@flutchai/flutch-sdk 0.4.1 → 0.6.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.cjs +90 -33
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -3
- package/dist/index.d.ts +6 -3
- package/dist/index.js +90 -33
- package/dist/index.js.map +1 -1
- package/package.json +47 -47
package/dist/index.d.cts
CHANGED
|
@@ -1049,6 +1049,8 @@ interface ModelByIdConfig {
|
|
|
1049
1049
|
baseURL?: string;
|
|
1050
1050
|
toolsConfig?: IAgentToolConfig[];
|
|
1051
1051
|
customTools?: DynamicStructuredTool[];
|
|
1052
|
+
mcpServers?: Record<string, any>[];
|
|
1053
|
+
mcpContext?: Record<string, any>;
|
|
1052
1054
|
}
|
|
1053
1055
|
type ModelConfigFetcher = (modelId: string) => Promise<ModelConfigWithToken>;
|
|
1054
1056
|
interface ModelConfigWithToken {
|
|
@@ -1273,7 +1275,7 @@ declare class McpToolFilter {
|
|
|
1273
1275
|
private readonly logger;
|
|
1274
1276
|
private readonly mcpConverter;
|
|
1275
1277
|
constructor(mcpRuntimeUrl?: string);
|
|
1276
|
-
getFilteredTools(toolsConfig?: IAgentToolConfig[]): Promise<StructuredTool[]>;
|
|
1278
|
+
getFilteredTools(toolsConfig?: IAgentToolConfig[], mcpServers?: Record<string, any>[], context?: Record<string, any>): Promise<StructuredTool[]>;
|
|
1277
1279
|
getAllTools(): Promise<StructuredTool[]>;
|
|
1278
1280
|
isHealthy(): Promise<boolean>;
|
|
1279
1281
|
getAvailableToolNames(): Promise<string[]>;
|
|
@@ -1285,10 +1287,10 @@ declare class McpRuntimeHttpClient implements McpRuntimeClient {
|
|
|
1285
1287
|
private readonly baseUrl;
|
|
1286
1288
|
constructor(mcpRuntimeUrl?: string);
|
|
1287
1289
|
getTools(): Promise<McpTool[]>;
|
|
1288
|
-
executeTool(name: string, args: any, context?: any): Promise<ToolExecutionResult>;
|
|
1290
|
+
executeTool(name: string, args: any, context?: any, mcpServers?: Record<string, any>[]): Promise<ToolExecutionResult>;
|
|
1289
1291
|
getToolStats(): Promise<any>;
|
|
1290
1292
|
isHealthy(): Promise<boolean>;
|
|
1291
|
-
executeToolWithEvents(toolCallId: string, toolName: string, enrichedArgs: Record<string, any>, executionContext: Record<string, any>, config?: RunnableConfig): Promise<{
|
|
1293
|
+
executeToolWithEvents(toolCallId: string, toolName: string, enrichedArgs: Record<string, any>, executionContext: Record<string, any>, config?: RunnableConfig, mcpServers?: Record<string, any>[]): Promise<{
|
|
1292
1294
|
content: string;
|
|
1293
1295
|
success: boolean;
|
|
1294
1296
|
rawResult?: any;
|
|
@@ -1326,6 +1328,7 @@ interface ExecuteToolWithAttachmentsParams {
|
|
|
1326
1328
|
properties?: Record<string, any>;
|
|
1327
1329
|
required?: string[];
|
|
1328
1330
|
};
|
|
1331
|
+
mcpServers?: Record<string, any>[];
|
|
1329
1332
|
}
|
|
1330
1333
|
interface ExecuteToolWithAttachmentsResult {
|
|
1331
1334
|
toolMessage: ToolMessage;
|
package/dist/index.d.ts
CHANGED
|
@@ -1049,6 +1049,8 @@ interface ModelByIdConfig {
|
|
|
1049
1049
|
baseURL?: string;
|
|
1050
1050
|
toolsConfig?: IAgentToolConfig[];
|
|
1051
1051
|
customTools?: DynamicStructuredTool[];
|
|
1052
|
+
mcpServers?: Record<string, any>[];
|
|
1053
|
+
mcpContext?: Record<string, any>;
|
|
1052
1054
|
}
|
|
1053
1055
|
type ModelConfigFetcher = (modelId: string) => Promise<ModelConfigWithToken>;
|
|
1054
1056
|
interface ModelConfigWithToken {
|
|
@@ -1273,7 +1275,7 @@ declare class McpToolFilter {
|
|
|
1273
1275
|
private readonly logger;
|
|
1274
1276
|
private readonly mcpConverter;
|
|
1275
1277
|
constructor(mcpRuntimeUrl?: string);
|
|
1276
|
-
getFilteredTools(toolsConfig?: IAgentToolConfig[]): Promise<StructuredTool[]>;
|
|
1278
|
+
getFilteredTools(toolsConfig?: IAgentToolConfig[], mcpServers?: Record<string, any>[], context?: Record<string, any>): Promise<StructuredTool[]>;
|
|
1277
1279
|
getAllTools(): Promise<StructuredTool[]>;
|
|
1278
1280
|
isHealthy(): Promise<boolean>;
|
|
1279
1281
|
getAvailableToolNames(): Promise<string[]>;
|
|
@@ -1285,10 +1287,10 @@ declare class McpRuntimeHttpClient implements McpRuntimeClient {
|
|
|
1285
1287
|
private readonly baseUrl;
|
|
1286
1288
|
constructor(mcpRuntimeUrl?: string);
|
|
1287
1289
|
getTools(): Promise<McpTool[]>;
|
|
1288
|
-
executeTool(name: string, args: any, context?: any): Promise<ToolExecutionResult>;
|
|
1290
|
+
executeTool(name: string, args: any, context?: any, mcpServers?: Record<string, any>[]): Promise<ToolExecutionResult>;
|
|
1289
1291
|
getToolStats(): Promise<any>;
|
|
1290
1292
|
isHealthy(): Promise<boolean>;
|
|
1291
|
-
executeToolWithEvents(toolCallId: string, toolName: string, enrichedArgs: Record<string, any>, executionContext: Record<string, any>, config?: RunnableConfig): Promise<{
|
|
1293
|
+
executeToolWithEvents(toolCallId: string, toolName: string, enrichedArgs: Record<string, any>, executionContext: Record<string, any>, config?: RunnableConfig, mcpServers?: Record<string, any>[]): Promise<{
|
|
1292
1294
|
content: string;
|
|
1293
1295
|
success: boolean;
|
|
1294
1296
|
rawResult?: any;
|
|
@@ -1326,6 +1328,7 @@ interface ExecuteToolWithAttachmentsParams {
|
|
|
1326
1328
|
properties?: Record<string, any>;
|
|
1327
1329
|
required?: string[];
|
|
1328
1330
|
};
|
|
1331
|
+
mcpServers?: Record<string, any>[];
|
|
1329
1332
|
}
|
|
1330
1333
|
interface ExecuteToolWithAttachmentsResult {
|
|
1331
1334
|
toolMessage: ToolMessage;
|
package/dist/index.js
CHANGED
|
@@ -329,8 +329,8 @@ var ENDPOINT_METADATA_KEY, UI_ENDPOINT_CLASS_METADATA_KEY, UI_ENDPOINT_METHOD_ME
|
|
|
329
329
|
var init_endpoint_decorators = __esm({
|
|
330
330
|
"src/agent-ui/endpoint.decorators.ts"() {
|
|
331
331
|
ENDPOINT_METADATA_KEY = "graph:endpoints";
|
|
332
|
-
UI_ENDPOINT_CLASS_METADATA_KEY = Symbol("ui_endpoint_class");
|
|
333
|
-
UI_ENDPOINT_METHOD_METADATA_KEY = Symbol("ui_endpoint_methods");
|
|
332
|
+
UI_ENDPOINT_CLASS_METADATA_KEY = /* @__PURE__ */ Symbol("ui_endpoint_class");
|
|
333
|
+
UI_ENDPOINT_METHOD_METADATA_KEY = /* @__PURE__ */ Symbol("ui_endpoint_methods");
|
|
334
334
|
}
|
|
335
335
|
});
|
|
336
336
|
var UIEndpointsDiscoveryService;
|
|
@@ -343,6 +343,9 @@ var init_ui_endpoints_discovery = __esm({
|
|
|
343
343
|
this.metadataScanner = metadataScanner;
|
|
344
344
|
this.endpointRegistry = endpointRegistry;
|
|
345
345
|
}
|
|
346
|
+
discoveryService;
|
|
347
|
+
metadataScanner;
|
|
348
|
+
endpointRegistry;
|
|
346
349
|
logger = new Logger(UIEndpointsDiscoveryService.name);
|
|
347
350
|
async onModuleInit() {
|
|
348
351
|
await this.discoverUIEndpoints();
|
|
@@ -419,6 +422,8 @@ var init_ui_dispatch_controller = __esm({
|
|
|
419
422
|
this.endpointRegistry = endpointRegistry;
|
|
420
423
|
this.builderRegistry = builderRegistry;
|
|
421
424
|
}
|
|
425
|
+
endpointRegistry;
|
|
426
|
+
builderRegistry;
|
|
422
427
|
logger = new Logger(UIDispatchController.name);
|
|
423
428
|
async dispatchUIEndpoint(dto) {
|
|
424
429
|
this.logger.debug(
|
|
@@ -693,8 +698,8 @@ function findCallbackMethod(target, handler) {
|
|
|
693
698
|
var CALLBACK_METADATA_KEY, CALLBACK_CLASS_METADATA_KEY;
|
|
694
699
|
var init_callback_decorators = __esm({
|
|
695
700
|
"src/callbacks/callback.decorators.ts"() {
|
|
696
|
-
CALLBACK_METADATA_KEY = Symbol("callbacks");
|
|
697
|
-
CALLBACK_CLASS_METADATA_KEY = Symbol("callback_class");
|
|
701
|
+
CALLBACK_METADATA_KEY = /* @__PURE__ */ Symbol("callbacks");
|
|
702
|
+
CALLBACK_CLASS_METADATA_KEY = /* @__PURE__ */ Symbol("callback_class");
|
|
698
703
|
}
|
|
699
704
|
});
|
|
700
705
|
|
|
@@ -1484,6 +1489,10 @@ var UniversalGraphService = class {
|
|
|
1484
1489
|
this.logger.error("GRAPH_ENGINE is not properly injected!");
|
|
1485
1490
|
}
|
|
1486
1491
|
}
|
|
1492
|
+
configService;
|
|
1493
|
+
builders;
|
|
1494
|
+
engine;
|
|
1495
|
+
endpointRegistry;
|
|
1487
1496
|
logger = new Logger(UniversalGraphService.name);
|
|
1488
1497
|
/**
|
|
1489
1498
|
* Returns graph types supported by the service
|
|
@@ -1997,6 +2006,8 @@ var GraphController = class {
|
|
|
1997
2006
|
this.graphService = graphService;
|
|
1998
2007
|
this.builderRegistry = builderRegistry;
|
|
1999
2008
|
}
|
|
2009
|
+
graphService;
|
|
2010
|
+
builderRegistry;
|
|
2000
2011
|
logger = new Logger(GraphController.name);
|
|
2001
2012
|
async healthCheck() {
|
|
2002
2013
|
try {
|
|
@@ -2383,6 +2394,7 @@ var CallbackStore = class {
|
|
|
2383
2394
|
this.redis = redis;
|
|
2384
2395
|
this.isProduction = process.env.NODE_ENV === "production";
|
|
2385
2396
|
}
|
|
2397
|
+
redis;
|
|
2386
2398
|
isProduction;
|
|
2387
2399
|
/**
|
|
2388
2400
|
* Issues a new callback token and persists its payload.
|
|
@@ -2589,6 +2601,7 @@ var IdempotencyManager = class {
|
|
|
2589
2601
|
constructor(redis) {
|
|
2590
2602
|
this.redis = redis;
|
|
2591
2603
|
}
|
|
2604
|
+
redis;
|
|
2592
2605
|
logger = new Logger(IdempotencyManager.name);
|
|
2593
2606
|
defaultConfig = {
|
|
2594
2607
|
ttlSeconds: 3600,
|
|
@@ -2839,6 +2852,14 @@ var SmartCallbackRouter = class {
|
|
|
2839
2852
|
this.idempotencyManager = idempotencyManager;
|
|
2840
2853
|
this.patchService = patchService;
|
|
2841
2854
|
}
|
|
2855
|
+
registry;
|
|
2856
|
+
store;
|
|
2857
|
+
acl;
|
|
2858
|
+
auditor;
|
|
2859
|
+
metrics;
|
|
2860
|
+
rateLimiter;
|
|
2861
|
+
idempotencyManager;
|
|
2862
|
+
patchService;
|
|
2842
2863
|
logger = new Logger(SmartCallbackRouter.name);
|
|
2843
2864
|
circuitBreakers = /* @__PURE__ */ new Map();
|
|
2844
2865
|
defaultConfig = {
|
|
@@ -3098,6 +3119,8 @@ var UniversalCallbackService = class {
|
|
|
3098
3119
|
this.store = store;
|
|
3099
3120
|
this.router = router;
|
|
3100
3121
|
}
|
|
3122
|
+
store;
|
|
3123
|
+
router;
|
|
3101
3124
|
async handle(record, user, metadata) {
|
|
3102
3125
|
try {
|
|
3103
3126
|
const result = await this.router.route(record, user, metadata);
|
|
@@ -3889,6 +3912,7 @@ var CallbackRateLimiter = class {
|
|
|
3889
3912
|
constructor(redis) {
|
|
3890
3913
|
this.redis = redis;
|
|
3891
3914
|
}
|
|
3915
|
+
redis;
|
|
3892
3916
|
logger = new Logger(CallbackRateLimiter.name);
|
|
3893
3917
|
defaultConfig = {
|
|
3894
3918
|
windowMs: 6e4,
|
|
@@ -4054,6 +4078,8 @@ var CallbackPatchService = class {
|
|
|
4054
4078
|
this.telegram = telegram;
|
|
4055
4079
|
this.web = web;
|
|
4056
4080
|
}
|
|
4081
|
+
telegram;
|
|
4082
|
+
web;
|
|
4057
4083
|
logger = new Logger(CallbackPatchService.name);
|
|
4058
4084
|
async apply(record, patch, context) {
|
|
4059
4085
|
if (!patch) return;
|
|
@@ -4114,6 +4140,8 @@ var CallbackTokenGuard = class {
|
|
|
4114
4140
|
this.store = store;
|
|
4115
4141
|
this.acl = acl;
|
|
4116
4142
|
}
|
|
4143
|
+
store;
|
|
4144
|
+
acl;
|
|
4117
4145
|
logger = new Logger(CallbackTokenGuard.name);
|
|
4118
4146
|
async canActivate(context) {
|
|
4119
4147
|
const request = context.switchToHttp().getRequest();
|
|
@@ -4171,6 +4199,7 @@ var CallbackController = class {
|
|
|
4171
4199
|
constructor(callbackService) {
|
|
4172
4200
|
this.callbackService = callbackService;
|
|
4173
4201
|
}
|
|
4202
|
+
callbackService;
|
|
4174
4203
|
async handleCallback(req) {
|
|
4175
4204
|
return this.callbackService.handle(req.callbackRecord, req.user);
|
|
4176
4205
|
}
|
|
@@ -4459,7 +4488,8 @@ async function executeToolWithAttachments(params) {
|
|
|
4459
4488
|
injectIntoArg = "data",
|
|
4460
4489
|
sourceAttachmentId,
|
|
4461
4490
|
threadId,
|
|
4462
|
-
toolSchema
|
|
4491
|
+
toolSchema,
|
|
4492
|
+
mcpServers
|
|
4463
4493
|
} = params;
|
|
4464
4494
|
const argsWithInjection = { ...enrichedArgs };
|
|
4465
4495
|
try {
|
|
@@ -4490,7 +4520,8 @@ async function executeToolWithAttachments(params) {
|
|
|
4490
4520
|
toolCall.name,
|
|
4491
4521
|
argsWithInjection,
|
|
4492
4522
|
executionContext,
|
|
4493
|
-
config
|
|
4523
|
+
config,
|
|
4524
|
+
mcpServers
|
|
4494
4525
|
);
|
|
4495
4526
|
try {
|
|
4496
4527
|
if (success && rawResult !== void 0 && content.length > threshold) {
|
|
@@ -4710,6 +4741,7 @@ var GraphEngineFactory = class {
|
|
|
4710
4741
|
constructor(langgraph) {
|
|
4711
4742
|
this.langgraph = langgraph;
|
|
4712
4743
|
}
|
|
4744
|
+
langgraph;
|
|
4713
4745
|
/**
|
|
4714
4746
|
* Get engine for the specified type
|
|
4715
4747
|
*/
|
|
@@ -5367,6 +5399,8 @@ var LangGraphEngine = class {
|
|
|
5367
5399
|
this.logger.error("EventProcessor is undefined/null!");
|
|
5368
5400
|
}
|
|
5369
5401
|
}
|
|
5402
|
+
eventProcessor;
|
|
5403
|
+
configService;
|
|
5370
5404
|
logger = new Logger(LangGraphEngine.name);
|
|
5371
5405
|
/**
|
|
5372
5406
|
* Deserialize input recursively
|
|
@@ -6343,6 +6377,7 @@ var McpToolFilter = class _McpToolFilter {
|
|
|
6343
6377
|
this.mcpRuntimeUrl = mcpRuntimeUrl;
|
|
6344
6378
|
this.mcpConverter = new McpConverter(this.mcpRuntimeUrl);
|
|
6345
6379
|
}
|
|
6380
|
+
mcpRuntimeUrl;
|
|
6346
6381
|
logger = new Logger(_McpToolFilter.name);
|
|
6347
6382
|
mcpConverter;
|
|
6348
6383
|
/**
|
|
@@ -6350,12 +6385,13 @@ var McpToolFilter = class _McpToolFilter {
|
|
|
6350
6385
|
* @param toolsConfig Array of tool configurations with dynamic config
|
|
6351
6386
|
* @returns Array of LangChain Tool instances with dynamic schemas
|
|
6352
6387
|
*/
|
|
6353
|
-
async getFilteredTools(toolsConfig = []) {
|
|
6388
|
+
async getFilteredTools(toolsConfig = [], mcpServers, context) {
|
|
6354
6389
|
this.logger.debug(
|
|
6355
6390
|
`[DEBUG] Getting filtered tools with dynamic schemas. Config: ${JSON.stringify(toolsConfig)}`
|
|
6356
6391
|
);
|
|
6357
6392
|
this.logger.debug(`[DEBUG] MCP Runtime URL: ${this.mcpRuntimeUrl}`);
|
|
6358
|
-
|
|
6393
|
+
const hasInlineServers = !!(mcpServers && mcpServers.length > 0);
|
|
6394
|
+
if (toolsConfig.length === 0 && !hasInlineServers) {
|
|
6359
6395
|
this.logger.debug("No tools configured, returning empty array");
|
|
6360
6396
|
return [];
|
|
6361
6397
|
}
|
|
@@ -6363,10 +6399,13 @@ var McpToolFilter = class _McpToolFilter {
|
|
|
6363
6399
|
this.logger.debug(
|
|
6364
6400
|
`[DEBUG] Making HTTP POST request to: ${this.mcpRuntimeUrl}/tools/schemas`
|
|
6365
6401
|
);
|
|
6366
|
-
|
|
6402
|
+
const requestBody = { tools: toolsConfig };
|
|
6403
|
+
if (hasInlineServers) requestBody.mcpServers = mcpServers;
|
|
6404
|
+
if (context) requestBody.context = context;
|
|
6405
|
+
this.logger.debug(`[DEBUG] Request body: ${JSON.stringify(requestBody)}`);
|
|
6367
6406
|
const response = await axios2.post(
|
|
6368
6407
|
`${this.mcpRuntimeUrl}/tools/schemas`,
|
|
6369
|
-
|
|
6408
|
+
requestBody,
|
|
6370
6409
|
{
|
|
6371
6410
|
timeout: 5e3,
|
|
6372
6411
|
headers: {
|
|
@@ -6383,14 +6422,14 @@ var McpToolFilter = class _McpToolFilter {
|
|
|
6383
6422
|
);
|
|
6384
6423
|
const mcpClient = {
|
|
6385
6424
|
getTools: async () => dynamicTools,
|
|
6386
|
-
executeTool: async (name, args,
|
|
6425
|
+
executeTool: async (name, args, context2) => {
|
|
6387
6426
|
this.logger.debug(`[DEBUG] Executing tool ${name} with args:`, args);
|
|
6388
6427
|
const response2 = await axios2.post(
|
|
6389
6428
|
`${this.mcpRuntimeUrl}/tools/execute`,
|
|
6390
6429
|
{
|
|
6391
6430
|
name,
|
|
6392
6431
|
arguments: args || {},
|
|
6393
|
-
context
|
|
6432
|
+
context: context2
|
|
6394
6433
|
}
|
|
6395
6434
|
);
|
|
6396
6435
|
return response2.data;
|
|
@@ -6529,7 +6568,7 @@ var McpRuntimeHttpClient = class {
|
|
|
6529
6568
|
/**
|
|
6530
6569
|
* Execute a tool by name with given arguments
|
|
6531
6570
|
*/
|
|
6532
|
-
async executeTool(name, args, context) {
|
|
6571
|
+
async executeTool(name, args, context, mcpServers) {
|
|
6533
6572
|
try {
|
|
6534
6573
|
this.logger.debug(`Executing tool: ${name} with args:`, args);
|
|
6535
6574
|
const payload = {
|
|
@@ -6539,6 +6578,9 @@ var McpRuntimeHttpClient = class {
|
|
|
6539
6578
|
if (context) {
|
|
6540
6579
|
payload.context = context;
|
|
6541
6580
|
}
|
|
6581
|
+
if (mcpServers && mcpServers.length > 0) {
|
|
6582
|
+
payload.mcpServers = mcpServers;
|
|
6583
|
+
}
|
|
6542
6584
|
const response = await this.httpClient.post("/tools/execute", payload);
|
|
6543
6585
|
this.logger.log(`Tool ${name} executed successfully`);
|
|
6544
6586
|
return response.data;
|
|
@@ -6589,7 +6631,7 @@ var McpRuntimeHttpClient = class {
|
|
|
6589
6631
|
* @param config - RunnableConfig with callbacks
|
|
6590
6632
|
* @returns Tool execution result with content
|
|
6591
6633
|
*/
|
|
6592
|
-
async executeToolWithEvents(toolCallId, toolName, enrichedArgs, executionContext, config) {
|
|
6634
|
+
async executeToolWithEvents(toolCallId, toolName, enrichedArgs, executionContext, config, mcpServers) {
|
|
6593
6635
|
const parsedConfig = parseCallbackConfigArg(config);
|
|
6594
6636
|
const callbackManager = CallbackManager.configure(parsedConfig.callbacks);
|
|
6595
6637
|
let runManager;
|
|
@@ -6611,7 +6653,8 @@ var McpRuntimeHttpClient = class {
|
|
|
6611
6653
|
const result = await this.executeTool(
|
|
6612
6654
|
toolName,
|
|
6613
6655
|
enrichedArgs,
|
|
6614
|
-
executionContext
|
|
6656
|
+
executionContext,
|
|
6657
|
+
mcpServers
|
|
6615
6658
|
);
|
|
6616
6659
|
const content = result.success ? JSON.stringify(result) : result.error || JSON.stringify(result);
|
|
6617
6660
|
await runManager?.handleToolEnd(content);
|
|
@@ -6775,6 +6818,8 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
6775
6818
|
this.apiKeyResolver = apiKeyResolver;
|
|
6776
6819
|
this.logger = logger2 || new Logger(_ModelInitializer.name);
|
|
6777
6820
|
}
|
|
6821
|
+
configFetcher;
|
|
6822
|
+
apiKeyResolver;
|
|
6778
6823
|
logger;
|
|
6779
6824
|
// Cache for model configurations to avoid repeated API calls
|
|
6780
6825
|
modelConfigCache = /* @__PURE__ */ new Map();
|
|
@@ -6820,13 +6865,17 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
6820
6865
|
* Example: "model123:0.7:4096" or "model123:0.7:4096:a1b2c3d4e5f6g7h8"
|
|
6821
6866
|
*/
|
|
6822
6867
|
generateModelCacheKey(config) {
|
|
6823
|
-
|
|
6868
|
+
const base = generateModelCacheKey(
|
|
6824
6869
|
config.modelId,
|
|
6825
6870
|
config.temperature,
|
|
6826
6871
|
config.maxTokens,
|
|
6827
6872
|
config.toolsConfig,
|
|
6828
6873
|
config.baseURL
|
|
6829
6874
|
);
|
|
6875
|
+
if (config.mcpServers && config.mcpServers.length > 0) {
|
|
6876
|
+
return `${base}:mcp:${JSON.stringify(config.mcpServers)}`;
|
|
6877
|
+
}
|
|
6878
|
+
return base;
|
|
6830
6879
|
}
|
|
6831
6880
|
// Chat model creators
|
|
6832
6881
|
chatModelCreators = {
|
|
@@ -7102,11 +7151,13 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
7102
7151
|
...model.metadata,
|
|
7103
7152
|
modelId: config.modelId
|
|
7104
7153
|
};
|
|
7105
|
-
if (config.toolsConfig || config.customTools) {
|
|
7154
|
+
if (config.toolsConfig || config.customTools || config.mcpServers && config.mcpServers.length > 0) {
|
|
7106
7155
|
const boundModel = await this.bindToolsToModel(
|
|
7107
7156
|
model,
|
|
7108
7157
|
config.toolsConfig,
|
|
7109
|
-
config.customTools
|
|
7158
|
+
config.customTools,
|
|
7159
|
+
config.mcpServers,
|
|
7160
|
+
config.mcpContext
|
|
7110
7161
|
);
|
|
7111
7162
|
this.modelInstanceCache.set(cacheKey, boundModel);
|
|
7112
7163
|
return boundModel;
|
|
@@ -7123,24 +7174,27 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
7123
7174
|
* - Runnable when tools are bound (model.bindTools returns Runnable)
|
|
7124
7175
|
* - BaseChatModel when no tools
|
|
7125
7176
|
*/
|
|
7126
|
-
async bindToolsToModel(model, toolsConfig, customTools) {
|
|
7177
|
+
async bindToolsToModel(model, toolsConfig, customTools, mcpServers, mcpContext) {
|
|
7127
7178
|
const allTools = [];
|
|
7128
|
-
|
|
7179
|
+
const enabledToolsConfig = (toolsConfig || []).filter(
|
|
7180
|
+
(tc) => tc.enabled !== false
|
|
7181
|
+
);
|
|
7182
|
+
const hasInlineServers = !!(mcpServers && mcpServers.length > 0);
|
|
7183
|
+
if (enabledToolsConfig.length > 0 || hasInlineServers) {
|
|
7129
7184
|
try {
|
|
7130
|
-
|
|
7131
|
-
(
|
|
7185
|
+
this.logger.debug(
|
|
7186
|
+
`Fetching ${enabledToolsConfig.length} tools (+${mcpServers?.length || 0} inline server(s)) with dynamic schemas from MCP Runtime`
|
|
7132
7187
|
);
|
|
7133
|
-
|
|
7134
|
-
|
|
7135
|
-
|
|
7136
|
-
|
|
7137
|
-
|
|
7138
|
-
|
|
7139
|
-
|
|
7140
|
-
|
|
7141
|
-
|
|
7142
|
-
|
|
7143
|
-
}
|
|
7188
|
+
const mcpToolFilter = new McpToolFilter();
|
|
7189
|
+
const mcpTools = await mcpToolFilter.getFilteredTools(
|
|
7190
|
+
enabledToolsConfig,
|
|
7191
|
+
mcpServers,
|
|
7192
|
+
mcpContext
|
|
7193
|
+
);
|
|
7194
|
+
this.logger.debug(
|
|
7195
|
+
`Successfully fetched ${mcpTools.length} tools with dynamic schemas from MCP Runtime`
|
|
7196
|
+
);
|
|
7197
|
+
allTools.push(...mcpTools);
|
|
7144
7198
|
} catch (error) {
|
|
7145
7199
|
this.logger.error(
|
|
7146
7200
|
`Failed to fetch tools from MCP Runtime: ${error instanceof Error ? error.message : String(error)}`
|
|
@@ -7659,6 +7713,7 @@ var StaticDiscovery = class {
|
|
|
7659
7713
|
constructor(services) {
|
|
7660
7714
|
this.services = services;
|
|
7661
7715
|
}
|
|
7716
|
+
services;
|
|
7662
7717
|
/**
|
|
7663
7718
|
* Get list of services by category
|
|
7664
7719
|
*/
|
|
@@ -7851,6 +7906,7 @@ var FileTokenStore = class {
|
|
|
7851
7906
|
constructor(filePath) {
|
|
7852
7907
|
this.filePath = filePath;
|
|
7853
7908
|
}
|
|
7909
|
+
filePath;
|
|
7854
7910
|
async get(provider) {
|
|
7855
7911
|
const data = this.readFile();
|
|
7856
7912
|
return data[provider] ?? null;
|
|
@@ -7891,6 +7947,7 @@ var MongoTokenStore = class {
|
|
|
7891
7947
|
this.db = db;
|
|
7892
7948
|
this.collectionName = collectionName ?? DEFAULT_COLLECTION;
|
|
7893
7949
|
}
|
|
7950
|
+
db;
|
|
7894
7951
|
collectionName;
|
|
7895
7952
|
initialized = false;
|
|
7896
7953
|
async get(provider) {
|