@mcp-abap-adt/llm-agent-server-libs 20.0.0 → 20.5.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/builders/controller-skill-pipeline-builder.d.ts +57 -0
- package/dist/builders/controller-skill-pipeline-builder.d.ts.map +1 -0
- package/dist/builders/controller-skill-pipeline-builder.js +175 -0
- package/dist/builders/controller-skill-pipeline-builder.js.map +1 -0
- package/dist/factories/controller-factory.d.ts +18 -1
- package/dist/factories/controller-factory.d.ts.map +1 -1
- package/dist/factories/controller-factory.js +12 -1
- package/dist/factories/controller-factory.js.map +1 -1
- package/dist/generated/version.d.ts +1 -1
- package/dist/generated/version.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/mcp/compose-auxiliary.d.ts +35 -0
- package/dist/mcp/compose-auxiliary.d.ts.map +1 -0
- package/dist/mcp/compose-auxiliary.js +64 -0
- package/dist/mcp/compose-auxiliary.js.map +1 -0
- package/dist/pipelines/controller.d.ts.map +1 -1
- package/dist/pipelines/controller.js +87 -5
- package/dist/pipelines/controller.js.map +1 -1
- package/dist/pipelines/coordinator-resolvers.d.ts +68 -0
- package/dist/pipelines/coordinator-resolvers.d.ts.map +1 -0
- package/dist/pipelines/coordinator-resolvers.js +97 -0
- package/dist/pipelines/coordinator-resolvers.js.map +1 -0
- package/dist/pipelines/parsers.d.ts +1 -1
- package/dist/pipelines/parsers.d.ts.map +1 -1
- package/dist/pipelines/parsers.js +5 -4
- package/dist/pipelines/parsers.js.map +1 -1
- package/dist/pipelines/register-skill-sources.d.ts.map +1 -1
- package/dist/pipelines/register-skill-sources.js +5 -0
- package/dist/pipelines/register-skill-sources.js.map +1 -1
- package/dist/smart-agent/build-stepper-root.d.ts +3 -2
- package/dist/smart-agent/build-stepper-root.d.ts.map +1 -1
- package/dist/smart-agent/build-stepper-root.js +2 -1
- package/dist/smart-agent/build-stepper-root.js.map +1 -1
- package/dist/smart-agent/config-reload-watcher.d.ts +30 -0
- package/dist/smart-agent/config-reload-watcher.d.ts.map +1 -0
- package/dist/smart-agent/config-reload-watcher.js +101 -0
- package/dist/smart-agent/config-reload-watcher.js.map +1 -0
- package/dist/smart-agent/config-validator.d.ts +21 -0
- package/dist/smart-agent/config-validator.d.ts.map +1 -0
- package/dist/smart-agent/config-validator.js +196 -0
- package/dist/smart-agent/config-validator.js.map +1 -0
- package/dist/smart-agent/config.d.ts +16 -254
- package/dist/smart-agent/config.d.ts.map +1 -1
- package/dist/smart-agent/config.js +17 -904
- package/dist/smart-agent/config.js.map +1 -1
- package/dist/smart-agent/controller/board.d.ts +6 -3
- package/dist/smart-agent/controller/board.d.ts.map +1 -1
- package/dist/smart-agent/controller/board.js +21 -0
- package/dist/smart-agent/controller/board.js.map +1 -1
- package/dist/smart-agent/controller/controller-coordinator-handler.d.ts +24 -50
- package/dist/smart-agent/controller/controller-coordinator-handler.d.ts.map +1 -1
- package/dist/smart-agent/controller/controller-coordinator-handler.js +542 -676
- package/dist/smart-agent/controller/controller-coordinator-handler.js.map +1 -1
- package/dist/smart-agent/controller/default-step-execution-control.d.ts +7 -0
- package/dist/smart-agent/controller/default-step-execution-control.d.ts.map +1 -0
- package/dist/smart-agent/controller/default-step-execution-control.js +36 -0
- package/dist/smart-agent/controller/default-step-execution-control.js.map +1 -0
- package/dist/smart-agent/controller/finalizer.d.ts +5 -0
- package/dist/smart-agent/controller/finalizer.d.ts.map +1 -1
- package/dist/smart-agent/controller/finalizer.js +12 -5
- package/dist/smart-agent/controller/finalizer.js.map +1 -1
- package/dist/smart-agent/controller/noop-run-execution-control.d.ts +6 -0
- package/dist/smart-agent/controller/noop-run-execution-control.d.ts.map +1 -0
- package/dist/smart-agent/controller/noop-run-execution-control.js +14 -0
- package/dist/smart-agent/controller/noop-run-execution-control.js.map +1 -0
- package/dist/smart-agent/controller/parser.d.ts +11 -0
- package/dist/smart-agent/controller/parser.d.ts.map +1 -0
- package/dist/smart-agent/controller/parser.js +77 -0
- package/dist/smart-agent/controller/parser.js.map +1 -0
- package/dist/smart-agent/controller/planner.js +1 -1
- package/dist/smart-agent/controller/planner.js.map +1 -1
- package/dist/smart-agent/controller/recall.d.ts +48 -0
- package/dist/smart-agent/controller/recall.d.ts.map +1 -0
- package/dist/smart-agent/controller/recall.js +196 -0
- package/dist/smart-agent/controller/recall.js.map +1 -0
- package/dist/smart-agent/controller/reviewer.d.ts.map +1 -1
- package/dist/smart-agent/controller/reviewer.js +1 -1
- package/dist/smart-agent/controller/reviewer.js.map +1 -1
- package/dist/smart-agent/controller/subagent-client.d.ts +2 -2
- package/dist/smart-agent/controller/subagent-client.d.ts.map +1 -1
- package/dist/smart-agent/controller/subagent-client.js +2 -2
- package/dist/smart-agent/controller/subagent-client.js.map +1 -1
- package/dist/smart-agent/controller/types.d.ts +16 -4
- package/dist/smart-agent/controller/types.d.ts.map +1 -1
- package/dist/smart-agent/controller/types.js.map +1 -1
- package/dist/smart-agent/controller/usage-logging.d.ts +16 -0
- package/dist/smart-agent/controller/usage-logging.d.ts.map +1 -0
- package/dist/smart-agent/controller/usage-logging.js +39 -0
- package/dist/smart-agent/controller/usage-logging.js.map +1 -0
- package/dist/smart-agent/http/adapter-route-handler.d.ts +13 -0
- package/dist/smart-agent/http/adapter-route-handler.d.ts.map +1 -0
- package/dist/smart-agent/http/adapter-route-handler.js +76 -0
- package/dist/smart-agent/http/adapter-route-handler.js.map +1 -0
- package/dist/smart-agent/http/chat-route-handler.d.ts +15 -0
- package/dist/smart-agent/http/chat-route-handler.d.ts.map +1 -0
- package/dist/smart-agent/http/chat-route-handler.js +327 -0
- package/dist/smart-agent/http/chat-route-handler.js.map +1 -0
- package/dist/smart-agent/http/config-route-handler.d.ts +21 -0
- package/dist/smart-agent/http/config-route-handler.d.ts.map +1 -0
- package/dist/smart-agent/http/config-route-handler.js +149 -0
- package/dist/smart-agent/http/config-route-handler.js.map +1 -0
- package/dist/smart-agent/http/health-route-handler.d.ts +12 -0
- package/dist/smart-agent/http/health-route-handler.d.ts.map +1 -0
- package/dist/smart-agent/http/health-route-handler.js +19 -0
- package/dist/smart-agent/http/health-route-handler.js.map +1 -0
- package/dist/smart-agent/http/models-route-handler.d.ts +17 -0
- package/dist/smart-agent/http/models-route-handler.d.ts.map +1 -0
- package/dist/smart-agent/http/models-route-handler.js +65 -0
- package/dist/smart-agent/http/models-route-handler.js.map +1 -0
- package/dist/smart-agent/http/response-helpers.d.ts +31 -0
- package/dist/smart-agent/http/response-helpers.d.ts.map +1 -0
- package/dist/smart-agent/http/response-helpers.js +59 -0
- package/dist/smart-agent/http/response-helpers.js.map +1 -0
- package/dist/smart-agent/http/route-table.d.ts +44 -0
- package/dist/smart-agent/http/route-table.d.ts.map +1 -0
- package/dist/smart-agent/http/route-table.js +35 -0
- package/dist/smart-agent/http/route-table.js.map +1 -0
- package/dist/smart-agent/http/session-cookie.d.ts +10 -0
- package/dist/smart-agent/http/session-cookie.d.ts.map +1 -0
- package/dist/smart-agent/http/session-cookie.js +16 -0
- package/dist/smart-agent/http/session-cookie.js.map +1 -0
- package/dist/smart-agent/http/sessions-route-handler.d.ts +8 -0
- package/dist/smart-agent/http/sessions-route-handler.d.ts.map +1 -0
- package/dist/smart-agent/http/sessions-route-handler.js +54 -0
- package/dist/smart-agent/http/sessions-route-handler.js.map +1 -0
- package/dist/smart-agent/http/usage-route-handler.d.ts +12 -0
- package/dist/smart-agent/http/usage-route-handler.d.ts.map +1 -0
- package/dist/smart-agent/http/usage-route-handler.js +28 -0
- package/dist/smart-agent/http/usage-route-handler.js.map +1 -0
- package/dist/smart-agent/knowledge/make-knowledge-backend.d.ts +13 -0
- package/dist/smart-agent/knowledge/make-knowledge-backend.d.ts.map +1 -0
- package/dist/smart-agent/knowledge/make-knowledge-backend.js +18 -0
- package/dist/smart-agent/knowledge/make-knowledge-backend.js.map +1 -0
- package/dist/smart-agent/llm/role-llm-resolver.d.ts +30 -0
- package/dist/smart-agent/llm/role-llm-resolver.d.ts.map +1 -0
- package/dist/smart-agent/llm/role-llm-resolver.js +44 -0
- package/dist/smart-agent/llm/role-llm-resolver.js.map +1 -0
- package/dist/smart-agent/llm-config-map.d.ts +38 -0
- package/dist/smart-agent/llm-config-map.d.ts.map +1 -0
- package/dist/smart-agent/llm-config-map.js +75 -0
- package/dist/smart-agent/llm-config-map.js.map +1 -0
- package/dist/smart-agent/mcp-readiness-monitor.d.ts +38 -0
- package/dist/smart-agent/mcp-readiness-monitor.d.ts.map +1 -0
- package/dist/smart-agent/mcp-readiness-monitor.js +81 -0
- package/dist/smart-agent/mcp-readiness-monitor.js.map +1 -0
- package/dist/smart-agent/mcp-readiness-registry.d.ts +37 -0
- package/dist/smart-agent/mcp-readiness-registry.d.ts.map +1 -0
- package/dist/smart-agent/mcp-readiness-registry.js +55 -0
- package/dist/smart-agent/mcp-readiness-registry.js.map +1 -0
- package/dist/smart-agent/resolve-config-sections.d.ts +15 -0
- package/dist/smart-agent/resolve-config-sections.d.ts.map +1 -0
- package/dist/smart-agent/resolve-config-sections.js +212 -0
- package/dist/smart-agent/resolve-config-sections.js.map +1 -0
- package/dist/smart-agent/session-lifecycle/index.d.ts +117 -0
- package/dist/smart-agent/session-lifecycle/index.d.ts.map +1 -0
- package/dist/smart-agent/session-lifecycle/index.js +152 -0
- package/dist/smart-agent/session-lifecycle/index.js.map +1 -0
- package/dist/smart-agent/skill-plugins-config.d.ts +9 -1
- package/dist/smart-agent/skill-plugins-config.d.ts.map +1 -1
- package/dist/smart-agent/skill-plugins-config.js +27 -1
- package/dist/smart-agent/skill-plugins-config.js.map +1 -1
- package/dist/smart-agent/skill-plugins-host-factory.d.ts +14 -2
- package/dist/smart-agent/skill-plugins-host-factory.d.ts.map +1 -1
- package/dist/smart-agent/skill-plugins-host-factory.js +16 -4
- package/dist/smart-agent/skill-plugins-host-factory.js.map +1 -1
- package/dist/smart-agent/smart-server.d.ts +169 -222
- package/dist/smart-agent/smart-server.d.ts.map +1 -1
- package/dist/smart-agent/smart-server.js +569 -1387
- package/dist/smart-agent/smart-server.js.map +1 -1
- package/dist/smart-agent/stepper-config.d.ts +138 -0
- package/dist/smart-agent/stepper-config.d.ts.map +1 -0
- package/dist/smart-agent/stepper-config.js +216 -0
- package/dist/smart-agent/stepper-config.js.map +1 -0
- package/dist/smart-agent/tools-rag-handle.d.ts +10 -0
- package/dist/smart-agent/tools-rag-handle.d.ts.map +1 -0
- package/dist/smart-agent/tools-rag-handle.js +76 -0
- package/dist/smart-agent/tools-rag-handle.js.map +1 -0
- package/dist/smart-agent/workers/worker-registry.d.ts +159 -0
- package/dist/smart-agent/workers/worker-registry.d.ts.map +1 -0
- package/dist/smart-agent/workers/worker-registry.js +203 -0
- package/dist/smart-agent/workers/worker-registry.js.map +1 -0
- package/dist/smart-agent/yaml-loader.d.ts +7 -0
- package/dist/smart-agent/yaml-loader.d.ts.map +1 -0
- package/dist/smart-agent/yaml-loader.js +146 -0
- package/dist/smart-agent/yaml-loader.js.map +1 -0
- package/package.json +7 -7
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { IMcpClient, ISmartAgent } from '@mcp-abap-adt/llm-agent';
|
|
2
|
+
import type { PlannerKind } from '../smart-agent/controller/types.js';
|
|
3
|
+
import type { BuildAgentDeps, SmartServerConfig } from '../smart-agent/smart-server.js';
|
|
4
|
+
export interface BuilderLlmInput {
|
|
5
|
+
provider: 'sap-ai-sdk' | 'openai' | 'anthropic' | 'deepseek' | 'ollama';
|
|
6
|
+
model?: string;
|
|
7
|
+
apiKey?: string;
|
|
8
|
+
url?: string;
|
|
9
|
+
temperature?: number;
|
|
10
|
+
maxTokens?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface BuilderSkillSourceInput {
|
|
13
|
+
github: string;
|
|
14
|
+
enabled: readonly string[];
|
|
15
|
+
collection?: string;
|
|
16
|
+
ref?: string;
|
|
17
|
+
token?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface BuilderEmbedderInput {
|
|
20
|
+
provider: string;
|
|
21
|
+
model?: string;
|
|
22
|
+
scenario?: string;
|
|
23
|
+
resourceGroup?: string;
|
|
24
|
+
}
|
|
25
|
+
type Role = 'evaluator' | 'planner' | 'executor';
|
|
26
|
+
export declare class ControllerSkillPipelineBuilder {
|
|
27
|
+
private _llm?;
|
|
28
|
+
private _roleLlm;
|
|
29
|
+
private _mcp;
|
|
30
|
+
private _mcpClients?;
|
|
31
|
+
private _skill?;
|
|
32
|
+
private _embedder?;
|
|
33
|
+
private _budgets;
|
|
34
|
+
private _targetState;
|
|
35
|
+
private _plannerKind;
|
|
36
|
+
withLlm(cfg: BuilderLlmInput): this;
|
|
37
|
+
withRoleLlm(role: Role, cfg: BuilderLlmInput): this;
|
|
38
|
+
withMcp(cfg: {
|
|
39
|
+
url: string;
|
|
40
|
+
headers?: Record<string, string>;
|
|
41
|
+
}): this;
|
|
42
|
+
withMcpClients(clients: IMcpClient[]): this;
|
|
43
|
+
withSkillSource(cfg: BuilderSkillSourceInput): this;
|
|
44
|
+
withEmbedder(cfg: BuilderEmbedderInput): this;
|
|
45
|
+
withBudgets(b: Record<string, unknown>): this;
|
|
46
|
+
withTargetState(t: Record<string, unknown>): this;
|
|
47
|
+
withPlanner(kind: PlannerKind): this;
|
|
48
|
+
toConfig(opts?: {
|
|
49
|
+
skipProviderRuntimeChecks?: boolean;
|
|
50
|
+
}): SmartServerConfig;
|
|
51
|
+
build(deps?: BuildAgentDeps): Promise<{
|
|
52
|
+
agent: ISmartAgent;
|
|
53
|
+
close: () => Promise<void>;
|
|
54
|
+
}>;
|
|
55
|
+
}
|
|
56
|
+
export {};
|
|
57
|
+
//# sourceMappingURL=controller-skill-pipeline-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controller-skill-pipeline-builder.d.ts","sourceRoot":"","sources":["../../src/builders/controller-skill-pipeline-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,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C;IAErD,OAAO,CAAC,GAAG,EAAE,eAAe,GAAG,IAAI;IAInC,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,eAAe,GAAG,IAAI;IAInD,OAAO,CAAC,GAAG,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,GAAG,IAAI;IAQrE,cAAc,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,IAAI;IAI3C,eAAe,CAAC,GAAG,EAAE,uBAAuB,GAAG,IAAI;IAInD,YAAY,CAAC,GAAG,EAAE,oBAAoB,GAAG,IAAI;IAI7C,WAAW,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAI7C,eAAe,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAIjD,WAAW,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI;IAKpC,QAAQ,CACN,IAAI,GAAE;QAAE,yBAAyB,CAAC,EAAE,OAAO,CAAA;KAAO,GACjD,iBAAiB;IAyFd,KAAK,CACT,IAAI,CAAC,EAAE,cAAc,GACpB,OAAO,CAAC;QAAE,KAAK,EAAE,WAAW,CAAC;QAAC,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;KAAE,CAAC;CAoB/D"}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { resolveSmartServerConfig } from '../smart-agent/config.js';
|
|
2
|
+
import { buildAgent } from '../smart-agent/smart-server.js';
|
|
3
|
+
const KEYLESS = new Set(['sap-ai-sdk', 'ollama']);
|
|
4
|
+
const ENV_KEY = {
|
|
5
|
+
openai: 'OPENAI_API_KEY',
|
|
6
|
+
anthropic: 'ANTHROPIC_API_KEY',
|
|
7
|
+
deepseek: 'DEEPSEEK_API_KEY',
|
|
8
|
+
};
|
|
9
|
+
function toLlmConfig(input, opts = {}) {
|
|
10
|
+
let apiKey = input.apiKey ?? '';
|
|
11
|
+
if (!KEYLESS.has(input.provider) && apiKey === '') {
|
|
12
|
+
apiKey = process.env[ENV_KEY[input.provider] ?? ''] ?? '';
|
|
13
|
+
if (apiKey === '' && !opts.skipRuntime) {
|
|
14
|
+
throw new Error(`ControllerSkillPipelineBuilder: provider '${input.provider}' needs an apiKey — ` +
|
|
15
|
+
`pass it to .withLlm()/.withRoleLlm() or set ${ENV_KEY[input.provider]}`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
provider: input.provider,
|
|
20
|
+
apiKey,
|
|
21
|
+
...(input.model !== undefined ? { model: input.model } : {}),
|
|
22
|
+
...(input.url !== undefined ? { url: input.url } : {}),
|
|
23
|
+
...(input.temperature !== undefined
|
|
24
|
+
? { temperature: input.temperature }
|
|
25
|
+
: {}),
|
|
26
|
+
...(input.maxTokens !== undefined ? { maxTokens: input.maxTokens } : {}),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export class ControllerSkillPipelineBuilder {
|
|
30
|
+
_llm;
|
|
31
|
+
_roleLlm = {};
|
|
32
|
+
_mcp = [];
|
|
33
|
+
_mcpClients;
|
|
34
|
+
_skill;
|
|
35
|
+
_embedder;
|
|
36
|
+
_budgets = {};
|
|
37
|
+
_targetState = {};
|
|
38
|
+
_plannerKind = 'smart-executor';
|
|
39
|
+
withLlm(cfg) {
|
|
40
|
+
this._llm = cfg;
|
|
41
|
+
return this;
|
|
42
|
+
}
|
|
43
|
+
withRoleLlm(role, cfg) {
|
|
44
|
+
this._roleLlm[role] = cfg;
|
|
45
|
+
return this;
|
|
46
|
+
}
|
|
47
|
+
withMcp(cfg) {
|
|
48
|
+
this._mcp.push({
|
|
49
|
+
type: 'http',
|
|
50
|
+
url: cfg.url,
|
|
51
|
+
...(cfg.headers ? { headers: cfg.headers } : {}),
|
|
52
|
+
});
|
|
53
|
+
return this;
|
|
54
|
+
}
|
|
55
|
+
withMcpClients(clients) {
|
|
56
|
+
this._mcpClients = clients;
|
|
57
|
+
return this;
|
|
58
|
+
}
|
|
59
|
+
withSkillSource(cfg) {
|
|
60
|
+
this._skill = cfg;
|
|
61
|
+
return this;
|
|
62
|
+
}
|
|
63
|
+
withEmbedder(cfg) {
|
|
64
|
+
this._embedder = cfg;
|
|
65
|
+
return this;
|
|
66
|
+
}
|
|
67
|
+
withBudgets(b) {
|
|
68
|
+
this._budgets = { ...this._budgets, ...b };
|
|
69
|
+
return this;
|
|
70
|
+
}
|
|
71
|
+
withTargetState(t) {
|
|
72
|
+
this._targetState = { ...this._targetState, ...t };
|
|
73
|
+
return this;
|
|
74
|
+
}
|
|
75
|
+
withPlanner(kind) {
|
|
76
|
+
this._plannerKind = kind;
|
|
77
|
+
return this;
|
|
78
|
+
}
|
|
79
|
+
toConfig(opts = {}) {
|
|
80
|
+
if (!this._llm && Object.keys(this._roleLlm).length === 0) {
|
|
81
|
+
throw new Error('ControllerSkillPipelineBuilder: call .withLlm() (or .withRoleLlm() for all roles) before building');
|
|
82
|
+
}
|
|
83
|
+
if (!this._skill) {
|
|
84
|
+
throw new Error('ControllerSkillPipelineBuilder: call .withSkillSource() before building');
|
|
85
|
+
}
|
|
86
|
+
if (!this._embedder) {
|
|
87
|
+
throw new Error('ControllerSkillPipelineBuilder: call .withEmbedder() before building (skills need an embedder)');
|
|
88
|
+
}
|
|
89
|
+
const skipRuntime = opts.skipProviderRuntimeChecks;
|
|
90
|
+
const base = this._llm
|
|
91
|
+
? toLlmConfig(this._llm, { skipRuntime })
|
|
92
|
+
: undefined;
|
|
93
|
+
const roleCfg = (r) => {
|
|
94
|
+
const ovr = this._roleLlm[r];
|
|
95
|
+
if (ovr)
|
|
96
|
+
return toLlmConfig(ovr, { skipRuntime });
|
|
97
|
+
if (base)
|
|
98
|
+
return base;
|
|
99
|
+
throw new Error(`ControllerSkillPipelineBuilder: no LLM for role '${r}' (set .withLlm() or .withRoleLlm('${r}', …))`);
|
|
100
|
+
};
|
|
101
|
+
const collection = this._skill.collection ?? 'sap';
|
|
102
|
+
return {
|
|
103
|
+
llm: { main: base ?? roleCfg('executor') },
|
|
104
|
+
pipeline: {
|
|
105
|
+
name: this._plannerKind === 'weak-executor'
|
|
106
|
+
? 'controller-weak'
|
|
107
|
+
: 'controller',
|
|
108
|
+
config: {
|
|
109
|
+
subagents: {
|
|
110
|
+
evaluator: roleCfg('evaluator'),
|
|
111
|
+
planner: roleCfg('planner'),
|
|
112
|
+
executor: roleCfg('executor'),
|
|
113
|
+
},
|
|
114
|
+
...(Object.keys(this._targetState).length
|
|
115
|
+
? { targetState: this._targetState }
|
|
116
|
+
: {}),
|
|
117
|
+
...(Object.keys(this._budgets).length
|
|
118
|
+
? { budgets: this._budgets }
|
|
119
|
+
: {}),
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
rag: {
|
|
123
|
+
type: 'in-memory',
|
|
124
|
+
embedder: this._embedder.provider,
|
|
125
|
+
...(this._embedder.model ? { model: this._embedder.model } : {}),
|
|
126
|
+
...(this._embedder.scenario
|
|
127
|
+
? { scenario: this._embedder.scenario }
|
|
128
|
+
: {}),
|
|
129
|
+
...(this._embedder.resourceGroup
|
|
130
|
+
? { resourceGroup: this._embedder.resourceGroup }
|
|
131
|
+
: {}),
|
|
132
|
+
},
|
|
133
|
+
...(this._mcp.length ? { mcp: this._mcp } : {}),
|
|
134
|
+
skillPlugins: {
|
|
135
|
+
store: { type: 'in-memory' },
|
|
136
|
+
// Intentionally NO `embedder` here: there is a single fluent embedder, and
|
|
137
|
+
// omitting `skillPlugins.embedder` makes SmartServer REUSE the already-
|
|
138
|
+
// resolved agent-RAG embedder (built from `rag` above with the full
|
|
139
|
+
// scenario/resourceGroup). Setting `skillPlugins.embedder` would force a
|
|
140
|
+
// SEPARATE skill-host embedder built from provider/model ONLY — dropping
|
|
141
|
+
// scenario/resourceGroup and causing a deployment mismatch (review P1).
|
|
142
|
+
controllerSkillGroup: collection,
|
|
143
|
+
sources: [
|
|
144
|
+
{
|
|
145
|
+
id: 'skills',
|
|
146
|
+
github: this._skill.github,
|
|
147
|
+
enabled: this._skill.enabled,
|
|
148
|
+
...(this._skill.ref ? { ref: this._skill.ref } : {}),
|
|
149
|
+
...(this._skill.token ? { token: this._skill.token } : {}),
|
|
150
|
+
strategy: 'single-collection',
|
|
151
|
+
strategyConfig: { collection },
|
|
152
|
+
},
|
|
153
|
+
],
|
|
154
|
+
},
|
|
155
|
+
// RAW yaml-shaped config (carries skillPlugins / pipeline.config keys that aren't
|
|
156
|
+
// all on the typed SmartServerConfig surface); resolveSmartServerConfig in build()
|
|
157
|
+
// validates + fills defaults. Shape is covered by the translation unit tests.
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
async build(deps) {
|
|
161
|
+
// When the consumer injects BOTH the LLM factory and the embedder, the real
|
|
162
|
+
// provider/credentials/model are never used — skip provider-runtime config
|
|
163
|
+
// validation (structural checks still run).
|
|
164
|
+
const skipProviderRuntimeChecks = !!(deps?.makeLlm && deps?.embedder);
|
|
165
|
+
const normalized = resolveSmartServerConfig({}, this.toConfig({ skipProviderRuntimeChecks }), process.env, { skipProviderRuntimeChecks });
|
|
166
|
+
const mergedDeps = this._mcpClients || deps
|
|
167
|
+
? {
|
|
168
|
+
...(this._mcpClients ? { mcpClients: this._mcpClients } : {}),
|
|
169
|
+
...deps,
|
|
170
|
+
}
|
|
171
|
+
: undefined;
|
|
172
|
+
return buildAgent(normalized, mergedDeps);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
//# sourceMappingURL=controller-skill-pipeline-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controller-skill-pipeline-builder.js","sourceRoot":"","sources":["../../src/builders/controller-skill-pipeline-builder.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAQpE,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAyB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AAkF;YAClF,mFAAmF;YACnF,8EAA8E;SAC/C,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,KAAK,CACT,IAAqB;QAErB,4EAA4E;QAC5E,2EAA2E;QAC3E,4CAA4C;QAC5C,MAAM,yBAAyB,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,OAAO,IAAI,IAAI,EAAE,QAAQ,CAAC,CAAC;QACtE,MAAM,UAAU,GAAG,wBAAwB,CACzC,EAAE,EACF,IAAI,CAAC,QAAQ,CAAC,EAAE,yBAAyB,EAAE,CAAe,EAC1D,OAAO,CAAC,GAAG,EACX,EAAE,yBAAyB,EAAE,CAC9B,CAAC;QACF,MAAM,UAAU,GACd,IAAI,CAAC,WAAW,IAAI,IAAI;YACtB,CAAC,CAAC;gBACE,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC7D,GAAG,IAAI;aACR;YACH,CAAC,CAAC,SAAS,CAAC;QAChB,OAAO,UAAU,CAAC,UAA+B,EAAE,UAAU,CAAC,CAAC;IACjE,CAAC;CACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BuiltCoordinator, CallOptions, IEmbedder, IKnowledgeRagHandle, IPipelineFactory, LlmTool, PipelineFactoryDepsBase } from '@mcp-abap-adt/llm-agent';
|
|
1
|
+
import type { BuiltCoordinator, CallOptions, IEmbedder, IKnowledgeRagHandle, IPipelineFactory, IRunExecutionControl, IStepExecutionControl, LlmTool, PipelineFactoryDepsBase, ToolLoopContextStrategyFactory } from '@mcp-abap-adt/llm-agent';
|
|
2
2
|
import type { KnowledgeBackend } from '@mcp-abap-adt/llm-agent-libs';
|
|
3
3
|
import type { ControllerConfig, PlannerKind } from '../smart-agent/controller/types.js';
|
|
4
4
|
/**
|
|
@@ -29,6 +29,23 @@ export interface ControllerFactoryDeps extends PipelineFactoryDepsBase {
|
|
|
29
29
|
* to the agnostic path (the measurement toggle).
|
|
30
30
|
*/
|
|
31
31
|
skillsRecall?: (goal: string, options?: CallOptions) => Promise<string>;
|
|
32
|
+
/**
|
|
33
|
+
* Per-step tool-loop context strategy factory (record/form). Called ONCE per
|
|
34
|
+
* step by the handler with the per-step run context (`{ rag, runId, meta,
|
|
35
|
+
* stepName }`). The controller pipeline injects a `RagRecall` factory here (its
|
|
36
|
+
* `record` persists an `mcp-result`, its `recall` runs `runScopedRecall`).
|
|
37
|
+
* Absent → the handler falls back to `LegacyAccumulateContextStrategy`
|
|
38
|
+
* (byte-identical to the historical growing transcript).
|
|
39
|
+
*/
|
|
40
|
+
toolLoopContextStrategyFactory?: ToolLoopContextStrategyFactory;
|
|
41
|
+
/** Consumer-swappable per-step execution control (timeout / tool-call budget).
|
|
42
|
+
* The controller pipeline resolves `ctx.stepExecutionControl ?? new DefaultStepExecutionControl()`.
|
|
43
|
+
* Absent → the handler defaults (no timeout armed, never aborts). */
|
|
44
|
+
stepExecutionControl?: IStepExecutionControl;
|
|
45
|
+
/** Consumer-swappable per-run execution control (max steps / run timeout).
|
|
46
|
+
* The controller pipeline resolves `ctx.runExecutionControl ?? new NoopRunExecutionControl()`.
|
|
47
|
+
* Absent → the handler no-ops (never fires). */
|
|
48
|
+
runExecutionControl?: IRunExecutionControl;
|
|
32
49
|
}
|
|
33
50
|
/**
|
|
34
51
|
* Builder-factory for the `controller` pipeline — the code-level (no-YAML)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller-factory.d.ts","sourceRoot":"","sources":["../../src/factories/controller-factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,WAAW,EACX,SAAS,EACT,mBAAmB,EACnB,gBAAgB,EAChB,OAAO,EACP,uBAAuB,
|
|
1
|
+
{"version":3,"file":"controller-factory.d.ts","sourceRoot":"","sources":["../../src/factories/controller-factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB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AAI,EAAG,YAAY,CAAU;IAEhC,KAAK,CACT,MAAM,EAAE,gBAAgB,EACxB,IAAI,EAAE,qBAAqB,EAC3B,WAAW,GAAE,WAA8B,GAC1C,OAAO,CAAC,gBAAgB,CAAC;CAqF7B"}
|
|
@@ -76,10 +76,21 @@ export class ControllerFactory {
|
|
|
76
76
|
backend: deps.backend,
|
|
77
77
|
knowledgeRagFor: deps.knowledgeRagFor,
|
|
78
78
|
embedder: deps.embedder,
|
|
79
|
-
callMcp: (name, args) => deps.callMcp(name, args),
|
|
79
|
+
callMcp: (name, args, signal) => deps.callMcp(name, args, signal),
|
|
80
80
|
selectTools: deps.selectTools,
|
|
81
81
|
...(deps.isExternalTool ? { isExternalTool: deps.isExternalTool } : {}),
|
|
82
82
|
...(deps.skillsRecall ? { skillsRecall: deps.skillsRecall } : {}),
|
|
83
|
+
...(deps.toolLoopContextStrategyFactory
|
|
84
|
+
? {
|
|
85
|
+
toolLoopContextStrategyFactory: deps.toolLoopContextStrategyFactory,
|
|
86
|
+
}
|
|
87
|
+
: {}),
|
|
88
|
+
...(deps.stepExecutionControl
|
|
89
|
+
? { stepExecutionControl: deps.stepExecutionControl }
|
|
90
|
+
: {}),
|
|
91
|
+
...(deps.runExecutionControl
|
|
92
|
+
? { runExecutionControl: deps.runExecutionControl }
|
|
93
|
+
: {}),
|
|
83
94
|
reviewer: new LlmReviewer(makeSubagentClient(reviewerLlm)),
|
|
84
95
|
finalizer: new LlmFinalizer(makeSubagentClient(finalizerLlm), {
|
|
85
96
|
budget: 12000,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller-factory.js","sourceRoot":"","sources":["../../src/factories/controller-factory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"controller-factory.js","sourceRoot":"","sources":["../../src/factories/controller-factory.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,4BAA4B,EAAE,MAA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gBACH,CAAC,CAAC,EAAE,CAAC;YACP,GAAG,CAAC,IAAI,CAAC,oBAAoB;gBAC3B,CAAC,CAAC,EAAE,oBAAoB,EAAE,IAAI,CAAC,oBAAoB,EAAE;gBACrD,CAAC,CAAC,EAAE,CAAC;YACP,GAAG,CAAC,IAAI,CAAC,mBAAmB;gBAC1B,CAAC,CAAC,EAAE,mBAAmB,EAAE,IAAI,CAAC,mBAAmB,EAAE;gBACnD,CAAC,CAAC,EAAE,CAAC;YACP,QAAQ,EAAE,IAAI,WAAW,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC;YAC1D,SAAS,EAAE,IAAI,YAAY,CAAC,kBAAkB,CAAC,YAAY,CAAC,EAAE;gBAC5D,MAAM,EAAE,KAAK;gBACb,YAAY,EAAE,IAAI;aACnB,CAAC;YACF,MAAM;YACN,WAAW;YACX,MAAM,EAAE;gBACN,SAAS,EAAE,YAAY,CAAC,KAAK,IAAI,SAAS;gBAC1C,OAAO,EAAE,UAAU,CAAC,KAAK,IAAI,SAAS;gBACtC,QAAQ,EAAE,WAAW,CAAC,KAAK,IAAI,SAAS;gBACxC,QAAQ,EAAE,WAAW,CAAC,KAAK,IAAI,SAAS;gBACxC,SAAS,EAAE,YAAY,CAAC,KAAK,IAAI,SAAS;aAC3C;SACF,CAAC,CAAC;QACH,OAAO,EAAE,OAAO,EAAE,CAAC;IACrB,CAAC;CACF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const PACKAGE_VERSION = "20.
|
|
1
|
+
export declare const PACKAGE_VERSION = "20.5.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { type BuilderEmbedderInput, type BuilderLlmInput, type BuilderSkillSourceInput, ControllerSkillPipelineBuilder, } from './builders/controller-skill-pipeline-builder.js';
|
|
1
2
|
export * from './factories/index.js';
|
|
2
3
|
export * from './pipelines/server-context.js';
|
|
3
4
|
export * from './smart-agent/build-dag-coordinator-deps.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,cAAc,sBAAsB,CAAC;AACrC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6CAA6C,CAAC;AAC5D,cAAc,qCAAqC,CAAC;AACpD,cAAc,yBAAyB,CAAC;AACxC,cAAc,0CAA0C,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AACtE,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yCAAyC,CAAC;AACxD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,qCAAqC,CAAC;AACpD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,8CAA8C,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAC5B,8BAA8B,GAC/B,MAAM,iDAAiD,CAAC;AACzD,cAAc,sBAAsB,CAAC;AACrC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6CAA6C,CAAC;AAC5D,cAAc,qCAAqC,CAAC;AACpD,cAAc,yBAAyB,CAAC;AACxC,cAAc,0CAA0C,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AACtE,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
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6CAA6C,CAAC;AAC5D,cAAc,qCAAqC,CAAC;AACpD,cAAc,yBAAyB,CAAC;AACxC,cAAc,0CAA0C,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AACtE,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yCAAyC,CAAC;AACxD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,qCAAqC,CAAC;AACpD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,8CAA8C,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,8BAA8B,GAC/B,MAAM,iDAAiD,CAAC;AACzD,cAAc,sBAAsB,CAAC;AACrC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6CAA6C,CAAC;AAC5D,cAAc,qCAAqC,CAAC;AACpD,cAAc,yBAAyB,CAAC;AACxC,cAAc,0CAA0C,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AACtE,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,35 @@
|
|
|
1
|
+
import type { CallOptions, IAuxiliaryMcpTools, IToolsRagHandle, LlmTool, McpError, McpTool, McpToolResult, Result } from '@mcp-abap-adt/llm-agent';
|
|
2
|
+
type CallMcp = (name: string, args: unknown, signal?: AbortSignal) => Promise<string>;
|
|
3
|
+
type AuxCallTool = (name: string, args: Record<string, unknown>, options?: CallOptions) => Promise<Result<McpToolResult, McpError>>;
|
|
4
|
+
/**
|
|
5
|
+
* Resolve the auxiliary tool defs ONCE at build. `!ok` is a real bug in the
|
|
6
|
+
* in-process provider — fail loud, never silently skip the aux tools.
|
|
7
|
+
*/
|
|
8
|
+
export declare function resolveAuxDefs(aux: IAuxiliaryMcpTools): Promise<McpTool[]>;
|
|
9
|
+
/**
|
|
10
|
+
* Fail-loud collision gate (sync, over the already-resolved defs). Aux-first
|
|
11
|
+
* dispatch would otherwise silently shadow a same-named domain tool. Uses the
|
|
12
|
+
* sync `toolsRag.lookup` (non-optional on IPipelineContext; EMPTY_TOOLS_RAG
|
|
13
|
+
* returns undefined for every name when there is no domain catalog).
|
|
14
|
+
*/
|
|
15
|
+
export declare function assertNoAuxCollision(auxDefs: McpTool[], toolsRag: IToolsRagHandle): void;
|
|
16
|
+
type SelectTools = (query: string, k?: number, options?: CallOptions) => Promise<readonly LlmTool[]>;
|
|
17
|
+
/**
|
|
18
|
+
* Wrap the pipeline's `selectTools` so the resolved auxiliary defs are ALWAYS
|
|
19
|
+
* merged into every selection result (deduped by name; aux appended). Auxiliary
|
|
20
|
+
* tools are a small fixed utility set that should always be in scope — not
|
|
21
|
+
* semantically ranked — which also makes them available MCP-less (domain
|
|
22
|
+
* `selectTools` → [] → result is just the aux defs). `McpTool` is structurally
|
|
23
|
+
* an `LlmTool`, so aux defs are assignable into the `LlmTool[]` result.
|
|
24
|
+
*/
|
|
25
|
+
export declare function composeAuxiliarySelect(auxDefs: McpTool[], selectTools: SelectTools): SelectTools;
|
|
26
|
+
/**
|
|
27
|
+
* Wrap the domain `callMcp` bridge so auxiliary tools are dispatched FIRST
|
|
28
|
+
* (aux-first; collisions were rejected at build). Auxiliary results are mapped
|
|
29
|
+
* to the string bridge contract: ok → content text / JSON; !ok → error.message
|
|
30
|
+
* (tool-level, the domain classifier / fail-loud is NOT run). An abort rejection
|
|
31
|
+
* from `auxCallTool` propagates unchanged (see the controller's abort handling).
|
|
32
|
+
*/
|
|
33
|
+
export declare function composeAuxiliaryBridge(auxDefs: McpTool[], auxCallTool: AuxCallTool, domainBridge: CallMcp): CallMcp;
|
|
34
|
+
export {};
|
|
35
|
+
//# sourceMappingURL=compose-auxiliary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compose-auxiliary.d.ts","sourceRoot":"","sources":["../../src/mcp/compose-auxiliary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,OAAO,EACP,QAAQ,EACR,OAAO,EACP,aAAa,EACb,MAAM,EACP,MAAM,yBAAyB,CAAC;AAEjC,KAAK,OAAO,GAAG,CACb,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,OAAO,EACb,MAAM,CAAC,EAAE,WAAW,KACjB,OAAO,CAAC,MAAM,CAAC,CAAC;AAErB,KAAK,WAAW,GAAG,CACjB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,CAAC,EAAE,WAAW,KAClB,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC,CAAC;AAE9C;;;GAGG;AACH,wBAAsB,cAAc,CAClC,GAAG,EAAE,kBAAkB,GACtB,OAAO,CAAC,OAAO,EAAE,CAAC,CAQpB;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,OAAO,EAAE,EAClB,QAAQ,EAAE,eAAe,GACxB,IAAI,CASN;AAED,KAAK,WAAW,GAAG,CACjB,KAAK,EAAE,MAAM,EACb,CAAC,CAAC,EAAE,MAAM,EACV,OAAO,CAAC,EAAE,WAAW,KAClB,OAAO,CAAC,SAAS,OAAO,EAAE,CAAC,CAAC;AAEjC;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,OAAO,EAAE,EAClB,WAAW,EAAE,WAAW,GACvB,WAAW,CAOb;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,OAAO,EAAE,EAClB,WAAW,EAAE,WAAW,EACxB,YAAY,EAAE,OAAO,GACpB,OAAO,CAiBT"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve the auxiliary tool defs ONCE at build. `!ok` is a real bug in the
|
|
3
|
+
* in-process provider — fail loud, never silently skip the aux tools.
|
|
4
|
+
*/
|
|
5
|
+
export async function resolveAuxDefs(aux) {
|
|
6
|
+
const listed = await aux.listTools();
|
|
7
|
+
if (!listed.ok) {
|
|
8
|
+
throw new Error(`auxiliary tools failed to list at build: ${listed.error.message}`);
|
|
9
|
+
}
|
|
10
|
+
return listed.value;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Fail-loud collision gate (sync, over the already-resolved defs). Aux-first
|
|
14
|
+
* dispatch would otherwise silently shadow a same-named domain tool. Uses the
|
|
15
|
+
* sync `toolsRag.lookup` (non-optional on IPipelineContext; EMPTY_TOOLS_RAG
|
|
16
|
+
* returns undefined for every name when there is no domain catalog).
|
|
17
|
+
*/
|
|
18
|
+
export function assertNoAuxCollision(auxDefs, toolsRag) {
|
|
19
|
+
for (const def of auxDefs) {
|
|
20
|
+
if (toolsRag.lookup(def.name) !== undefined) {
|
|
21
|
+
throw new Error(`auxiliary tool '${def.name}' collides with a connected MCP tool — ` +
|
|
22
|
+
'rename the auxiliary tool');
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Wrap the pipeline's `selectTools` so the resolved auxiliary defs are ALWAYS
|
|
28
|
+
* merged into every selection result (deduped by name; aux appended). Auxiliary
|
|
29
|
+
* tools are a small fixed utility set that should always be in scope — not
|
|
30
|
+
* semantically ranked — which also makes them available MCP-less (domain
|
|
31
|
+
* `selectTools` → [] → result is just the aux defs). `McpTool` is structurally
|
|
32
|
+
* an `LlmTool`, so aux defs are assignable into the `LlmTool[]` result.
|
|
33
|
+
*/
|
|
34
|
+
export function composeAuxiliarySelect(auxDefs, selectTools) {
|
|
35
|
+
return async (query, k, options) => {
|
|
36
|
+
const domain = await selectTools(query, k, options);
|
|
37
|
+
const domainNames = new Set(domain.map((t) => t.name));
|
|
38
|
+
const extra = auxDefs.filter((d) => !domainNames.has(d.name));
|
|
39
|
+
return [...domain, ...extra];
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Wrap the domain `callMcp` bridge so auxiliary tools are dispatched FIRST
|
|
44
|
+
* (aux-first; collisions were rejected at build). Auxiliary results are mapped
|
|
45
|
+
* to the string bridge contract: ok → content text / JSON; !ok → error.message
|
|
46
|
+
* (tool-level, the domain classifier / fail-loud is NOT run). An abort rejection
|
|
47
|
+
* from `auxCallTool` propagates unchanged (see the controller's abort handling).
|
|
48
|
+
*/
|
|
49
|
+
export function composeAuxiliaryBridge(auxDefs, auxCallTool, domainBridge) {
|
|
50
|
+
const auxNames = new Set(auxDefs.map((d) => d.name));
|
|
51
|
+
return async (name, args, signal) => {
|
|
52
|
+
if (!auxNames.has(name))
|
|
53
|
+
return domainBridge(name, args, signal);
|
|
54
|
+
const safeArgs = args != null && typeof args === 'object' && !Array.isArray(args)
|
|
55
|
+
? args
|
|
56
|
+
: {};
|
|
57
|
+
const result = await auxCallTool(name, safeArgs, signal ? { signal } : undefined);
|
|
58
|
+
if (!result.ok)
|
|
59
|
+
return result.error.message;
|
|
60
|
+
const { content } = result.value;
|
|
61
|
+
return typeof content === 'string' ? content : JSON.stringify(content);
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=compose-auxiliary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compose-auxiliary.js","sourceRoot":"","sources":["../../src/mcp/compose-auxiliary.ts"],"names":[],"mappings":"AAuBA;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,GAAuB;IAEvB,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,SAAS,EAAE,CAAC;IACrC,IAAI,CAAC,MAAM,CAAC,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CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IACrD,OAAO,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE;QAClC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,OAAO,YAAY,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QACjE,MAAM,QAAQ,GACZ,IAAI,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;YAC9D,CAAC,CAAE,IAAgC;YACnC,CAAC,CAAC,EAAE,CAAC;QACT,MAAM,MAAM,GAAG,MAAM,WAAW,CAC9B,IAAI,EACJ,QAAQ,EACR,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,CAChC,CAAC;QACF,IAAI,CAAC,MAAM,CAAC,EAAE;YAAE,OAAO,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC;QAC5C,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC;QACjC,OAAO,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACzE,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../src/pipelines/controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../src/pipelines/controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,iBAAiB,EACjB,eAAe,EAGhB,MAAM,yBAAyB,CAAC;AAyBjC,OAAO,KAAK,EACV,gBAAgB,EAChB,WAAW,EACZ,MAAM,oCAAoC,CAAC;AAE5C,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,qBAAqB,CAAC;AAM5E,OAAO,EACL,iBAAiB,EACjB,KAAK,qBAAqB,GAC3B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,4BAA4B,EAC5B,KAAK,qBAAqB,GAC3B,MAAM,6DAA6D,CAAC;AACrE,OAAO,EACL,KAAK,eAAe,EACpB,kBAAkB,GACnB,MAAM,8CAA8C,CAAC;AACtD,YAAY,EACV,gBAAgB,EAChB,aAAa,GACd,MAAM,oCAAoC,CAAC;AAE5C;;;;;;GAMG;AACH,qBAAa,wBACX,YAAW,eAAe,CAAC,gBAAgB,CAAC;IAE5C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAc;gBAExC,IAAI,SAAe,EACnB,WAAW,GAAE,WAA8B;IAM7C,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,gBAAgB;IAsDrC,KAAK,CACT,GAAG,EAAE,gBAAgB,EACrB,GAAG,EAAE,gCAAgC,GACpC,OAAO,CAAC,iBAAiB,CAAC;CAsM9B"}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
+
import { RagRecallContextStrategy } from '@mcp-abap-adt/llm-agent-libs';
|
|
2
|
+
import { DefaultAuxiliaryMcpTools, makeWaitTool, } from '@mcp-abap-adt/llm-agent-mcp';
|
|
1
3
|
import { ControllerFactory, } from '../factories/controller-factory.js';
|
|
4
|
+
import { assertNoAuxCollision, composeAuxiliaryBridge, composeAuxiliarySelect, resolveAuxDefs, } from '../mcp/compose-auxiliary.js';
|
|
5
|
+
import { DefaultStepExecutionControl } from '../smart-agent/controller/default-step-execution-control.js';
|
|
6
|
+
import { writeArtifact } from '../smart-agent/controller/memorizer.js';
|
|
7
|
+
import { NoopRunExecutionControl } from '../smart-agent/controller/noop-run-execution-control.js';
|
|
8
|
+
import { buildRecallBlock, RECALL_K_MCP, RECALL_MAX_CHARS_MCP, runScopedRecall, } from '../smart-agent/controller/recall.js';
|
|
2
9
|
import { buildMcpBridge } from '../smart-agent/smart-server.js';
|
|
3
10
|
// Re-export the controller building blocks so embedders (no-YAML) can compose
|
|
4
11
|
// the coordinator in code — preferably via the `ControllerFactory`
|
|
@@ -66,14 +73,25 @@ export class ControllerPipelinePlugin {
|
|
|
66
73
|
}
|
|
67
74
|
async build(cfg, ctx) {
|
|
68
75
|
const mcpClients = ctx.mcpClients ?? [];
|
|
69
|
-
|
|
76
|
+
// Honor the consumer-injected MCP failure classifier on the `pipeline: controller`
|
|
77
|
+
// path (ctx carries it from SmartServer/builder DI). Without this the bridge would
|
|
78
|
+
// silently fall back to DefaultMcpFailureClassifier and a custom policy (e.g. mapping
|
|
79
|
+
// an otherwise-tool-level code to 'unavailable') would be lost for the controller.
|
|
80
|
+
const mcpBridge = buildMcpBridge(mcpClients, ctx.mcpFailureClassifier);
|
|
81
|
+
// Auxiliary/service tools contributed at pipeline creation (default: wait).
|
|
82
|
+
// Consumer overrides the whole provider via ctx.auxiliaryMcpTools.
|
|
83
|
+
const aux = ctx.auxiliaryMcpTools ?? new DefaultAuxiliaryMcpTools([makeWaitTool()]);
|
|
84
|
+
const auxDefs = await resolveAuxDefs(aux); // single build-time listTools()
|
|
85
|
+
assertNoAuxCollision(auxDefs, ctx.toolsRag); // fail-loud on name collision
|
|
86
|
+
const auxCallMcp = composeAuxiliaryBridge(auxDefs, aux.callTool.bind(aux), mcpBridge);
|
|
70
87
|
// INTERNAL tools reach the executor/planner via SEMANTIC selection over the
|
|
71
88
|
// vectorized MCP catalog (toolsRag) — relevant top-K per query, not a full
|
|
72
89
|
// dump. The server vectorizes every MCP `tool:<name>` into toolsRag at
|
|
73
90
|
// startup. When no toolsRag is wired (MCP-less / no embedder) selection
|
|
74
91
|
// yields [] and the loop runs with external tools only.
|
|
75
92
|
const toolsRag = ctx.toolsRag;
|
|
76
|
-
const
|
|
93
|
+
const baseSelectTools = (query, k, options) => (toolsRag ? toolsRag.query(query, k, options) : Promise.resolve([]));
|
|
94
|
+
const selectTools = composeAuxiliarySelect(auxDefs, baseSelectTools);
|
|
77
95
|
// Controller-OWN skills recall hook (B4). The controller pipeline builds its
|
|
78
96
|
// subagent prompts itself (it does NOT use the context-assembler), so it needs
|
|
79
97
|
// its own recall: query the configured controller skill group and format a
|
|
@@ -97,30 +115,94 @@ export class ControllerPipelinePlugin {
|
|
|
97
115
|
? { k, threshold: ctx.skillRecall.threshold }
|
|
98
116
|
: { k };
|
|
99
117
|
const hits = await skillRagHandle.query(goal, queryOpts, options);
|
|
100
|
-
if (hits.length === 0)
|
|
118
|
+
if (hits.length === 0) {
|
|
119
|
+
// Make skill engagement verifiable: an empty recall means the planner
|
|
120
|
+
// prompt is byte-identical to the agnostic path (no skills injected).
|
|
121
|
+
if (process.env.DEBUG_CONTROLLER)
|
|
122
|
+
console.error(`[controller] skills-recall group=${group} hits=0 injected=0 chars=0 (empty — no skills in plan)`);
|
|
101
123
|
return '';
|
|
124
|
+
}
|
|
102
125
|
let block = 'Relevant skills:\n';
|
|
126
|
+
let injected = 0;
|
|
103
127
|
for (const h of hits) {
|
|
104
128
|
const next = `${block}- ${h.record.content}\n`;
|
|
105
129
|
if (next.length > maxInjectChars)
|
|
106
130
|
break;
|
|
107
131
|
block = next;
|
|
132
|
+
injected++;
|
|
108
133
|
}
|
|
109
|
-
|
|
134
|
+
const out = block.trimEnd();
|
|
135
|
+
// The recall block is built in-memory and never persisted, so without
|
|
136
|
+
// this line there is no way to confirm skills actually reached the plan.
|
|
137
|
+
if (process.env.DEBUG_CONTROLLER)
|
|
138
|
+
console.error(`[controller] skills-recall group=${group} hits=${hits.length} injected=${injected} chars=${out.length}`);
|
|
139
|
+
return out;
|
|
110
140
|
}
|
|
111
141
|
: undefined;
|
|
142
|
+
// Per-step tool-loop context strategy: RagRecall. The handler calls this
|
|
143
|
+
// factory ONCE PER STEP, passing the per-step run context
|
|
144
|
+
// (`{ rag, runId, meta, stepName }`) — meta/stepName are only known inside
|
|
145
|
+
// runStep. `record` persists the round as an `mcp-result` artifact (the write
|
|
146
|
+
// the handler used to do inline); `recall` runs the run-scoped MCP recall and
|
|
147
|
+
// formats a bounded "Relevant prior context" block, excluding the raw-tail
|
|
148
|
+
// round (which form() re-injects verbatim) by roundId.
|
|
149
|
+
//
|
|
150
|
+
// Run-scoped over-fetch bound (kPrime): a generous derivation from the
|
|
151
|
+
// controller budgets (steps × attempts × tool-calls) mirroring the prior
|
|
152
|
+
// inline `maxSteps * maxAttempts * maxTool`. maxStepAttempts is not on the
|
|
153
|
+
// pipeline budgets here, so `maxRetries + 1` stands in for per-step attempts.
|
|
154
|
+
const b = cfg.budgets;
|
|
155
|
+
const mcpBound = (b.maxSteps ?? 20) * ((b.maxRetries ?? 3) + 1) * (b.maxToolCalls ?? 10);
|
|
156
|
+
const ragRecallFactory = ({ run }) => {
|
|
157
|
+
const { rag, runId, meta, stepName } = run;
|
|
158
|
+
return new RagRecallContextStrategy({
|
|
159
|
+
// Mirror the removed inline mcp-result write. Write `roundId` as its OWN
|
|
160
|
+
// metadata field so recall can exclude the raw-tail round by roundId;
|
|
161
|
+
// `identityKey` stays tool+args (fetch dedup) and is a DIFFERENT key.
|
|
162
|
+
record: (round, options) => writeArtifact(rag, {
|
|
163
|
+
...meta,
|
|
164
|
+
artifactType: 'mcp-result',
|
|
165
|
+
task: stepName,
|
|
166
|
+
runId,
|
|
167
|
+
identityKey: round.meta?.[0]?.identityKey ?? round.roundId,
|
|
168
|
+
roundId: round.roundId,
|
|
169
|
+
// Monotonic per-write ordinal stamped by the handler. isBetterMcp
|
|
170
|
+
// tie-breaks on writeOrdinal FIRST (then createdAt); without it a
|
|
171
|
+
// later same-identityKey fetch cannot supersede a stale earlier one
|
|
172
|
+
// when createdAt ties (all mcp writes in a step share createdAt).
|
|
173
|
+
writeOrdinal: round.ordinal,
|
|
174
|
+
content: round.results
|
|
175
|
+
.map((r) => String(r.content ?? ''))
|
|
176
|
+
.join('\n'),
|
|
177
|
+
}, options),
|
|
178
|
+
recall: async (queryText, excludeRoundIds, options) => {
|
|
179
|
+
const rows = await runScopedRecall(rag, queryText, RECALL_K_MCP, runId, mcpBound, ['mcp-result'], options);
|
|
180
|
+
return (buildRecallBlock(rows.filter((r) => !excludeRoundIds.includes(String(r.metadata?.roundId))), RECALL_MAX_CHARS_MCP) ?? '');
|
|
181
|
+
},
|
|
182
|
+
}, { runId });
|
|
183
|
+
};
|
|
184
|
+
// Honor a CONSUMER-injected tool-loop context strategy on the controller
|
|
185
|
+
// path: `new SmartServer(cfg, { toolLoopContextStrategyFactory })` threads
|
|
186
|
+
// it onto `ctx.toolLoopContextStrategyFactory` (undefined when not injected).
|
|
187
|
+
// When the consumer supplied one it OVERRIDES the controller's RagRecall
|
|
188
|
+
// example default; otherwise RagRecall stands. We never silently drop an
|
|
189
|
+
// injected DI dependency.
|
|
190
|
+
const toolLoopContextStrategyFactory = ctx.toolLoopContextStrategyFactory ?? ragRecallFactory;
|
|
112
191
|
// The factory resolves the three role LLMs via makeRoleLlm, wraps them as
|
|
113
192
|
// subagent clients, validates the embedder requirement, and builds the
|
|
114
193
|
// handler. external-tool routing is decided PER-REQUEST inside the handler
|
|
115
194
|
// from `ctx.externalTools`, so we do NOT wire `isExternalTool` here.
|
|
116
195
|
const deps = {
|
|
117
196
|
makeRoleLlm: (role) => ctx.makeLlm(cfg.subagents[role]),
|
|
118
|
-
callMcp: (name, args) =>
|
|
197
|
+
callMcp: (name, args, signal) => auxCallMcp(name, args, signal),
|
|
119
198
|
backend: ctx.stepperKnowledgeBackend,
|
|
120
199
|
knowledgeRagFor: (sessionId) => ctx.knowledgeRagFor(sessionId),
|
|
121
200
|
embedder: ctx.embedder,
|
|
122
201
|
selectTools,
|
|
123
202
|
...(skillsRecall ? { skillsRecall } : {}),
|
|
203
|
+
toolLoopContextStrategyFactory,
|
|
204
|
+
stepExecutionControl: ctx.stepExecutionControl ?? new DefaultStepExecutionControl(),
|
|
205
|
+
runExecutionControl: ctx.runExecutionControl ?? new NoopRunExecutionControl(),
|
|
124
206
|
};
|
|
125
207
|
const { handler } = await new ControllerFactory().build(cfg, deps, this.plannerKind);
|
|
126
208
|
const builder = await ctx.createAgentBuilder();
|