@juspay/neurolink 7.13.0 → 7.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +89 -25
- package/dist/agent/directTools.d.ts +3 -3
- package/dist/agent/directTools.js +1 -1
- package/dist/cli/commands/mcp.js +67 -207
- package/dist/cli/factories/commandFactory.js +7 -1
- package/dist/cli/utils/interactiveSetup.js +1 -1
- package/dist/config/conversationMemoryConfig.js +2 -1
- package/dist/context/ContextManager.js +15 -4
- package/dist/context/config.js +5 -1
- package/dist/context/utils.js +1 -1
- package/dist/core/baseProvider.d.ts +11 -30
- package/dist/core/baseProvider.js +268 -42
- package/dist/core/conversationMemoryManager.js +3 -2
- package/dist/core/dynamicModels.d.ts +14 -14
- package/dist/core/dynamicModels.js +1 -1
- package/dist/core/evaluation.js +1 -1
- package/dist/core/factory.js +1 -1
- package/dist/factories/providerFactory.js +5 -11
- package/dist/factories/providerRegistry.js +2 -2
- package/dist/index.d.ts +5 -4
- package/dist/index.js +1 -1
- package/dist/lib/agent/directTools.js +1 -1
- package/dist/lib/config/conversationMemoryConfig.js +2 -1
- package/dist/lib/context/ContextManager.js +15 -4
- package/dist/lib/context/config.js +5 -1
- package/dist/lib/context/utils.js +1 -1
- package/dist/lib/core/baseProvider.d.ts +11 -30
- package/dist/lib/core/baseProvider.js +268 -42
- package/dist/lib/core/conversationMemoryManager.js +3 -2
- package/dist/lib/core/dynamicModels.js +1 -1
- package/dist/lib/core/evaluation.js +1 -1
- package/dist/lib/core/factory.js +1 -1
- package/dist/lib/factories/providerFactory.js +5 -11
- package/dist/lib/factories/providerRegistry.js +2 -2
- package/dist/lib/index.d.ts +5 -4
- package/dist/lib/index.js +1 -1
- package/dist/lib/mcp/externalServerManager.d.ts +148 -0
- package/dist/lib/mcp/externalServerManager.js +1038 -0
- package/dist/lib/mcp/mcpCircuitBreaker.d.ts +184 -0
- package/dist/lib/mcp/mcpCircuitBreaker.js +338 -0
- package/dist/lib/mcp/mcpClientFactory.d.ts +105 -0
- package/dist/lib/mcp/mcpClientFactory.js +421 -0
- package/dist/lib/mcp/toolDiscoveryService.d.ts +193 -0
- package/dist/lib/mcp/toolDiscoveryService.js +646 -0
- package/dist/lib/mcp/toolRegistry.d.ts +15 -11
- package/dist/lib/mcp/toolRegistry.js +118 -55
- package/dist/lib/models/modelResolver.js +1 -1
- package/dist/lib/neurolink.d.ts +139 -43
- package/dist/lib/neurolink.js +604 -174
- package/dist/lib/providers/googleVertex.d.ts +7 -1
- package/dist/lib/providers/googleVertex.js +34 -7
- package/dist/lib/providers/huggingFace.js +1 -1
- package/dist/lib/providers/mistral.js +3 -3
- package/dist/lib/providers/ollama.js +1 -1
- package/dist/lib/providers/openAI.d.ts +3 -2
- package/dist/lib/providers/openAI.js +2 -2
- package/dist/lib/providers/openaiCompatible.d.ts +1 -1
- package/dist/lib/providers/openaiCompatible.js +2 -2
- package/dist/lib/providers/sagemaker/config.js +1 -1
- package/dist/lib/sdk/toolRegistration.d.ts +4 -13
- package/dist/lib/sdk/toolRegistration.js +19 -66
- package/dist/lib/types/cli.d.ts +0 -1
- package/dist/lib/types/cli.js +0 -1
- package/dist/lib/types/common.d.ts +1 -2
- package/dist/lib/types/common.js +0 -1
- package/dist/lib/types/contextTypes.d.ts +1 -1
- package/dist/lib/types/contextTypes.js +3 -3
- package/dist/lib/types/externalMcp.d.ts +288 -0
- package/dist/lib/types/externalMcp.js +7 -0
- package/dist/lib/types/generateTypes.d.ts +0 -1
- package/dist/lib/types/index.d.ts +2 -2
- package/dist/lib/types/index.js +0 -1
- package/dist/lib/types/mcpTypes.d.ts +53 -99
- package/dist/lib/types/providers.d.ts +0 -1
- package/dist/lib/types/providers.js +0 -1
- package/dist/lib/types/tools.d.ts +2 -2
- package/dist/lib/types/tools.js +2 -2
- package/dist/lib/utils/factoryProcessing.js +1 -1
- package/dist/lib/utils/mcpDefaults.d.ts +54 -0
- package/dist/lib/utils/mcpDefaults.js +125 -0
- package/dist/lib/utils/providerConfig.d.ts +1 -1
- package/dist/lib/utils/providerConfig.js +2 -2
- package/dist/lib/utils/providerHealth.js +6 -6
- package/dist/mcp/externalServerManager.d.ts +148 -0
- package/dist/mcp/externalServerManager.js +1038 -0
- package/dist/mcp/mcpCircuitBreaker.d.ts +184 -0
- package/dist/mcp/mcpCircuitBreaker.js +338 -0
- package/dist/mcp/mcpClientFactory.d.ts +105 -0
- package/dist/mcp/mcpClientFactory.js +421 -0
- package/dist/mcp/toolDiscoveryService.d.ts +193 -0
- package/dist/mcp/toolDiscoveryService.js +646 -0
- package/dist/mcp/toolRegistry.d.ts +15 -11
- package/dist/mcp/toolRegistry.js +118 -55
- package/dist/models/modelResolver.js +1 -1
- package/dist/neurolink.d.ts +139 -43
- package/dist/neurolink.js +604 -174
- package/dist/providers/googleVertex.d.ts +7 -1
- package/dist/providers/googleVertex.js +34 -7
- package/dist/providers/huggingFace.js +1 -1
- package/dist/providers/mistral.js +3 -3
- package/dist/providers/ollama.js +1 -1
- package/dist/providers/openAI.d.ts +3 -2
- package/dist/providers/openAI.js +2 -2
- package/dist/providers/openaiCompatible.d.ts +1 -1
- package/dist/providers/openaiCompatible.js +2 -2
- package/dist/providers/sagemaker/config.js +1 -1
- package/dist/sdk/toolRegistration.d.ts +4 -13
- package/dist/sdk/toolRegistration.js +19 -66
- package/dist/types/cli.d.ts +0 -1
- package/dist/types/cli.js +0 -1
- package/dist/types/common.d.ts +1 -2
- package/dist/types/common.js +0 -1
- package/dist/types/contextTypes.d.ts +1 -1
- package/dist/types/contextTypes.js +3 -3
- package/dist/types/externalMcp.d.ts +288 -0
- package/dist/types/externalMcp.js +7 -0
- package/dist/types/generateTypes.d.ts +0 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.js +0 -1
- package/dist/types/mcpTypes.d.ts +53 -99
- package/dist/types/providers.d.ts +0 -1
- package/dist/types/providers.js +0 -1
- package/dist/types/tools.d.ts +2 -2
- package/dist/types/tools.js +2 -2
- package/dist/utils/factoryProcessing.js +1 -1
- package/dist/utils/mcpDefaults.d.ts +54 -0
- package/dist/utils/mcpDefaults.js +125 -0
- package/dist/utils/providerConfig.d.ts +1 -1
- package/dist/utils/providerConfig.js +2 -2
- package/dist/utils/providerHealth.js +6 -6
- package/package.json +1 -1
|
@@ -20,10 +20,10 @@ declare const ModelConfigSchema: z.ZodObject<{
|
|
|
20
20
|
contextWindow: z.ZodNumber;
|
|
21
21
|
releaseDate: z.ZodString;
|
|
22
22
|
}, "strip", z.ZodTypeAny, {
|
|
23
|
-
id: string;
|
|
24
|
-
displayName: string;
|
|
25
23
|
capabilities: string[];
|
|
24
|
+
id: string;
|
|
26
25
|
deprecated: boolean;
|
|
26
|
+
displayName: string;
|
|
27
27
|
pricing: {
|
|
28
28
|
input: number;
|
|
29
29
|
output: number;
|
|
@@ -31,10 +31,10 @@ declare const ModelConfigSchema: z.ZodObject<{
|
|
|
31
31
|
contextWindow: number;
|
|
32
32
|
releaseDate: string;
|
|
33
33
|
}, {
|
|
34
|
-
id: string;
|
|
35
|
-
displayName: string;
|
|
36
34
|
capabilities: string[];
|
|
35
|
+
id: string;
|
|
37
36
|
deprecated: boolean;
|
|
37
|
+
displayName: string;
|
|
38
38
|
pricing: {
|
|
39
39
|
input: number;
|
|
40
40
|
output: number;
|
|
@@ -63,10 +63,10 @@ declare const ModelRegistrySchema: z.ZodObject<{
|
|
|
63
63
|
contextWindow: z.ZodNumber;
|
|
64
64
|
releaseDate: z.ZodString;
|
|
65
65
|
}, "strip", z.ZodTypeAny, {
|
|
66
|
-
id: string;
|
|
67
|
-
displayName: string;
|
|
68
66
|
capabilities: string[];
|
|
67
|
+
id: string;
|
|
69
68
|
deprecated: boolean;
|
|
69
|
+
displayName: string;
|
|
70
70
|
pricing: {
|
|
71
71
|
input: number;
|
|
72
72
|
output: number;
|
|
@@ -74,10 +74,10 @@ declare const ModelRegistrySchema: z.ZodObject<{
|
|
|
74
74
|
contextWindow: number;
|
|
75
75
|
releaseDate: string;
|
|
76
76
|
}, {
|
|
77
|
-
id: string;
|
|
78
|
-
displayName: string;
|
|
79
77
|
capabilities: string[];
|
|
78
|
+
id: string;
|
|
80
79
|
deprecated: boolean;
|
|
80
|
+
displayName: string;
|
|
81
81
|
pricing: {
|
|
82
82
|
input: number;
|
|
83
83
|
output: number;
|
|
@@ -89,11 +89,12 @@ declare const ModelRegistrySchema: z.ZodObject<{
|
|
|
89
89
|
defaults: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
90
90
|
}, "strip", z.ZodTypeAny, {
|
|
91
91
|
version: string;
|
|
92
|
+
lastUpdated: string;
|
|
92
93
|
models: Record<string, Record<string, {
|
|
93
|
-
id: string;
|
|
94
|
-
displayName: string;
|
|
95
94
|
capabilities: string[];
|
|
95
|
+
id: string;
|
|
96
96
|
deprecated: boolean;
|
|
97
|
+
displayName: string;
|
|
97
98
|
pricing: {
|
|
98
99
|
input: number;
|
|
99
100
|
output: number;
|
|
@@ -101,16 +102,16 @@ declare const ModelRegistrySchema: z.ZodObject<{
|
|
|
101
102
|
contextWindow: number;
|
|
102
103
|
releaseDate: string;
|
|
103
104
|
}>>;
|
|
104
|
-
lastUpdated: string;
|
|
105
105
|
defaults?: Record<string, string> | undefined;
|
|
106
106
|
aliases?: Record<string, string> | undefined;
|
|
107
107
|
}, {
|
|
108
108
|
version: string;
|
|
109
|
+
lastUpdated: string;
|
|
109
110
|
models: Record<string, Record<string, {
|
|
110
|
-
id: string;
|
|
111
|
-
displayName: string;
|
|
112
111
|
capabilities: string[];
|
|
112
|
+
id: string;
|
|
113
113
|
deprecated: boolean;
|
|
114
|
+
displayName: string;
|
|
114
115
|
pricing: {
|
|
115
116
|
input: number;
|
|
116
117
|
output: number;
|
|
@@ -118,7 +119,6 @@ declare const ModelRegistrySchema: z.ZodObject<{
|
|
|
118
119
|
contextWindow: number;
|
|
119
120
|
releaseDate: string;
|
|
120
121
|
}>>;
|
|
121
|
-
lastUpdated: string;
|
|
122
122
|
defaults?: Record<string, string> | undefined;
|
|
123
123
|
aliases?: Record<string, string> | undefined;
|
|
124
124
|
}>;
|
|
@@ -89,7 +89,7 @@ export class DynamicModelProvider {
|
|
|
89
89
|
}
|
|
90
90
|
// Log all failures for debugging
|
|
91
91
|
logger.warn(`[DynamicModelProvider] All model configuration sources failed`, { errors });
|
|
92
|
-
throw new Error(`Failed to load model configuration from
|
|
92
|
+
throw new Error(`Failed to load model configuration from all source. Attempted: ${errors.map((e) => e.source).join(", ")}`);
|
|
93
93
|
}
|
|
94
94
|
/**
|
|
95
95
|
* Load configuration from a source with timeout handling
|
package/dist/core/evaluation.js
CHANGED
|
@@ -181,7 +181,7 @@ Relevance: [score]
|
|
|
181
181
|
Accuracy: [score]
|
|
182
182
|
Completeness: [score]
|
|
183
183
|
Overall: [score]
|
|
184
|
-
Reasoning: [Provide a detailed explanation of your evaluation, explaining why you gave these scores. Include specific observations about the response's strengths and
|
|
184
|
+
Reasoning: [Provide a detailed explanation of your evaluation, explaining why you gave these scores. Include specific observations about the response's strengths and all possible areas for improvement.]
|
|
185
185
|
`;
|
|
186
186
|
// Generate evaluation
|
|
187
187
|
const result = await provider.generate(prompt);
|
package/dist/core/factory.js
CHANGED
|
@@ -109,13 +109,13 @@ export class AIProviderFactory {
|
|
|
109
109
|
const finalModelName = resolvedModelName === "default" || resolvedModelName === null
|
|
110
110
|
? undefined
|
|
111
111
|
: resolvedModelName;
|
|
112
|
+
// Create provider with enhanced SDK
|
|
112
113
|
const provider = await ProviderFactory.createProvider(normalizedName, finalModelName, sdk);
|
|
113
114
|
logger.debug(componentIdentifier, "Pure factory pattern provider created", {
|
|
114
115
|
providerName: normalizedName,
|
|
115
116
|
modelName: finalModelName,
|
|
116
117
|
factoryUsed: true,
|
|
117
118
|
});
|
|
118
|
-
// PURE FACTORY PATTERN: All providers handled by ProviderFactory - no switch statements needed
|
|
119
119
|
// Wrap with MCP if enabled
|
|
120
120
|
if (enableMCP) {
|
|
121
121
|
try {
|
|
@@ -46,22 +46,16 @@ export class ProviderFactory {
|
|
|
46
46
|
model = model || registration.defaultModel;
|
|
47
47
|
}
|
|
48
48
|
try {
|
|
49
|
-
// Try calling as factory function first, then fallback to constructor
|
|
50
49
|
let result;
|
|
51
50
|
try {
|
|
52
|
-
// Try as factory function
|
|
53
|
-
result = registration.constructor(model, providerName, sdk);
|
|
51
|
+
// Try as async factory function first (most providers are async functions)
|
|
52
|
+
result = await registration.constructor(model, providerName, sdk);
|
|
54
53
|
}
|
|
55
|
-
catch (
|
|
56
|
-
// Fallback to constructor
|
|
54
|
+
catch (functionError) {
|
|
55
|
+
// Fallback to constructor - ensure parameters are maintained
|
|
57
56
|
result = new registration.constructor(model, providerName, sdk);
|
|
58
57
|
}
|
|
59
|
-
//
|
|
60
|
-
if (result &&
|
|
61
|
-
typeof result === "object" &&
|
|
62
|
-
typeof result.then === "function") {
|
|
63
|
-
result = await result;
|
|
64
|
-
}
|
|
58
|
+
// Return result (no need to await again if already awaited in try block)
|
|
65
59
|
return result;
|
|
66
60
|
}
|
|
67
61
|
catch (error) {
|
|
@@ -52,9 +52,9 @@ export class ProviderRegistry {
|
|
|
52
52
|
process.env.AZURE_OPENAI_DEPLOYMENT_ID ||
|
|
53
53
|
"gpt-4o-mini", ["azure", "azureOpenai"]);
|
|
54
54
|
// Register Google Vertex AI provider
|
|
55
|
-
ProviderFactory.registerProvider(AIProviderName.VERTEX, async (modelName) => {
|
|
55
|
+
ProviderFactory.registerProvider(AIProviderName.VERTEX, async (modelName, providerName, sdk) => {
|
|
56
56
|
const { GoogleVertexProvider } = await import("../providers/googleVertex.js");
|
|
57
|
-
return new GoogleVertexProvider(modelName);
|
|
57
|
+
return new GoogleVertexProvider(modelName, providerName, sdk);
|
|
58
58
|
}, "claude-sonnet-4@20250514", ["vertex", "googleVertex"]);
|
|
59
59
|
// Register Hugging Face provider (Unified Router implementation)
|
|
60
60
|
ProviderFactory.registerProvider(AIProviderName.HUGGINGFACE, async (modelName) => {
|
package/dist/index.d.ts
CHANGED
|
@@ -10,13 +10,14 @@ import { AIProviderFactory } from "./core/factory.js";
|
|
|
10
10
|
export { AIProviderFactory };
|
|
11
11
|
export type { AIProvider, AIProviderName, ProviderConfig, StreamingOptions, ProviderAttempt, SupportedModelName, } from "./core/types.js";
|
|
12
12
|
export type { GenerateOptions, GenerateResult, EnhancedProvider, } from "./types/generateTypes.js";
|
|
13
|
-
export type {
|
|
14
|
-
export {
|
|
15
|
-
export type {
|
|
13
|
+
export type { ToolContext } from "./sdk/toolRegistration.js";
|
|
14
|
+
export { validateTool } from "./sdk/toolRegistration.js";
|
|
15
|
+
export type { ToolResult, ToolDefinition } from "./types/tools.js";
|
|
16
16
|
export { BedrockModels, OpenAIModels, VertexModels, DEFAULT_PROVIDER_CONFIGS, } from "./core/types.js";
|
|
17
17
|
export { getBestProvider, getAvailableProviders, isValidProvider, } from "./utils/providerUtils.js";
|
|
18
18
|
export { NeuroLink } from "./neurolink.js";
|
|
19
|
-
export type { ProviderStatus, MCPStatus
|
|
19
|
+
export type { ProviderStatus, MCPStatus } from "./neurolink.js";
|
|
20
|
+
export type { MCPServerInfo } from "./types/mcpTypes.js";
|
|
20
21
|
export declare const VERSION = "1.0.0";
|
|
21
22
|
/**
|
|
22
23
|
* Quick start factory function
|
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
// Core exports
|
|
10
10
|
import { AIProviderFactory } from "./core/factory.js";
|
|
11
11
|
export { AIProviderFactory };
|
|
12
|
-
export {
|
|
12
|
+
export { validateTool } from "./sdk/toolRegistration.js";
|
|
13
13
|
// Model enums
|
|
14
14
|
export { BedrockModels, OpenAIModels, VertexModels, DEFAULT_PROVIDER_CONFIGS, } from "./core/types.js";
|
|
15
15
|
// Utility exports
|
|
@@ -163,7 +163,7 @@ export const directAgentTools = {
|
|
|
163
163
|
for (const func of allowedMathFunctions) {
|
|
164
164
|
safeExpression = safeExpression.replace(new RegExp(func, "g"), func);
|
|
165
165
|
}
|
|
166
|
-
// Remove
|
|
166
|
+
// Remove remaining non-safe characters except Math functions
|
|
167
167
|
const mathSafe = /^[0-9+\-*/().\s]|Math\.(abs|ceil|floor|round|sqrt|pow|sin|cos|tan|log|exp|PI|E)/g;
|
|
168
168
|
if (!safeExpression
|
|
169
169
|
.split("")
|
|
@@ -34,6 +34,7 @@ export function getConversationMemoryDefaults() {
|
|
|
34
34
|
return {
|
|
35
35
|
enabled: process.env.NEUROLINK_MEMORY_ENABLED === "true",
|
|
36
36
|
maxSessions: Number(process.env.NEUROLINK_MEMORY_MAX_SESSIONS) || DEFAULT_MAX_SESSIONS,
|
|
37
|
-
maxTurnsPerSession: Number(process.env.NEUROLINK_MEMORY_MAX_TURNS_PER_SESSION) ||
|
|
37
|
+
maxTurnsPerSession: Number(process.env.NEUROLINK_MEMORY_MAX_TURNS_PER_SESSION) ||
|
|
38
|
+
DEFAULT_MAX_TURNS_PER_SESSION,
|
|
38
39
|
};
|
|
39
40
|
}
|
|
@@ -14,7 +14,10 @@ export class ContextManager {
|
|
|
14
14
|
constructor(generatorFunction, config, initialContext = "This is the start of the conversation.") {
|
|
15
15
|
this.internalGenerator = generatorFunction;
|
|
16
16
|
this.config = config;
|
|
17
|
-
const initialMessage = {
|
|
17
|
+
const initialMessage = {
|
|
18
|
+
role: "system",
|
|
19
|
+
content: initialContext,
|
|
20
|
+
};
|
|
18
21
|
initialMessage.wordCount = this.config.estimateWordCount([initialMessage]);
|
|
19
22
|
this.history = [initialMessage];
|
|
20
23
|
this.wordCount = initialMessage.wordCount;
|
|
@@ -55,7 +58,9 @@ export class ContextManager {
|
|
|
55
58
|
const result = await this.internalGenerator(textOptions);
|
|
56
59
|
if (typeof result.content === "string" && result.content.length > 0) {
|
|
57
60
|
// Replace the history with a single system message containing the summary
|
|
58
|
-
const newHistory = [
|
|
61
|
+
const newHistory = [
|
|
62
|
+
{ role: "system", content: result.content },
|
|
63
|
+
];
|
|
59
64
|
this.history = newHistory;
|
|
60
65
|
this.wordCount = this.config.estimateWordCount(this.history);
|
|
61
66
|
logger.info(`[ContextManager] Summarization complete. New history length: ${this.wordCount} words.`);
|
|
@@ -63,7 +68,10 @@ export class ContextManager {
|
|
|
63
68
|
else {
|
|
64
69
|
logger.warn("[ContextManager] Summarization returned empty or non-string content; truncating history as a fallback.");
|
|
65
70
|
this._truncateHistory(this.config.lowWaterMarkWords);
|
|
66
|
-
this.history.unshift({
|
|
71
|
+
this.history.unshift({
|
|
72
|
+
role: "system",
|
|
73
|
+
content: ContextManager.SUMMARIZATION_EMPTY_WARNING,
|
|
74
|
+
});
|
|
67
75
|
this.wordCount = this.config.estimateWordCount(this.history);
|
|
68
76
|
}
|
|
69
77
|
logger.debug(`[ContextManager] New history: ${JSON.stringify(this.history)}`);
|
|
@@ -72,7 +80,10 @@ export class ContextManager {
|
|
|
72
80
|
logger.error("Context summarization failed:", { error });
|
|
73
81
|
// Fallback strategy: truncate the history to the target word count.
|
|
74
82
|
this._truncateHistory(this.config.lowWaterMarkWords);
|
|
75
|
-
this.history.unshift({
|
|
83
|
+
this.history.unshift({
|
|
84
|
+
role: "system",
|
|
85
|
+
content: ContextManager.SUMMARIZATION_FAILED_WARNING,
|
|
86
|
+
});
|
|
76
87
|
this.wordCount = this.config.estimateWordCount(this.history);
|
|
77
88
|
}
|
|
78
89
|
}
|
|
@@ -6,7 +6,11 @@ function estimateWordCount(history) {
|
|
|
6
6
|
if (!history || history.length === 0) {
|
|
7
7
|
return 0;
|
|
8
8
|
}
|
|
9
|
-
return history.reduce((acc, msg) => acc +
|
|
9
|
+
return history.reduce((acc, msg) => acc +
|
|
10
|
+
(msg.content
|
|
11
|
+
.trim()
|
|
12
|
+
.split(/\s+/)
|
|
13
|
+
.filter((word) => word.length > 0).length || 0), 0);
|
|
10
14
|
}
|
|
11
15
|
/**
|
|
12
16
|
* Generates the default prompt for summarization.
|
|
@@ -3,33 +3,8 @@ import type { Schema } from "ai";
|
|
|
3
3
|
import type { Tool, LanguageModelV1 } from "ai";
|
|
4
4
|
import type { AIProvider, TextGenerationOptions, EnhancedGenerateResult, AnalyticsData, AIProviderName, EvaluationData } from "../core/types.js";
|
|
5
5
|
import type { StreamOptions, StreamResult } from "../types/streamTypes.js";
|
|
6
|
-
import type {
|
|
7
|
-
import type {
|
|
8
|
-
/**
|
|
9
|
-
* Interface for SDK with in-memory MCP servers
|
|
10
|
-
*/
|
|
11
|
-
export interface NeuroLinkSDK {
|
|
12
|
-
getInMemoryServers?: () => Map<string, {
|
|
13
|
-
server: {
|
|
14
|
-
title?: string;
|
|
15
|
-
description?: string;
|
|
16
|
-
tools?: Map<string, ToolInfo> | Record<string, ToolInfo>;
|
|
17
|
-
};
|
|
18
|
-
category?: string;
|
|
19
|
-
metadata?: UnknownRecord;
|
|
20
|
-
}>;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Interface for tool information in MCP servers
|
|
24
|
-
*/
|
|
25
|
-
interface ToolInfo {
|
|
26
|
-
description?: string;
|
|
27
|
-
inputSchema?: ZodType<JsonValue>;
|
|
28
|
-
parameters?: ZodType<JsonValue>;
|
|
29
|
-
execute: (args: JsonValue) => Promise<JsonValue | ToolResult> | JsonValue | ToolResult;
|
|
30
|
-
isImplemented?: boolean;
|
|
31
|
-
metadata?: UnknownRecord;
|
|
32
|
-
}
|
|
6
|
+
import type { UnknownRecord } from "../types/common.js";
|
|
7
|
+
import type { NeuroLink } from "../neurolink.js";
|
|
33
8
|
/**
|
|
34
9
|
* Abstract base class for all AI providers
|
|
35
10
|
* Tools are integrated as first-class citizens - always available by default
|
|
@@ -40,10 +15,12 @@ export declare abstract class BaseProvider implements AIProvider {
|
|
|
40
15
|
protected readonly defaultTimeout: number;
|
|
41
16
|
protected readonly directTools: {};
|
|
42
17
|
protected mcpTools?: Record<string, Tool>;
|
|
18
|
+
protected customTools?: Map<string, unknown>;
|
|
19
|
+
protected toolExecutor?: (toolName: string, params: unknown) => Promise<unknown>;
|
|
43
20
|
protected sessionId?: string;
|
|
44
21
|
protected userId?: string;
|
|
45
|
-
protected
|
|
46
|
-
constructor(modelName?: string, providerName?: AIProviderName,
|
|
22
|
+
protected neurolink?: NeuroLink;
|
|
23
|
+
constructor(modelName?: string, providerName?: AIProviderName, neurolink?: NeuroLink);
|
|
47
24
|
/**
|
|
48
25
|
* Check if this provider supports tool/function calling
|
|
49
26
|
* Override in subclasses to disable tools for specific providers or models
|
|
@@ -86,6 +63,11 @@ export declare abstract class BaseProvider implements AIProvider {
|
|
|
86
63
|
* MCP tools are added when available (without blocking)
|
|
87
64
|
*/
|
|
88
65
|
protected getAllTools(): Promise<Record<string, Tool>>;
|
|
66
|
+
/**
|
|
67
|
+
* Convert MCP JSON Schema to Zod schema for AI SDK tools
|
|
68
|
+
* Handles common MCP schema patterns safely
|
|
69
|
+
*/
|
|
70
|
+
private convertMCPSchemaToZod;
|
|
89
71
|
/**
|
|
90
72
|
* Set session context for MCP tools
|
|
91
73
|
*/
|
|
@@ -161,4 +143,3 @@ export declare abstract class BaseProvider implements AIProvider {
|
|
|
161
143
|
*/
|
|
162
144
|
static chunkPrompt(prompt: string, maxChunkSize?: number, overlap?: number): string[];
|
|
163
145
|
}
|
|
164
|
-
export {};
|