@juspay/neurolink 5.2.0 ā 6.0.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/CHANGELOG.md +82 -2
- package/dist/chat/client-utils.d.ts +3 -0
- package/dist/chat/client-utils.js +22 -5
- package/dist/chat/index.d.ts +4 -7
- package/dist/chat/index.js +0 -8
- package/dist/chat/session-storage.d.ts +2 -2
- package/dist/chat/session.d.ts +4 -3
- package/dist/chat/session.js +1 -1
- package/dist/chat/sse-handler.js +13 -21
- package/dist/chat/types.d.ts +3 -2
- package/dist/chat/websocket-chat-handler.d.ts +4 -3
- package/dist/chat/websocket-chat-handler.js +12 -12
- package/dist/cli/commands/config.d.ts +2 -2
- package/dist/cli/commands/mcp.d.ts +3 -2
- package/dist/cli/commands/mcp.js +39 -29
- package/dist/cli/commands/ollama.js +8 -4
- package/dist/cli/factories/command-factory.d.ts +2 -1
- package/dist/cli/factories/command-factory.js +6 -5
- package/dist/cli/index.js +22 -19
- package/dist/core/analytics.d.ts +3 -2
- package/dist/core/analytics.js +16 -7
- package/dist/core/base-provider.d.ts +35 -7
- package/dist/core/base-provider.js +57 -23
- package/dist/core/constants.d.ts +1 -0
- package/dist/core/constants.js +1 -0
- package/dist/core/defaults.d.ts +2 -1
- package/dist/core/evaluation.d.ts +4 -4
- package/dist/core/evaluation.js +17 -7
- package/dist/core/factory.d.ts +3 -2
- package/dist/core/service-registry.d.ts +4 -4
- package/dist/core/types.d.ts +11 -4
- package/dist/factories/compatibility-factory.d.ts +16 -1
- package/dist/factories/compatibility-factory.js +3 -1
- package/dist/factories/provider-factory.d.ts +5 -4
- package/dist/factories/provider-factory.js +15 -24
- package/dist/factories/provider-generate-factory.js +26 -20
- package/dist/lib/chat/client-utils.d.ts +3 -0
- package/dist/lib/chat/client-utils.js +22 -5
- package/dist/lib/chat/index.d.ts +4 -7
- package/dist/lib/chat/index.js +0 -8
- package/dist/lib/chat/session-storage.d.ts +2 -2
- package/dist/lib/chat/session.d.ts +4 -3
- package/dist/lib/chat/session.js +1 -1
- package/dist/lib/chat/sse-handler.js +13 -21
- package/dist/lib/chat/types.d.ts +3 -2
- package/dist/lib/chat/websocket-chat-handler.d.ts +4 -3
- package/dist/lib/chat/websocket-chat-handler.js +12 -12
- package/dist/lib/core/analytics.d.ts +3 -2
- package/dist/lib/core/analytics.js +16 -7
- package/dist/lib/core/base-provider.d.ts +35 -7
- package/dist/lib/core/base-provider.js +57 -23
- package/dist/lib/core/constants.d.ts +1 -0
- package/dist/lib/core/constants.js +1 -0
- package/dist/lib/core/defaults.d.ts +2 -1
- package/dist/lib/core/evaluation.d.ts +4 -4
- package/dist/lib/core/evaluation.js +17 -7
- package/dist/lib/core/factory.d.ts +3 -2
- package/dist/lib/core/service-registry.d.ts +4 -4
- package/dist/lib/core/types.d.ts +11 -4
- package/dist/lib/factories/compatibility-factory.d.ts +16 -1
- package/dist/lib/factories/compatibility-factory.js +3 -1
- package/dist/lib/factories/provider-factory.d.ts +5 -4
- package/dist/lib/factories/provider-factory.js +15 -24
- package/dist/lib/factories/provider-generate-factory.js +26 -20
- package/dist/lib/mcp/adapters/plugin-bridge.d.ts +5 -4
- package/dist/lib/mcp/adapters/plugin-bridge.js +13 -6
- package/dist/lib/mcp/client.d.ts +3 -1
- package/dist/lib/mcp/client.js +13 -10
- package/dist/lib/mcp/context-manager.d.ts +2 -1
- package/dist/lib/mcp/context-manager.js +8 -4
- package/dist/lib/mcp/contracts/mcp-contract.d.ts +15 -8
- package/dist/lib/mcp/core/plugin-manager.d.ts +3 -2
- package/dist/lib/mcp/core/plugin-manager.js +1 -1
- package/dist/lib/mcp/demo/plugin-demo.js +3 -1
- package/dist/lib/mcp/dynamic-chain-executor.d.ts +64 -40
- package/dist/lib/mcp/dynamic-chain-executor.js +3 -3
- package/dist/lib/mcp/dynamic-orchestrator.d.ts +14 -8
- package/dist/lib/mcp/ecosystem.d.ts +4 -4
- package/dist/lib/mcp/error-manager.d.ts +2 -2
- package/dist/lib/mcp/error-recovery.d.ts +4 -3
- package/dist/lib/mcp/external-client.d.ts +1 -1
- package/dist/lib/mcp/external-client.js +14 -10
- package/dist/lib/mcp/external-manager.d.ts +3 -3
- package/dist/lib/mcp/external-manager.js +9 -3
- package/dist/lib/mcp/factory.d.ts +7 -7
- package/dist/lib/mcp/function-calling.d.ts +14 -0
- package/dist/lib/mcp/function-calling.js +133 -34
- package/dist/lib/mcp/health-monitor.d.ts +2 -1
- package/dist/lib/mcp/health-monitor.js +16 -7
- package/dist/lib/mcp/index.d.ts +5 -5
- package/dist/lib/mcp/initialize-tools.d.ts +2 -1
- package/dist/lib/mcp/initialize-tools.js +10 -2
- package/dist/lib/mcp/manager.d.ts +2 -1
- package/dist/lib/mcp/neurolink-mcp-client.d.ts +1 -0
- package/dist/lib/mcp/neurolink-mcp-client.js +22 -6
- package/dist/lib/mcp/orchestrator.d.ts +13 -12
- package/dist/lib/mcp/orchestrator.js +10 -8
- package/dist/lib/mcp/plugin-manager.js +4 -2
- package/dist/lib/mcp/plugins/core/filesystem-mcp.d.ts +3 -2
- package/dist/lib/mcp/plugins/core/filesystem-mcp.js +5 -2
- package/dist/lib/mcp/plugins/filesystem-mcp.d.ts +2 -1
- package/dist/lib/mcp/registry.d.ts +2 -1
- package/dist/lib/mcp/registry.js +2 -1
- package/dist/lib/mcp/security-manager.d.ts +4 -2
- package/dist/lib/mcp/servers/agent/direct-tools-server.js +18 -6
- package/dist/lib/mcp/servers/ai-providers/ai-analysis-tools.d.ts +1 -16
- package/dist/lib/mcp/servers/ai-providers/ai-analysis-tools.js +21 -17
- package/dist/lib/mcp/servers/ai-providers/ai-core-server.d.ts +2 -2
- package/dist/lib/mcp/servers/ai-providers/ai-core-server.js +15 -133
- package/dist/lib/mcp/servers/ai-providers/ai-workflow-tools.d.ts +1 -97
- package/dist/lib/mcp/servers/ai-providers/ai-workflow-tools.js +18 -18
- package/dist/lib/mcp/session-manager.d.ts +4 -3
- package/dist/lib/mcp/session-persistence.js +5 -2
- package/dist/lib/mcp/tool-integration.d.ts +3 -2
- package/dist/lib/mcp/tool-integration.js +3 -1
- package/dist/lib/mcp/tool-registry.d.ts +18 -1
- package/dist/lib/mcp/tool-registry.js +11 -8
- package/dist/lib/mcp/transport-manager.d.ts +2 -1
- package/dist/lib/mcp/transport-manager.js +5 -1
- package/dist/lib/mcp/unified-mcp.d.ts +5 -5
- package/dist/lib/mcp/unified-registry.d.ts +18 -2
- package/dist/lib/mcp/unified-registry.js +52 -3
- package/dist/lib/neurolink.d.ts +2 -2
- package/dist/lib/neurolink.js +40 -15
- package/dist/lib/providers/amazon-bedrock.d.ts +1 -1
- package/dist/lib/providers/amazon-bedrock.js +8 -7
- package/dist/lib/providers/analytics-helper.d.ts +8 -23
- package/dist/lib/providers/analytics-helper.js +95 -33
- package/dist/lib/providers/anthropic-baseprovider.d.ts +3 -3
- package/dist/lib/providers/anthropic-baseprovider.js +6 -5
- package/dist/lib/providers/anthropic.d.ts +2 -2
- package/dist/lib/providers/anthropic.js +11 -4
- package/dist/lib/providers/azure-openai.d.ts +5 -4
- package/dist/lib/providers/azure-openai.js +10 -4
- package/dist/lib/providers/function-calling-provider.d.ts +66 -4
- package/dist/lib/providers/function-calling-provider.js +209 -10
- package/dist/lib/providers/google-ai-studio.d.ts +2 -2
- package/dist/lib/providers/google-ai-studio.js +9 -3
- package/dist/lib/providers/google-vertex.d.ts +2 -2
- package/dist/lib/providers/google-vertex.js +18 -12
- package/dist/lib/providers/huggingFace.d.ts +1 -1
- package/dist/lib/providers/huggingFace.js +8 -4
- package/dist/lib/providers/mcp-provider.d.ts +3 -3
- package/dist/lib/providers/mcp-provider.js +20 -5
- package/dist/lib/providers/mistral.d.ts +34 -27
- package/dist/lib/providers/mistral.js +115 -107
- package/dist/lib/providers/ollama.d.ts +2 -1
- package/dist/lib/providers/ollama.js +43 -3
- package/dist/lib/providers/openAI.d.ts +1 -1
- package/dist/lib/providers/openAI.js +8 -4
- package/dist/lib/proxy/proxy-fetch.js +3 -2
- package/dist/lib/sdk/tool-extension.d.ts +12 -12
- package/dist/lib/sdk/tool-extension.js +2 -1
- package/dist/lib/sdk/tool-registration.d.ts +16 -12
- package/dist/lib/sdk/tool-registration.js +3 -2
- package/dist/lib/services/streaming/streaming-manager.js +11 -10
- package/dist/lib/services/types.d.ts +5 -4
- package/dist/lib/services/websocket/websocket-server.d.ts +1 -1
- package/dist/lib/services/websocket/websocket-server.js +13 -12
- package/dist/lib/telemetry/telemetry-service.js +9 -8
- package/dist/lib/types/cli.d.ts +247 -0
- package/dist/lib/types/cli.js +22 -0
- package/dist/lib/types/common.d.ts +76 -0
- package/dist/lib/types/common.js +52 -0
- package/dist/lib/types/generate-types.d.ts +6 -6
- package/dist/lib/types/index.d.ts +12 -0
- package/dist/lib/types/index.js +12 -0
- package/dist/lib/types/mcp-types.d.ts +7 -7
- package/dist/lib/types/providers.d.ts +158 -0
- package/dist/lib/types/providers.js +23 -0
- package/dist/lib/types/stream-types.d.ts +4 -3
- package/dist/lib/types/tools.d.ts +154 -0
- package/dist/lib/types/tools.js +24 -0
- package/dist/lib/utils/logger.d.ts +5 -5
- package/dist/lib/utils/provider-validation.d.ts +2 -1
- package/dist/mcp/adapters/plugin-bridge.d.ts +5 -4
- package/dist/mcp/adapters/plugin-bridge.js +13 -6
- package/dist/mcp/client.d.ts +3 -1
- package/dist/mcp/client.js +13 -10
- package/dist/mcp/context-manager.d.ts +2 -1
- package/dist/mcp/context-manager.js +8 -4
- package/dist/mcp/contracts/mcp-contract.d.ts +15 -8
- package/dist/mcp/core/plugin-manager.d.ts +3 -2
- package/dist/mcp/core/plugin-manager.js +1 -1
- package/dist/mcp/demo/plugin-demo.js +3 -1
- package/dist/mcp/dynamic-chain-executor.d.ts +64 -40
- package/dist/mcp/dynamic-chain-executor.js +3 -3
- package/dist/mcp/dynamic-orchestrator.d.ts +14 -8
- package/dist/mcp/dynamic-orchestrator.js +1 -1
- package/dist/mcp/ecosystem.d.ts +4 -4
- package/dist/mcp/error-manager.d.ts +2 -2
- package/dist/mcp/error-recovery.d.ts +4 -3
- package/dist/mcp/external-client.d.ts +1 -1
- package/dist/mcp/external-client.js +14 -10
- package/dist/mcp/external-manager.d.ts +3 -3
- package/dist/mcp/external-manager.js +9 -3
- package/dist/mcp/factory.d.ts +7 -7
- package/dist/mcp/function-calling.d.ts +14 -0
- package/dist/mcp/function-calling.js +133 -34
- package/dist/mcp/health-monitor.d.ts +2 -1
- package/dist/mcp/health-monitor.js +16 -7
- package/dist/mcp/index.d.ts +5 -5
- package/dist/mcp/initialize-tools.d.ts +2 -1
- package/dist/mcp/initialize-tools.js +10 -2
- package/dist/mcp/manager.d.ts +2 -1
- package/dist/mcp/neurolink-mcp-client.d.ts +1 -0
- package/dist/mcp/neurolink-mcp-client.js +22 -6
- package/dist/mcp/orchestrator.d.ts +13 -12
- package/dist/mcp/orchestrator.js +10 -8
- package/dist/mcp/plugin-manager.js +4 -2
- package/dist/mcp/plugins/core/filesystem-mcp.d.ts +3 -2
- package/dist/mcp/plugins/core/filesystem-mcp.js +5 -2
- package/dist/mcp/plugins/filesystem-mcp.d.ts +2 -1
- package/dist/mcp/registry.d.ts +2 -1
- package/dist/mcp/registry.js +2 -1
- package/dist/mcp/security-manager.d.ts +4 -2
- package/dist/mcp/servers/agent/direct-tools-server.js +19 -6
- package/dist/mcp/servers/ai-providers/ai-analysis-tools.d.ts +1 -16
- package/dist/mcp/servers/ai-providers/ai-analysis-tools.js +21 -17
- package/dist/mcp/servers/ai-providers/ai-core-server.d.ts +2 -2
- package/dist/mcp/servers/ai-providers/ai-core-server.js +15 -132
- package/dist/mcp/servers/ai-providers/ai-workflow-tools.d.ts +1 -97
- package/dist/mcp/servers/ai-providers/ai-workflow-tools.js +18 -18
- package/dist/mcp/session-manager.d.ts +4 -3
- package/dist/mcp/session-persistence.js +5 -2
- package/dist/mcp/tool-integration.d.ts +3 -2
- package/dist/mcp/tool-integration.js +3 -1
- package/dist/mcp/tool-registry.d.ts +18 -1
- package/dist/mcp/tool-registry.js +11 -8
- package/dist/mcp/transport-manager.d.ts +2 -1
- package/dist/mcp/transport-manager.js +5 -1
- package/dist/mcp/unified-mcp.d.ts +5 -5
- package/dist/mcp/unified-registry.d.ts +18 -2
- package/dist/mcp/unified-registry.js +52 -3
- package/dist/neurolink.d.ts +2 -2
- package/dist/neurolink.js +40 -15
- package/dist/providers/amazon-bedrock.d.ts +1 -1
- package/dist/providers/amazon-bedrock.js +8 -7
- package/dist/providers/analytics-helper.d.ts +8 -23
- package/dist/providers/analytics-helper.js +95 -33
- package/dist/providers/anthropic-baseprovider.d.ts +3 -3
- package/dist/providers/anthropic-baseprovider.js +6 -5
- package/dist/providers/anthropic.d.ts +2 -2
- package/dist/providers/anthropic.js +11 -4
- package/dist/providers/azure-openai.d.ts +5 -4
- package/dist/providers/azure-openai.js +10 -4
- package/dist/providers/function-calling-provider.d.ts +66 -4
- package/dist/providers/function-calling-provider.js +209 -10
- package/dist/providers/google-ai-studio.d.ts +2 -2
- package/dist/providers/google-ai-studio.js +9 -3
- package/dist/providers/google-vertex.d.ts +2 -2
- package/dist/providers/google-vertex.js +18 -12
- package/dist/providers/huggingFace.d.ts +1 -1
- package/dist/providers/huggingFace.js +8 -4
- package/dist/providers/mcp-provider.d.ts +3 -3
- package/dist/providers/mcp-provider.js +20 -5
- package/dist/providers/mistral.d.ts +34 -27
- package/dist/providers/mistral.js +116 -108
- package/dist/providers/ollama.d.ts +2 -1
- package/dist/providers/ollama.js +43 -3
- package/dist/providers/openAI.d.ts +1 -1
- package/dist/providers/openAI.js +8 -4
- package/dist/proxy/proxy-fetch.js +3 -2
- package/dist/sdk/tool-extension.d.ts +12 -12
- package/dist/sdk/tool-extension.js +2 -1
- package/dist/sdk/tool-registration.d.ts +16 -12
- package/dist/sdk/tool-registration.js +3 -2
- package/dist/services/streaming/streaming-manager.js +11 -10
- package/dist/services/types.d.ts +5 -4
- package/dist/services/websocket/websocket-server.d.ts +1 -1
- package/dist/services/websocket/websocket-server.js +14 -12
- package/dist/telemetry/telemetry-service.js +9 -8
- package/dist/types/cli.d.ts +247 -0
- package/dist/types/cli.js +22 -0
- package/dist/types/common.d.ts +76 -0
- package/dist/types/common.js +52 -0
- package/dist/types/generate-types.d.ts +6 -6
- package/dist/types/index.d.ts +12 -0
- package/dist/types/index.js +12 -0
- package/dist/types/mcp-types.d.ts +7 -7
- package/dist/types/providers.d.ts +158 -0
- package/dist/types/providers.js +23 -0
- package/dist/types/stream-types.d.ts +4 -3
- package/dist/types/tools.d.ts +154 -0
- package/dist/types/tools.js +25 -0
- package/dist/utils/logger.d.ts +5 -5
- package/dist/utils/provider-validation.d.ts +2 -1
- package/package.json +12 -10
|
@@ -99,7 +99,7 @@ const debugAIOutputSchema = z.object({
|
|
|
99
99
|
/**
|
|
100
100
|
* Generate test cases for code functions
|
|
101
101
|
*/
|
|
102
|
-
|
|
102
|
+
const generateTestCasesTool = {
|
|
103
103
|
name: "generate-test-cases",
|
|
104
104
|
description: "Generate comprehensive test cases for code functions with various test types and frameworks",
|
|
105
105
|
category: "ai-workflow",
|
|
@@ -203,7 +203,7 @@ Generate 3-5 comprehensive test cases covering the requested types.`;
|
|
|
203
203
|
/**
|
|
204
204
|
* Refactor code for improved quality
|
|
205
205
|
*/
|
|
206
|
-
|
|
206
|
+
const refactorCodeTool = {
|
|
207
207
|
name: "refactor-code",
|
|
208
208
|
description: "AI-powered code refactoring for improved readability, performance, and maintainability",
|
|
209
209
|
category: "ai-workflow",
|
|
@@ -316,7 +316,7 @@ Focus on real, actionable improvements based on the specified objectives.`;
|
|
|
316
316
|
/**
|
|
317
317
|
* Generate documentation from code
|
|
318
318
|
*/
|
|
319
|
-
|
|
319
|
+
const generateDocumentationTool = {
|
|
320
320
|
name: "generate-documentation",
|
|
321
321
|
description: "Automatically generate comprehensive documentation from code",
|
|
322
322
|
category: "ai-workflow",
|
|
@@ -427,7 +427,7 @@ Focus on creating accurate, useful documentation that explains the code's purpos
|
|
|
427
427
|
/**
|
|
428
428
|
* Debug AI-generated output
|
|
429
429
|
*/
|
|
430
|
-
|
|
430
|
+
const debugAIOutputTool = {
|
|
431
431
|
name: "debug-ai-output",
|
|
432
432
|
description: "Analyze and debug AI-generated output to identify issues and suggest improvements",
|
|
433
433
|
category: "ai-workflow",
|
|
@@ -566,17 +566,17 @@ function simulateRefactoring(code, objectives, styleGuide) {
|
|
|
566
566
|
}
|
|
567
567
|
return refactored;
|
|
568
568
|
}
|
|
569
|
-
//
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
];
|
|
576
|
-
//
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
};
|
|
569
|
+
// REMOVED: Tool exports disabled to prevent provider conflicts
|
|
570
|
+
// const aiWorkflowTools = [
|
|
571
|
+
// generateTestCasesTool,
|
|
572
|
+
// refactorCodeTool,
|
|
573
|
+
// generateDocumentationTool,
|
|
574
|
+
// debugAIOutputTool,
|
|
575
|
+
// ];
|
|
576
|
+
// REMOVED: Schema exports disabled
|
|
577
|
+
// const workflowToolSchemas = {
|
|
578
|
+
// "generate-test-cases": generateTestCasesSchema,
|
|
579
|
+
// "refactor-code": refactorCodeSchema,
|
|
580
|
+
// "generate-documentation": generateDocumentationSchema,
|
|
581
|
+
// "debug-ai-output": debugAIOutputSchema,
|
|
582
|
+
// };
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Enables continuous tool calling with persistent state across executions
|
|
4
4
|
* Based on patterns from Cline's session management implementation
|
|
5
5
|
*/
|
|
6
|
+
import type { Unknown } from "../types/common.js";
|
|
6
7
|
import type { NeuroLinkExecutionContext, ToolResult } from "./factory.js";
|
|
7
8
|
import { type PersistenceOptions } from "./session-persistence.js";
|
|
8
9
|
/**
|
|
@@ -12,7 +13,7 @@ export interface OrchestratorSession {
|
|
|
12
13
|
id: string;
|
|
13
14
|
context: NeuroLinkExecutionContext;
|
|
14
15
|
toolHistory: ToolResult[];
|
|
15
|
-
state: Map<string,
|
|
16
|
+
state: Map<string, Unknown>;
|
|
16
17
|
metadata: {
|
|
17
18
|
userAgent?: string;
|
|
18
19
|
origin?: string;
|
|
@@ -95,7 +96,7 @@ export declare class SessionManager {
|
|
|
95
96
|
* @param value State value
|
|
96
97
|
* @returns Updated session or null if not found
|
|
97
98
|
*/
|
|
98
|
-
setSessionState(sessionId: string, key: string, value:
|
|
99
|
+
setSessionState(sessionId: string, key: string, value: Unknown): OrchestratorSession | null;
|
|
99
100
|
/**
|
|
100
101
|
* Get session state value
|
|
101
102
|
*
|
|
@@ -103,7 +104,7 @@ export declare class SessionManager {
|
|
|
103
104
|
* @param key State key
|
|
104
105
|
* @returns State value or undefined
|
|
105
106
|
*/
|
|
106
|
-
getSessionState(sessionId: string, key: string):
|
|
107
|
+
getSessionState(sessionId: string, key: string): Unknown;
|
|
107
108
|
/**
|
|
108
109
|
* Remove a session
|
|
109
110
|
*
|
|
@@ -91,8 +91,11 @@ export class SessionPersistence {
|
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
// Convert state array back to Map
|
|
94
|
-
const
|
|
95
|
-
session
|
|
94
|
+
const serializedSession = fileData.session;
|
|
95
|
+
const session = {
|
|
96
|
+
...serializedSession,
|
|
97
|
+
state: new Map(serializedSession.state),
|
|
98
|
+
};
|
|
96
99
|
return session;
|
|
97
100
|
}
|
|
98
101
|
catch (error) {
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* MCP Tool Integration Layer
|
|
3
3
|
* Connects MCP tools to NeuroLink AI providers following Lighthouse patterns
|
|
4
4
|
*/
|
|
5
|
+
import type { Unknown } from "../types/common.js";
|
|
5
6
|
import type { NeuroLinkExecutionContext, ToolResult } from "./factory.js";
|
|
6
7
|
/**
|
|
7
8
|
* Tool Integration System
|
|
@@ -31,7 +32,7 @@ export declare class MCPToolIntegration {
|
|
|
31
32
|
/**
|
|
32
33
|
* Execute a tool by name
|
|
33
34
|
*/
|
|
34
|
-
executeTool(toolName: string, params:
|
|
35
|
+
executeTool(toolName: string, params: Unknown, serverId?: string): Promise<ToolResult>;
|
|
35
36
|
/**
|
|
36
37
|
* Enhance AI prompt with tool context
|
|
37
38
|
*/
|
|
@@ -41,7 +42,7 @@ export declare class MCPToolIntegration {
|
|
|
41
42
|
*/
|
|
42
43
|
analyzeForToolUsage(aiResponse: string): Array<{
|
|
43
44
|
toolName: string;
|
|
44
|
-
params:
|
|
45
|
+
params: Unknown;
|
|
45
46
|
confidence: number;
|
|
46
47
|
}>;
|
|
47
48
|
/**
|
|
@@ -54,7 +54,9 @@ export class MCPToolIntegration {
|
|
|
54
54
|
async initializeTools() {
|
|
55
55
|
const servers = await mcpConfig.getServers();
|
|
56
56
|
for (const server of servers) {
|
|
57
|
-
await this.registry.registerServer(server.id ||
|
|
57
|
+
await this.registry.registerServer(server.id ||
|
|
58
|
+
server.name ||
|
|
59
|
+
"unknown", server);
|
|
58
60
|
}
|
|
59
61
|
const tools = await this.registry.listTools();
|
|
60
62
|
logger.debug("[Tool Integration] Initialized with servers:", {
|
|
@@ -5,6 +5,23 @@
|
|
|
5
5
|
import type { ExecutionContext, ToolInfo } from "./contracts/mcpContract.js";
|
|
6
6
|
import type { ToolResult } from "./factory.js";
|
|
7
7
|
import { MCPRegistry } from "./registry.js";
|
|
8
|
+
interface ToolImplementation {
|
|
9
|
+
execute: (params: unknown, context?: ExecutionContext) => Promise<unknown> | unknown;
|
|
10
|
+
description?: string;
|
|
11
|
+
inputSchema?: unknown;
|
|
12
|
+
outputSchema?: unknown;
|
|
13
|
+
category?: string;
|
|
14
|
+
permissions?: string[];
|
|
15
|
+
}
|
|
16
|
+
interface ServerRegistration {
|
|
17
|
+
id?: string;
|
|
18
|
+
serverId?: string;
|
|
19
|
+
description?: string;
|
|
20
|
+
title?: string;
|
|
21
|
+
category?: string;
|
|
22
|
+
tools?: Record<string, ToolImplementation>;
|
|
23
|
+
configuration?: Record<string, unknown>;
|
|
24
|
+
}
|
|
8
25
|
export type ToolExecutionResult = ToolResult;
|
|
9
26
|
/**
|
|
10
27
|
* Tool execution options
|
|
@@ -25,7 +42,7 @@ export declare class MCPToolRegistry extends MCPRegistry {
|
|
|
25
42
|
/**
|
|
26
43
|
* Register a server with its tools (updated signature)
|
|
27
44
|
*/
|
|
28
|
-
registerServer(serverOrId: string |
|
|
45
|
+
registerServer(serverOrId: string | ServerRegistration, serverConfig?: unknown, context?: ExecutionContext): Promise<void>;
|
|
29
46
|
/**
|
|
30
47
|
* Execute a tool with enhanced context
|
|
31
48
|
*/
|
|
@@ -23,7 +23,8 @@ export class MCPToolRegistry extends MCPRegistry {
|
|
|
23
23
|
metadata: {
|
|
24
24
|
name: serverId,
|
|
25
25
|
description: typeof serverConfig === "object" && serverConfig
|
|
26
|
-
? serverConfig.description ||
|
|
26
|
+
? serverConfig.description ||
|
|
27
|
+
"No description"
|
|
27
28
|
: "No description",
|
|
28
29
|
},
|
|
29
30
|
tools: typeof serverConfig === "object" && serverConfig
|
|
@@ -37,16 +38,17 @@ export class MCPToolRegistry extends MCPRegistry {
|
|
|
37
38
|
else {
|
|
38
39
|
// New behavior: register server object
|
|
39
40
|
const server = serverOrId;
|
|
40
|
-
serverId = server.id || server.serverId || "unknown-server";
|
|
41
|
+
serverId = String(server.id || server.serverId || "unknown-server");
|
|
41
42
|
registryLogger.info(`Registering server object: ${serverId}`);
|
|
42
43
|
plugin = {
|
|
43
44
|
metadata: {
|
|
44
45
|
name: serverId,
|
|
45
|
-
description: server.description || server.title || "No description",
|
|
46
|
-
category: server.category,
|
|
46
|
+
description: String(server.description || server.title || "No description"),
|
|
47
|
+
category: String(server.category || ""),
|
|
47
48
|
},
|
|
48
49
|
tools: server.tools || {},
|
|
49
|
-
configuration: server.configuration ||
|
|
50
|
+
configuration: server.configuration ||
|
|
51
|
+
{},
|
|
50
52
|
};
|
|
51
53
|
}
|
|
52
54
|
// Call the parent register method
|
|
@@ -112,14 +114,15 @@ export class MCPToolRegistry extends MCPRegistry {
|
|
|
112
114
|
registryLogger.debug(`Executing tool '${toolName}' with args:`, args);
|
|
113
115
|
const toolResult = await toolImpl.execute(args, execContext);
|
|
114
116
|
// Add metadata to the tool result (don't double-wrap)
|
|
117
|
+
const toolResultObj = toolResult;
|
|
115
118
|
const result = {
|
|
116
|
-
...
|
|
119
|
+
...toolResultObj,
|
|
117
120
|
usage: {
|
|
118
|
-
...
|
|
121
|
+
...(toolResultObj.usage || {}),
|
|
119
122
|
executionTime: Date.now() - startTime,
|
|
120
123
|
},
|
|
121
124
|
metadata: {
|
|
122
|
-
...
|
|
125
|
+
...(toolResultObj.metadata || {}),
|
|
123
126
|
toolName,
|
|
124
127
|
serverId: tool.serverId,
|
|
125
128
|
sessionId: execContext.sessionId,
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Supports stdio, SSE, and HTTP transports with reconnection logic
|
|
4
4
|
*/
|
|
5
5
|
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
6
|
+
import type { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
|
|
6
7
|
import { z } from "zod";
|
|
7
8
|
import { ErrorManager } from "./error-manager.js";
|
|
8
9
|
export declare const TransportConfigSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
@@ -96,7 +97,7 @@ export declare class TransportManager {
|
|
|
96
97
|
/**
|
|
97
98
|
* Create transport based on configuration
|
|
98
99
|
*/
|
|
99
|
-
createTransport(config: TransportConfig): Promise<
|
|
100
|
+
createTransport(config: TransportConfig): Promise<Transport>;
|
|
100
101
|
/**
|
|
101
102
|
* Create stdio transport
|
|
102
103
|
*/
|
|
@@ -160,7 +160,11 @@ export class TransportManager {
|
|
|
160
160
|
async createHTTPTransport(config) {
|
|
161
161
|
// Dynamically import HTTP transport
|
|
162
162
|
const httpModule = await import("@modelcontextprotocol/sdk/client/streamableHttp.js");
|
|
163
|
-
const HTTPClientTransport = httpModule.default ||
|
|
163
|
+
const HTTPClientTransport = httpModule.default ||
|
|
164
|
+
httpModule.HTTPClientTransport;
|
|
165
|
+
if (!HTTPClientTransport || typeof HTTPClientTransport !== "function") {
|
|
166
|
+
throw new Error("HTTPClientTransport constructor not found");
|
|
167
|
+
}
|
|
164
168
|
return new HTTPClientTransport(new URL(config.url), {
|
|
165
169
|
requestInit: {
|
|
166
170
|
headers: config.headers,
|
|
@@ -31,7 +31,7 @@ export interface UnifiedMCPStatus {
|
|
|
31
31
|
tools: number;
|
|
32
32
|
};
|
|
33
33
|
totalTools: number;
|
|
34
|
-
registryStats:
|
|
34
|
+
registryStats: unknown;
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
37
|
* Unified MCP System
|
|
@@ -59,11 +59,11 @@ export declare class UnifiedMCPSystem {
|
|
|
59
59
|
/**
|
|
60
60
|
* Execute a tool from any registered server
|
|
61
61
|
*/
|
|
62
|
-
executeTool(toolName: string, params:
|
|
62
|
+
executeTool(toolName: string, params: unknown, context: NeuroLinkExecutionContext): Promise<ToolResult>;
|
|
63
63
|
/**
|
|
64
64
|
* List all available tools
|
|
65
65
|
*/
|
|
66
|
-
listTools(criteria?:
|
|
66
|
+
listTools(criteria?: unknown): Promise<import("./tool-registry.js").ToolInfo[]>;
|
|
67
67
|
/**
|
|
68
68
|
* Get tool information
|
|
69
69
|
*/
|
|
@@ -113,11 +113,11 @@ export declare function getMCPSystem(): UnifiedMCPSystem;
|
|
|
113
113
|
/**
|
|
114
114
|
* Execute a tool using the default system
|
|
115
115
|
*/
|
|
116
|
-
export declare function executeMCPTool(toolName: string, params:
|
|
116
|
+
export declare function executeMCPTool(toolName: string, params: unknown, context: NeuroLinkExecutionContext): Promise<ToolResult>;
|
|
117
117
|
/**
|
|
118
118
|
* List all available MCP tools
|
|
119
119
|
*/
|
|
120
|
-
export declare function listMCPTools(criteria?:
|
|
120
|
+
export declare function listMCPTools(criteria?: unknown): Promise<import("./tool-registry.js").ToolInfo[]>;
|
|
121
121
|
/**
|
|
122
122
|
* Get MCP tool information
|
|
123
123
|
*/
|
|
@@ -2,7 +2,17 @@
|
|
|
2
2
|
* Unified MCP Registry - Combines Multiple Registration Sources
|
|
3
3
|
*/
|
|
4
4
|
import type { DiscoveredMCP, ExecutionContext } from "./contracts/mcp-contract.js";
|
|
5
|
+
import type { JsonValue } from "../types/common.js";
|
|
5
6
|
import type { DiscoveryOptions } from "./auto-discovery.js";
|
|
7
|
+
interface MCPServerConfig {
|
|
8
|
+
name: string;
|
|
9
|
+
id?: string;
|
|
10
|
+
command: string;
|
|
11
|
+
args?: string[];
|
|
12
|
+
env?: Record<string, string>;
|
|
13
|
+
transport?: string;
|
|
14
|
+
[key: string]: JsonValue | undefined;
|
|
15
|
+
}
|
|
6
16
|
import { MCPToolRegistry, type ToolInfo } from "./tool-registry.js";
|
|
7
17
|
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
8
18
|
import { ErrorManager } from "./error-manager.js";
|
|
@@ -53,7 +63,7 @@ export declare class UnifiedMCPRegistry extends MCPToolRegistry {
|
|
|
53
63
|
/**
|
|
54
64
|
* Get manual servers
|
|
55
65
|
*/
|
|
56
|
-
getManualServers(): Map<string,
|
|
66
|
+
getManualServers(): Map<string, MCPServerConfig>;
|
|
57
67
|
/**
|
|
58
68
|
* List all tools from all registered plugins
|
|
59
69
|
*/
|
|
@@ -73,7 +83,7 @@ export declare class UnifiedMCPRegistry extends MCPToolRegistry {
|
|
|
73
83
|
/**
|
|
74
84
|
* Register a manual server
|
|
75
85
|
*/
|
|
76
|
-
registerManualServer(id: string, server:
|
|
86
|
+
registerManualServer(id: string, server: MCPServerConfig): void;
|
|
77
87
|
/**
|
|
78
88
|
* Get registry statistics (override parent method)
|
|
79
89
|
*/
|
|
@@ -142,8 +152,14 @@ export declare class UnifiedMCPRegistry extends MCPToolRegistry {
|
|
|
142
152
|
* Clear all registries and close active connections asynchronously
|
|
143
153
|
*/
|
|
144
154
|
clearAsync(): Promise<void>;
|
|
155
|
+
/**
|
|
156
|
+
* Convert unknown arguments to JsonValue for CLI compatibility
|
|
157
|
+
* Attempts to serialize complex types to JSON-safe format
|
|
158
|
+
*/
|
|
159
|
+
private toJsonValue;
|
|
145
160
|
}
|
|
146
161
|
/**
|
|
147
162
|
* Default unified registry instance
|
|
148
163
|
*/
|
|
149
164
|
export declare const unifiedRegistry: UnifiedMCPRegistry;
|
|
165
|
+
export {};
|
|
@@ -284,7 +284,25 @@ export class UnifiedMCPRegistry extends MCPToolRegistry {
|
|
|
284
284
|
unifiedRegistryLogger.debug(`Trying tool ${toolName} on server ${serverId}`);
|
|
285
285
|
// Import the executeMCPTool function
|
|
286
286
|
const { executeMCPTool } = await import("../../cli/commands/mcp.js");
|
|
287
|
-
const
|
|
287
|
+
const typedServerConfig = serverConfig;
|
|
288
|
+
const mcpServerConfig = {
|
|
289
|
+
name: serverId,
|
|
290
|
+
command: (typeof typedServerConfig.command === "string"
|
|
291
|
+
? typedServerConfig.command
|
|
292
|
+
: "npx"),
|
|
293
|
+
args: (Array.isArray(typedServerConfig.args)
|
|
294
|
+
? typedServerConfig.args
|
|
295
|
+
: []),
|
|
296
|
+
env: (typeof typedServerConfig.env === "object" &&
|
|
297
|
+
typedServerConfig.env
|
|
298
|
+
? typedServerConfig.env
|
|
299
|
+
: {}),
|
|
300
|
+
cwd: typeof typedServerConfig.cwd === "string"
|
|
301
|
+
? typedServerConfig.cwd
|
|
302
|
+
: undefined,
|
|
303
|
+
transport: typedServerConfig.transport || "stdio",
|
|
304
|
+
};
|
|
305
|
+
const result = await executeMCPTool(mcpServerConfig, toolName, this.toJsonValue(args || {}));
|
|
288
306
|
// Convert to ToolResult format
|
|
289
307
|
const toolResult = {
|
|
290
308
|
success: true,
|
|
@@ -349,7 +367,8 @@ export class UnifiedMCPRegistry extends MCPToolRegistry {
|
|
|
349
367
|
const bySource = {};
|
|
350
368
|
const byType = {};
|
|
351
369
|
for (const plugin of plugins) {
|
|
352
|
-
const source = plugin.source ||
|
|
370
|
+
const source = plugin.source ||
|
|
371
|
+
"unknown";
|
|
353
372
|
bySource[source] = (bySource[source] || 0) + 1;
|
|
354
373
|
// Extract type from name or metadata
|
|
355
374
|
const type = plugin.metadata.name.split("/")[1]?.split("-")[0] || "unknown";
|
|
@@ -388,7 +407,11 @@ export class UnifiedMCPRegistry extends MCPToolRegistry {
|
|
|
388
407
|
};
|
|
389
408
|
// Register in internal registry
|
|
390
409
|
this.register(serverMeta);
|
|
391
|
-
this.manualServers.set(serverId,
|
|
410
|
+
this.manualServers.set(serverId, {
|
|
411
|
+
...config,
|
|
412
|
+
name: serverId,
|
|
413
|
+
command: config.command || "npx",
|
|
414
|
+
});
|
|
392
415
|
this.availableServers.add(serverId);
|
|
393
416
|
// Establish actual connection to make server immediately reachable
|
|
394
417
|
try {
|
|
@@ -482,6 +505,32 @@ export class UnifiedMCPRegistry extends MCPToolRegistry {
|
|
|
482
505
|
// Clear registries without attempting to close connections again
|
|
483
506
|
this.clearRegistriesOnly();
|
|
484
507
|
}
|
|
508
|
+
/**
|
|
509
|
+
* Convert unknown arguments to JsonValue for CLI compatibility
|
|
510
|
+
* Attempts to serialize complex types to JSON-safe format
|
|
511
|
+
*/
|
|
512
|
+
toJsonValue(args) {
|
|
513
|
+
try {
|
|
514
|
+
// First try to use it directly if it's already a JsonValue
|
|
515
|
+
if (args === null ||
|
|
516
|
+
typeof args === "string" ||
|
|
517
|
+
typeof args === "number" ||
|
|
518
|
+
typeof args === "boolean") {
|
|
519
|
+
return args;
|
|
520
|
+
}
|
|
521
|
+
// For objects and arrays, try JSON round-trip to ensure serialization
|
|
522
|
+
if (typeof args === "object") {
|
|
523
|
+
return JSON.parse(JSON.stringify(args));
|
|
524
|
+
}
|
|
525
|
+
// For other types, convert to string
|
|
526
|
+
return String(args);
|
|
527
|
+
}
|
|
528
|
+
catch (error) {
|
|
529
|
+
// If serialization fails, return empty object as fallback
|
|
530
|
+
unifiedRegistryLogger.warn("Failed to convert args to JsonValue, using empty object:", error);
|
|
531
|
+
return {};
|
|
532
|
+
}
|
|
533
|
+
}
|
|
485
534
|
}
|
|
486
535
|
/**
|
|
487
536
|
* Default unified registry instance
|
package/dist/lib/neurolink.d.ts
CHANGED
|
@@ -36,7 +36,7 @@ export interface MCPServerInfo {
|
|
|
36
36
|
source: string;
|
|
37
37
|
status: "connected" | "discovered" | "failed";
|
|
38
38
|
hasServer: boolean;
|
|
39
|
-
metadata?:
|
|
39
|
+
metadata?: unknown;
|
|
40
40
|
}
|
|
41
41
|
export declare class NeuroLink {
|
|
42
42
|
private mcpInitialized;
|
|
@@ -132,7 +132,7 @@ export declare class NeuroLink {
|
|
|
132
132
|
* @param options - Execution options
|
|
133
133
|
* @returns Tool execution result
|
|
134
134
|
*/
|
|
135
|
-
executeTool<T =
|
|
135
|
+
executeTool<T = unknown>(toolName: string, params?: unknown, options?: {
|
|
136
136
|
timeout?: number;
|
|
137
137
|
}): Promise<T>;
|
|
138
138
|
/**
|
package/dist/lib/neurolink.js
CHANGED
|
@@ -112,20 +112,45 @@ export class NeuroLink {
|
|
|
112
112
|
: undefined,
|
|
113
113
|
responseTime: textResult.responseTime,
|
|
114
114
|
toolsUsed: textResult.toolsUsed,
|
|
115
|
-
toolExecutions: textResult.toolExecutions?.map((te) =>
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
115
|
+
toolExecutions: textResult.toolExecutions?.map((te) => {
|
|
116
|
+
const teRecord = te;
|
|
117
|
+
return {
|
|
118
|
+
name: te.toolName || teRecord.name || "",
|
|
119
|
+
input: teRecord.input ||
|
|
120
|
+
teRecord.args ||
|
|
121
|
+
{},
|
|
122
|
+
output: teRecord.output ||
|
|
123
|
+
teRecord.result ||
|
|
124
|
+
(te.success ? "success" : "failed"),
|
|
125
|
+
duration: te.executionTime || teRecord.duration || 0,
|
|
126
|
+
};
|
|
127
|
+
}),
|
|
121
128
|
enhancedWithTools: textResult.enhancedWithTools,
|
|
122
|
-
availableTools: textResult.availableTools?.map((tool) =>
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
129
|
+
availableTools: textResult.availableTools?.map((tool) => {
|
|
130
|
+
const toolRecord = tool;
|
|
131
|
+
return {
|
|
132
|
+
name: tool.name || "",
|
|
133
|
+
description: tool.description || "",
|
|
134
|
+
parameters: toolRecord.parameters ||
|
|
135
|
+
toolRecord.schema ||
|
|
136
|
+
{},
|
|
137
|
+
};
|
|
138
|
+
}),
|
|
127
139
|
analytics: textResult.analytics,
|
|
128
|
-
evaluation: textResult.evaluation
|
|
140
|
+
evaluation: textResult.evaluation
|
|
141
|
+
? {
|
|
142
|
+
...textResult.evaluation,
|
|
143
|
+
isOffTopic: textResult.evaluation
|
|
144
|
+
.isOffTopic ?? false,
|
|
145
|
+
alertSeverity: textResult.evaluation.alertSeverity ?? "none",
|
|
146
|
+
reasoning: textResult.evaluation.reasoning ??
|
|
147
|
+
"No evaluation provided",
|
|
148
|
+
evaluationModel: textResult.evaluation
|
|
149
|
+
.evaluationModel ?? "unknown",
|
|
150
|
+
evaluationTime: textResult.evaluation
|
|
151
|
+
.evaluationTime ?? Date.now(),
|
|
152
|
+
}
|
|
153
|
+
: undefined,
|
|
129
154
|
};
|
|
130
155
|
return generateResult;
|
|
131
156
|
}
|
|
@@ -213,9 +238,9 @@ export class NeuroLink {
|
|
|
213
238
|
try {
|
|
214
239
|
const allTools = await toolRegistry.listTools();
|
|
215
240
|
availableTools = allTools.map((tool) => ({
|
|
216
|
-
name: tool.name,
|
|
241
|
+
name: tool.name || "Unknown",
|
|
217
242
|
description: tool.description || "No description available",
|
|
218
|
-
server: tool.server,
|
|
243
|
+
server: tool.server || "Unknown",
|
|
219
244
|
category: tool.category,
|
|
220
245
|
}));
|
|
221
246
|
}
|
|
@@ -245,7 +270,7 @@ export class NeuroLink {
|
|
|
245
270
|
toolsUsed: [],
|
|
246
271
|
enhancedWithTools: true,
|
|
247
272
|
availableTools: availableTools.length > 0 ? availableTools : undefined,
|
|
248
|
-
//
|
|
273
|
+
// Include analytics and evaluation from BaseProvider
|
|
249
274
|
analytics: result.analytics,
|
|
250
275
|
evaluation: result.evaluation,
|
|
251
276
|
};
|
|
@@ -26,7 +26,7 @@ export declare class AmazonBedrockProvider extends BaseProvider {
|
|
|
26
26
|
*/
|
|
27
27
|
protected getAISDKModel(): LanguageModelV1;
|
|
28
28
|
protected executeStream(options: StreamOptions, analysisSchema?: ZodType<unknown, ZodTypeDef, unknown> | Schema<unknown>): Promise<StreamResult>;
|
|
29
|
-
protected handleProviderError(error:
|
|
29
|
+
protected handleProviderError(error: unknown): Error;
|
|
30
30
|
private validateStreamOptions;
|
|
31
31
|
}
|
|
32
32
|
export default AmazonBedrockProvider;
|
|
@@ -112,19 +112,20 @@ export class AmazonBedrockProvider extends BaseProvider {
|
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
handleProviderError(error) {
|
|
115
|
-
if (error.name === "TimeoutError") {
|
|
115
|
+
if (error instanceof Error && error.name === "TimeoutError") {
|
|
116
116
|
return new TimeoutError(`Amazon Bedrock request timed out. Consider increasing timeout or using a lighter model.`, this.defaultTimeout);
|
|
117
117
|
}
|
|
118
|
-
|
|
119
|
-
|
|
118
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
119
|
+
if (errorMessage.includes("InvalidRequestException")) {
|
|
120
|
+
return new Error(`ā Amazon Bedrock Request Error\n\nThe request was invalid: ${errorMessage}\n\nš§ Common Solutions:\n1. Check your model ID format\n2. Verify your request parameters\n3. Ensure your AWS account has Bedrock access`);
|
|
120
121
|
}
|
|
121
|
-
if (
|
|
122
|
+
if (errorMessage.includes("AccessDeniedException")) {
|
|
122
123
|
return new Error(`ā Amazon Bedrock Access Denied\n\nYour AWS credentials don't have permission to access Bedrock.\n\nš§ Required Steps:\n1. Ensure your IAM user has bedrock:InvokeModel permission\n2. Check if Bedrock is available in your region\n3. Verify model access is enabled in Bedrock console`);
|
|
123
124
|
}
|
|
124
|
-
if (
|
|
125
|
-
return new Error(`ā Amazon Bedrock Validation Error\n\n${
|
|
125
|
+
if (errorMessage.includes("ValidationException")) {
|
|
126
|
+
return new Error(`ā Amazon Bedrock Validation Error\n\n${errorMessage}\n\nš§ Check:\n1. Model ID format (should be ARN or model identifier)\n2. Request parameters are within limits\n3. Region configuration is correct`);
|
|
126
127
|
}
|
|
127
|
-
return new Error(`ā Amazon Bedrock Provider Error\n\n${
|
|
128
|
+
return new Error(`ā Amazon Bedrock Provider Error\n\n${errorMessage || "Unknown error occurred"}\n\nš§ Troubleshooting:\n1. Check AWS credentials and permissions\n2. Verify model availability\n3. Check network connectivity`);
|
|
128
129
|
}
|
|
129
130
|
validateStreamOptions(options) {
|
|
130
131
|
if (!options.input?.text?.trim()) {
|
|
@@ -3,18 +3,9 @@
|
|
|
3
3
|
* Ensures consistent analytics data format across providers
|
|
4
4
|
* Integrates with Universal Evaluation System
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
tokens: {
|
|
10
|
-
input: number;
|
|
11
|
-
output: number;
|
|
12
|
-
total: number;
|
|
13
|
-
};
|
|
14
|
-
cost?: number;
|
|
15
|
-
responseTime: number;
|
|
16
|
-
timestamp: string;
|
|
17
|
-
context?: Record<string, any>;
|
|
6
|
+
import type { UnknownRecord } from "../types/common.js";
|
|
7
|
+
import type { AnalyticsData as CoreAnalyticsData } from "../core/types.js";
|
|
8
|
+
export interface AnalyticsData extends CoreAnalyticsData {
|
|
18
9
|
evaluation?: {
|
|
19
10
|
relevanceScore: number;
|
|
20
11
|
accuracyScore: number;
|
|
@@ -24,30 +15,24 @@ export interface AnalyticsData {
|
|
|
24
15
|
evaluationTime?: number;
|
|
25
16
|
evaluationAttempt?: number;
|
|
26
17
|
};
|
|
27
|
-
costDetails?:
|
|
28
|
-
inputCost: number;
|
|
29
|
-
outputCost: number;
|
|
30
|
-
evaluationCost?: number;
|
|
31
|
-
totalCost: number;
|
|
32
|
-
currency: string;
|
|
33
|
-
};
|
|
18
|
+
costDetails?: UnknownRecord;
|
|
34
19
|
}
|
|
35
20
|
/**
|
|
36
21
|
* Create standardized analytics data from provider response
|
|
37
22
|
*/
|
|
38
|
-
export declare function createAnalytics(provider: string, model: string, result:
|
|
23
|
+
export declare function createAnalytics(provider: string, model: string, result: unknown, responseTime: number, context?: Record<string, unknown>): AnalyticsData;
|
|
39
24
|
/**
|
|
40
25
|
* Create enhanced analytics data with accurate cost calculations (async version)
|
|
41
26
|
*/
|
|
42
|
-
export declare function createEnhancedAnalytics(provider: string, model: string, result:
|
|
27
|
+
export declare function createEnhancedAnalytics(provider: string, model: string, result: unknown, responseTime: number, context?: Record<string, unknown>): Promise<AnalyticsData>;
|
|
43
28
|
/**
|
|
44
29
|
* Calculate enhanced cost details using provider configurations
|
|
45
30
|
*/
|
|
46
31
|
export declare function calculateEnhancedCost(provider: string, inputTokens: number, outputTokens: number): Promise<{
|
|
47
|
-
costDetails:
|
|
32
|
+
costDetails: UnknownRecord;
|
|
48
33
|
estimatedCost: number;
|
|
49
34
|
}>;
|
|
50
35
|
/**
|
|
51
36
|
* Enhance analytics with evaluation data
|
|
52
37
|
*/
|
|
53
|
-
export declare function enhanceAnalyticsWithEvaluation(analytics: AnalyticsData, evaluationResult:
|
|
38
|
+
export declare function enhanceAnalyticsWithEvaluation(analytics: AnalyticsData, evaluationResult: UnknownRecord): AnalyticsData;
|