@juspay/neurolink 7.36.0 → 7.37.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.
Files changed (87) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cli/commands/config.d.ts +18 -18
  3. package/dist/cli/factories/commandFactory.d.ts +24 -0
  4. package/dist/cli/factories/commandFactory.js +297 -245
  5. package/dist/config/taskClassificationConfig.d.ts +51 -0
  6. package/dist/config/taskClassificationConfig.js +148 -0
  7. package/dist/core/baseProvider.d.ts +40 -3
  8. package/dist/core/baseProvider.js +689 -352
  9. package/dist/core/constants.d.ts +2 -30
  10. package/dist/core/constants.js +15 -43
  11. package/dist/factories/providerFactory.js +23 -6
  12. package/dist/index.d.ts +3 -2
  13. package/dist/index.js +4 -3
  14. package/dist/lib/config/taskClassificationConfig.d.ts +51 -0
  15. package/dist/lib/config/taskClassificationConfig.js +148 -0
  16. package/dist/lib/core/baseProvider.d.ts +40 -3
  17. package/dist/lib/core/baseProvider.js +689 -352
  18. package/dist/lib/core/constants.d.ts +2 -30
  19. package/dist/lib/core/constants.js +15 -43
  20. package/dist/lib/factories/providerFactory.js +23 -6
  21. package/dist/lib/index.d.ts +3 -2
  22. package/dist/lib/index.js +4 -3
  23. package/dist/lib/mcp/externalServerManager.js +2 -2
  24. package/dist/lib/mcp/registry.js +2 -2
  25. package/dist/lib/mcp/servers/agent/directToolsServer.js +19 -10
  26. package/dist/lib/mcp/toolRegistry.js +4 -8
  27. package/dist/lib/neurolink.d.ts +82 -27
  28. package/dist/lib/neurolink.js +672 -713
  29. package/dist/lib/providers/amazonBedrock.js +2 -2
  30. package/dist/lib/providers/googleVertex.d.ts +3 -23
  31. package/dist/lib/providers/googleVertex.js +14 -342
  32. package/dist/lib/providers/openAI.d.ts +23 -0
  33. package/dist/lib/providers/openAI.js +313 -6
  34. package/dist/lib/providers/sagemaker/language-model.d.ts +2 -2
  35. package/dist/lib/sdk/toolRegistration.js +18 -1
  36. package/dist/lib/types/common.d.ts +98 -0
  37. package/dist/lib/types/index.d.ts +2 -0
  38. package/dist/lib/types/index.js +2 -0
  39. package/dist/lib/types/streamTypes.d.ts +13 -6
  40. package/dist/lib/types/taskClassificationTypes.d.ts +52 -0
  41. package/dist/lib/types/taskClassificationTypes.js +5 -0
  42. package/dist/lib/types/typeAliases.d.ts +3 -2
  43. package/dist/lib/utils/modelRouter.d.ts +107 -0
  44. package/dist/lib/utils/modelRouter.js +292 -0
  45. package/dist/lib/utils/parameterValidation.js +6 -25
  46. package/dist/lib/utils/promptRedaction.d.ts +29 -0
  47. package/dist/lib/utils/promptRedaction.js +62 -0
  48. package/dist/lib/utils/schemaConversion.d.ts +14 -0
  49. package/dist/lib/utils/schemaConversion.js +140 -0
  50. package/dist/lib/utils/taskClassificationUtils.d.ts +55 -0
  51. package/dist/lib/utils/taskClassificationUtils.js +149 -0
  52. package/dist/lib/utils/taskClassifier.d.ts +23 -0
  53. package/dist/lib/utils/taskClassifier.js +94 -0
  54. package/dist/lib/utils/transformationUtils.js +143 -5
  55. package/dist/mcp/externalServerManager.js +2 -2
  56. package/dist/mcp/registry.js +2 -2
  57. package/dist/mcp/servers/agent/directToolsServer.js +19 -10
  58. package/dist/mcp/toolRegistry.js +4 -8
  59. package/dist/neurolink.d.ts +82 -27
  60. package/dist/neurolink.js +672 -713
  61. package/dist/providers/amazonBedrock.js +2 -2
  62. package/dist/providers/googleVertex.d.ts +3 -23
  63. package/dist/providers/googleVertex.js +14 -342
  64. package/dist/providers/openAI.d.ts +23 -0
  65. package/dist/providers/openAI.js +313 -6
  66. package/dist/providers/sagemaker/language-model.d.ts +2 -2
  67. package/dist/sdk/toolRegistration.js +18 -1
  68. package/dist/types/common.d.ts +98 -0
  69. package/dist/types/index.d.ts +2 -0
  70. package/dist/types/index.js +2 -0
  71. package/dist/types/streamTypes.d.ts +13 -6
  72. package/dist/types/taskClassificationTypes.d.ts +52 -0
  73. package/dist/types/taskClassificationTypes.js +5 -0
  74. package/dist/types/typeAliases.d.ts +3 -2
  75. package/dist/utils/modelRouter.d.ts +107 -0
  76. package/dist/utils/modelRouter.js +292 -0
  77. package/dist/utils/parameterValidation.js +6 -25
  78. package/dist/utils/promptRedaction.d.ts +29 -0
  79. package/dist/utils/promptRedaction.js +62 -0
  80. package/dist/utils/schemaConversion.d.ts +14 -0
  81. package/dist/utils/schemaConversion.js +140 -0
  82. package/dist/utils/taskClassificationUtils.d.ts +55 -0
  83. package/dist/utils/taskClassificationUtils.js +149 -0
  84. package/dist/utils/taskClassifier.d.ts +23 -0
  85. package/dist/utils/taskClassifier.js +94 -0
  86. package/dist/utils/transformationUtils.js +143 -5
  87. package/package.json +3 -2
@@ -4,8 +4,8 @@
4
4
  */
5
5
  export declare const DEFAULT_MAX_TOKENS: undefined;
6
6
  export declare const DEFAULT_TEMPERATURE = 0.7;
7
- export declare const DEFAULT_TIMEOUT = 30000;
8
- export declare const DEFAULT_MAX_STEPS = 5;
7
+ export declare const DEFAULT_TIMEOUT = 60000;
8
+ export declare const DEFAULT_MAX_STEPS = 200;
9
9
  export declare const STEP_LIMITS: {
10
10
  min: number;
11
11
  max: number;
@@ -31,49 +31,21 @@ export declare const PROVIDER_CONFIG: {
31
31
  };
32
32
  export declare const PROVIDER_MAX_TOKENS: {
33
33
  anthropic: {
34
- "claude-3-haiku-20240307": number;
35
- "claude-3-5-sonnet-20241022": number;
36
- "claude-3-opus-20240229": number;
37
- "claude-3-5-sonnet-20240620": number;
38
34
  default: number;
39
35
  };
40
36
  openai: {
41
- "gpt-4o": number;
42
- "gpt-4o-mini": number;
43
- "gpt-3.5-turbo": number;
44
- "gpt-4": number;
45
- "gpt-4-turbo": number;
46
37
  default: number;
47
38
  };
48
39
  "google-ai": {
49
- "gemini-1.5-pro": number;
50
- "gemini-1.5-flash": number;
51
- "gemini-2.5-pro": number;
52
- "gemini-2.5-flash": number;
53
- "gemini-pro": number;
54
40
  default: number;
55
41
  };
56
42
  vertex: {
57
- "gemini-1.5-pro": number;
58
- "gemini-1.5-flash": number;
59
- "gemini-2.5-pro": number;
60
- "gemini-2.5-flash": number;
61
- "claude-4.0-sonnet": number;
62
43
  default: number;
63
44
  };
64
45
  bedrock: {
65
- "anthropic.claude-3-sonnet-20240229-v1:0": number;
66
- "anthropic.claude-3-haiku-20240307-v1:0": number;
67
- "anthropic.claude-3-5-sonnet-20240620-v1:0": number;
68
46
  default: number;
69
47
  };
70
48
  azure: {
71
- "gpt-4o": number;
72
- "gpt-4o-mini": number;
73
- "gpt-4.1": number;
74
- "gpt-3.5-turbo": number;
75
- "gpt-4": number;
76
- "gpt-4-turbo": number;
77
49
  default: number;
78
50
  };
79
51
  ollama: {
@@ -5,12 +5,12 @@
5
5
  // Core AI Generation Defaults
6
6
  export const DEFAULT_MAX_TOKENS = undefined; // Unlimited by default - let providers decide their own limits
7
7
  export const DEFAULT_TEMPERATURE = 0.7;
8
- export const DEFAULT_TIMEOUT = 30000;
9
- export const DEFAULT_MAX_STEPS = 5; // Default multi-turn tool execution steps
8
+ export const DEFAULT_TIMEOUT = 60000;
9
+ export const DEFAULT_MAX_STEPS = 200;
10
10
  // Step execution limits
11
11
  export const STEP_LIMITS = {
12
12
  min: 1,
13
- max: 20,
13
+ max: 500,
14
14
  default: DEFAULT_MAX_STEPS,
15
15
  };
16
16
  // Specialized Use Case Defaults
@@ -33,68 +33,40 @@ export const PROVIDER_CONFIG = {
33
33
  temperature: 0.4,
34
34
  },
35
35
  };
36
- // Provider-specific maxTokens limits (discovered through testing)
36
+ // Provider-specific maxTokens limits
37
37
  export const PROVIDER_MAX_TOKENS = {
38
38
  anthropic: {
39
- "claude-3-haiku-20240307": 4096,
40
- "claude-3-5-sonnet-20241022": 4096,
41
- "claude-3-opus-20240229": 4096,
42
- "claude-3-5-sonnet-20240620": 4096,
43
- default: 4096, // Conservative default for Anthropic
39
+ default: 64000,
44
40
  },
45
41
  openai: {
46
- "gpt-4o": 16384,
47
- "gpt-4o-mini": 16384,
48
- "gpt-3.5-turbo": 4096,
49
- "gpt-4": 8192,
50
- "gpt-4-turbo": 4096,
51
- default: 8192, // OpenAI generally supports higher limits
42
+ default: 500000,
52
43
  },
53
44
  "google-ai": {
54
- "gemini-1.5-pro": 8192,
55
- "gemini-1.5-flash": 8192,
56
- "gemini-2.5-pro": 8192,
57
- "gemini-2.5-flash": 8192,
58
- "gemini-pro": 4096,
59
- default: 4096, // Conservative default due to 500 errors at high limits
45
+ default: 64000,
60
46
  },
61
47
  vertex: {
62
- "gemini-1.5-pro": 8192,
63
- "gemini-1.5-flash": 8192,
64
- "gemini-2.5-pro": 8192,
65
- "gemini-2.5-flash": 8192,
66
- "claude-4.0-sonnet": 4096,
67
- default: 4096,
48
+ default: 64000,
68
49
  },
69
50
  bedrock: {
70
- "anthropic.claude-3-sonnet-20240229-v1:0": 4096,
71
- "anthropic.claude-3-haiku-20240307-v1:0": 4096,
72
- "anthropic.claude-3-5-sonnet-20240620-v1:0": 4096,
73
- default: 4096,
51
+ default: 64000,
74
52
  },
75
53
  azure: {
76
- "gpt-4o": 16384,
77
- "gpt-4o-mini": 16384,
78
- "gpt-4.1": 16384,
79
- "gpt-3.5-turbo": 4096,
80
- "gpt-4": 8192,
81
- "gpt-4-turbo": 4096,
82
- default: 8192, // Azure OpenAI generally supports similar limits to OpenAI
54
+ default: 64000,
83
55
  },
84
56
  ollama: {
85
- default: 8192, // Ollama typically supports higher limits
57
+ default: 64000,
86
58
  },
87
59
  litellm: {
88
- default: 4096, // Conservative default
60
+ default: 500000,
89
61
  },
90
- default: 4096, // Safe default across all providers
62
+ default: 64000,
91
63
  };
92
64
  // CLI Validation Limits
93
65
  export const CLI_LIMITS = {
94
66
  maxTokens: {
95
67
  min: 1,
96
- max: 50000,
97
- default: undefined, // No default limit - unlimited by default
68
+ max: 64000,
69
+ default: DEFAULT_MAX_TOKENS,
98
70
  },
99
71
  temperature: {
100
72
  min: 0,
@@ -49,16 +49,33 @@ export class ProviderFactory {
49
49
  model = model || registration.defaultModel;
50
50
  }
51
51
  try {
52
+ if (typeof registration.constructor !== "function") {
53
+ throw new Error(`Invalid constructor for provider ${providerName}: not a function`);
54
+ }
52
55
  let result;
53
56
  try {
54
- // Try as async factory function first (most providers are async functions)
55
- result = await registration.constructor(model, providerName, sdk);
57
+ const factoryResult = registration.constructor(model, providerName, sdk);
58
+ // Handle both sync and async results
59
+ result =
60
+ factoryResult instanceof Promise
61
+ ? await factoryResult
62
+ : factoryResult;
56
63
  }
57
- catch {
58
- // Fallback to constructor - ensure parameters are maintained
59
- result = new registration.constructor(model, providerName, sdk);
64
+ catch (factoryError) {
65
+ if (registration.constructor.prototype &&
66
+ registration.constructor.prototype.constructor ===
67
+ registration.constructor) {
68
+ try {
69
+ result = new registration.constructor(model, providerName, sdk);
70
+ }
71
+ catch (constructorError) {
72
+ throw new Error(`Both factory function and constructor failed. Factory error: ${factoryError}. Constructor error: ${constructorError}`);
73
+ }
74
+ }
75
+ else {
76
+ throw factoryError;
77
+ }
60
78
  }
61
- // Return result (no need to await again if already awaited in try block)
62
79
  return result;
63
80
  }
64
81
  catch (error) {
package/dist/index.d.ts CHANGED
@@ -17,7 +17,8 @@ export { BedrockModels, OpenAIModels, VertexModels, DEFAULT_PROVIDER_CONFIGS, }
17
17
  export { getBestProvider, getAvailableProviders, isValidProvider, } from "./utils/providerUtils.js";
18
18
  export { dynamicModelProvider } from "./core/dynamicModels.js";
19
19
  export type { DynamicModelConfig, ModelRegistry } from "./types/modelTypes.js";
20
- export { NeuroLink } from "./neurolink.js";
20
+ import { NeuroLink } from "./neurolink.js";
21
+ export { NeuroLink };
21
22
  export type { ProviderStatus, MCPStatus } from "./neurolink.js";
22
23
  export type { MCPServerInfo } from "./types/mcpTypes.js";
23
24
  export type { NeuroLinkMiddleware, MiddlewareContext, MiddlewareFactoryOptions, MiddlewarePreset, MiddlewareConfig, } from "./types/middlewareTypes.js";
@@ -102,4 +103,4 @@ export type { TextGenerationOptions, TextGenerationResult, AnalyticsData, Evalua
102
103
  * console.log(result.content);
103
104
  * ```
104
105
  */
105
- export declare function generateText(options: import("./types/index.js").TextGenerationOptions): Promise<import("./types/index.js").TextGenerationResult>;
106
+ export declare function generateText(options: import("./core/types.js").TextGenerationOptions): Promise<import("./core/types.js").TextGenerationResult>;
package/dist/index.js CHANGED
@@ -17,7 +17,8 @@ export { getBestProvider, getAvailableProviders, isValidProvider, } from "./util
17
17
  // Dynamic Models exports
18
18
  export { dynamicModelProvider } from "./core/dynamicModels.js";
19
19
  // Main NeuroLink wrapper class and diagnostic types
20
- export { NeuroLink } from "./neurolink.js";
20
+ import { NeuroLink } from "./neurolink.js";
21
+ export { NeuroLink };
21
22
  export { MiddlewareFactory } from "./middleware/factory.js";
22
23
  // Version
23
24
  export const VERSION = "1.0.0";
@@ -127,7 +128,7 @@ export function getTelemetryStatus() {
127
128
  * ```
128
129
  */
129
130
  export async function generateText(options) {
130
- // Import neurolink instance to avoid circular dependencies
131
- const { neurolink } = await import("./neurolink.js");
131
+ // Create instance on-demand without auto-instantiation
132
+ const neurolink = new NeuroLink();
132
133
  return await neurolink.generateText(options);
133
134
  }
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Task Classification Configuration
3
+ * Contains patterns, keywords, and scoring weights for task classification
4
+ */
5
+ /**
6
+ * Regular expression patterns that indicate fast response tasks
7
+ */
8
+ export declare const FAST_PATTERNS: RegExp[];
9
+ /**
10
+ * Regular expression patterns that indicate reasoning tasks
11
+ */
12
+ export declare const REASONING_PATTERNS: RegExp[];
13
+ /**
14
+ * Keywords that indicate fast tasks regardless of context
15
+ */
16
+ export declare const FAST_KEYWORDS: string[];
17
+ /**
18
+ * Keywords that indicate reasoning tasks regardless of context
19
+ */
20
+ export declare const REASONING_KEYWORDS: string[];
21
+ /**
22
+ * Scoring weights for different classification factors
23
+ */
24
+ export declare const SCORING_WEIGHTS: {
25
+ readonly SHORT_PROMPT_BONUS: 2;
26
+ readonly LONG_PROMPT_BONUS: 1;
27
+ readonly PATTERN_MATCH_SCORE: 3;
28
+ readonly KEYWORD_MATCH_SCORE: 1;
29
+ readonly MULTIPLE_QUESTIONS_BONUS: 1;
30
+ readonly MULTI_SENTENCE_BONUS: 1;
31
+ readonly TECHNICAL_DOMAIN_BONUS: 1;
32
+ readonly SIMPLE_DEFINITION_BONUS: 2;
33
+ };
34
+ /**
35
+ * Classification thresholds and constraints
36
+ */
37
+ export declare const CLASSIFICATION_THRESHOLDS: {
38
+ readonly SHORT_PROMPT_LENGTH: 50;
39
+ readonly LONG_PROMPT_LENGTH: 200;
40
+ readonly SIMPLE_DEFINITION_LENGTH: 100;
41
+ readonly MIN_CONFIDENCE: 0.6;
42
+ readonly MAX_CONFIDENCE: 0.95;
43
+ readonly DEFAULT_CONFIDENCE: 0.5;
44
+ };
45
+ /**
46
+ * Domain-specific patterns for enhanced classification
47
+ */
48
+ export declare const DOMAIN_PATTERNS: {
49
+ readonly TECHNICAL: RegExp;
50
+ readonly SIMPLE_DEFINITION: RegExp;
51
+ };
@@ -0,0 +1,148 @@
1
+ /**
2
+ * Task Classification Configuration
3
+ * Contains patterns, keywords, and scoring weights for task classification
4
+ */
5
+ /**
6
+ * Regular expression patterns that indicate fast response tasks
7
+ */
8
+ export const FAST_PATTERNS = [
9
+ // Greetings and social
10
+ /^(hi|hello|hey|good morning|good afternoon|good evening)/i,
11
+ /^(thanks?|thank you|thx)/i,
12
+ /^(yes|no|ok|okay|sure|fine)/i,
13
+ // Simple questions
14
+ /^what is\s+\w+\??$/i,
15
+ /^how are you/i,
16
+ /^tell me about\s+\w+$/i,
17
+ // Simple requests
18
+ /^(list|show|display)\s+/i,
19
+ /^give me\s+/i,
20
+ /^can you\s+(help|assist)/i,
21
+ // Simple definitions
22
+ /^define\s+/i,
23
+ /^meaning of\s+/i,
24
+ /^what does\s+\w+\s+mean/i,
25
+ // Quick facts
26
+ /^when (is|was|did)/i,
27
+ /^where (is|was)/i,
28
+ /^who (is|was)/i,
29
+ // Simple translations
30
+ /^translate\s+["'].*["']\s+to\s+\w+/i,
31
+ /^how do you say\s+/i,
32
+ ];
33
+ /**
34
+ * Regular expression patterns that indicate reasoning tasks
35
+ */
36
+ export const REASONING_PATTERNS = [
37
+ // Analysis and comparison
38
+ /\b(analyz|compar|evaluat|assess|examin)\w*/i,
39
+ /\b(pros and cons|advantages and disadvantages)/i,
40
+ /\b(better|worse|best|worst)\b.*\b(than|versus|vs)\b/i,
41
+ // Problem solving
42
+ /\b(solve|solution|problem|issue|challenge)\b/i,
43
+ /\b(how to|step by step|strategy|approach)\b/i,
44
+ /\b(optimize|improve|enhance|maximize|minimize)\b/i,
45
+ // Planning and design
46
+ /\b(plan|design|architect|structure|framework)\b/i,
47
+ /\b(implement|develop|build|create|construct)\b/i,
48
+ /\b(roadmap|timeline|schedule|phases)\b/i,
49
+ // Complex questions
50
+ /\b(why|explain|reason|cause|effect|impact)\b/i,
51
+ /\b(implications|consequences|considerations)\b/i,
52
+ /\b(should I|would you recommend|what if)\b/i,
53
+ // Research and investigation
54
+ /\b(research|investigate|explore|discover)\b/i,
55
+ /\b(evidence|proof|validate|verify)\b/i,
56
+ /\b(trends|patterns|insights|conclusions)\b/i,
57
+ // Business and strategy
58
+ /\b(business|strategy|market|competitive|financial)\b/i,
59
+ /\b(ROI|revenue|profit|investment|budget)\b/i,
60
+ /\b(stakeholder|customer|user experience|UX)\b/i,
61
+ // Technical complexity
62
+ /\b(algorithm|architecture|system|infrastructure)\b/i,
63
+ /\b(performance|scalability|security|reliability)\b/i,
64
+ /\b(integration|API|database|server)\b/i,
65
+ ];
66
+ /**
67
+ * Keywords that indicate fast tasks regardless of context
68
+ */
69
+ export const FAST_KEYWORDS = [
70
+ "quick",
71
+ "simple",
72
+ "brief",
73
+ "short",
74
+ "summary",
75
+ "overview",
76
+ "definition",
77
+ "meaning",
78
+ "list",
79
+ "show",
80
+ "display",
81
+ "name",
82
+ "tell",
83
+ "what",
84
+ "when",
85
+ "where",
86
+ "who",
87
+ "how many",
88
+ "count",
89
+ ];
90
+ /**
91
+ * Keywords that indicate reasoning tasks regardless of context
92
+ */
93
+ export const REASONING_KEYWORDS = [
94
+ "complex",
95
+ "detailed",
96
+ "comprehensive",
97
+ "thorough",
98
+ "in-depth",
99
+ "analyze",
100
+ "compare",
101
+ "evaluate",
102
+ "assess",
103
+ "research",
104
+ "investigate",
105
+ "strategy",
106
+ "plan",
107
+ "design",
108
+ "solve",
109
+ "optimize",
110
+ "recommend",
111
+ "explain",
112
+ "why",
113
+ "justify",
114
+ "pros",
115
+ "cons",
116
+ "trade-offs",
117
+ ];
118
+ /**
119
+ * Scoring weights for different classification factors
120
+ */
121
+ export const SCORING_WEIGHTS = {
122
+ SHORT_PROMPT_BONUS: 2,
123
+ LONG_PROMPT_BONUS: 1,
124
+ PATTERN_MATCH_SCORE: 3,
125
+ KEYWORD_MATCH_SCORE: 1,
126
+ MULTIPLE_QUESTIONS_BONUS: 1,
127
+ MULTI_SENTENCE_BONUS: 1,
128
+ TECHNICAL_DOMAIN_BONUS: 1,
129
+ SIMPLE_DEFINITION_BONUS: 2,
130
+ };
131
+ /**
132
+ * Classification thresholds and constraints
133
+ */
134
+ export const CLASSIFICATION_THRESHOLDS = {
135
+ SHORT_PROMPT_LENGTH: 50,
136
+ LONG_PROMPT_LENGTH: 200,
137
+ SIMPLE_DEFINITION_LENGTH: 100,
138
+ MIN_CONFIDENCE: 0.6,
139
+ MAX_CONFIDENCE: 0.95,
140
+ DEFAULT_CONFIDENCE: 0.5,
141
+ };
142
+ /**
143
+ * Domain-specific patterns for enhanced classification
144
+ */
145
+ export const DOMAIN_PATTERNS = {
146
+ TECHNICAL: /\b(code|programming|development|software)\b/i,
147
+ SIMPLE_DEFINITION: /\b(definition|meaning|what is)\b/i,
148
+ };
@@ -34,6 +34,39 @@ export declare abstract class BaseProvider implements AIProvider {
34
34
  * When tools are involved, falls back to generate() with synthetic streaming
35
35
  */
36
36
  stream(optionsOrPrompt: StreamOptions | string, analysisSchema?: ValidationSchema): Promise<StreamResult>;
37
+ /**
38
+ * Prepare generation context including tools and model
39
+ */
40
+ private prepareGenerationContext;
41
+ /**
42
+ * Build messages array for generation
43
+ */
44
+ private buildMessages;
45
+ /**
46
+ * Execute the generation with AI SDK
47
+ */
48
+ private executeGeneration;
49
+ /**
50
+ * Log generation completion information
51
+ */
52
+ private logGenerationComplete;
53
+ /**
54
+ * Record performance metrics
55
+ */
56
+ private recordPerformanceMetrics;
57
+ /**
58
+ * Extract tool information from generation result
59
+ */
60
+ private extractToolInformation;
61
+ /**
62
+ * Format the enhanced result
63
+ */
64
+ private formatEnhancedResult;
65
+ /**
66
+ * Analyze AI response structure and log detailed debugging information
67
+ * Extracted from generate method to reduce complexity
68
+ */
69
+ private analyzeAIResponse;
37
70
  /**
38
71
  * Text generation method - implements AIProvider interface
39
72
  * Tools are always available unless explicitly disabled
@@ -85,12 +118,17 @@ export declare abstract class BaseProvider implements AIProvider {
85
118
  private isZodSchema;
86
119
  /**
87
120
  * Convert tool execution result from MCP format to standard format
121
+ * Handles tool failures gracefully to prevent stream termination
88
122
  */
89
123
  private convertToolResult;
90
124
  /**
91
125
  * Create a custom tool from tool definition
92
126
  */
93
127
  private createCustomToolFromDefinition;
128
+ /**
129
+ * Process direct tools with event emission wrapping
130
+ */
131
+ private processDirectTools;
94
132
  /**
95
133
  * Process custom tools from setupToolExecutor
96
134
  */
@@ -117,10 +155,9 @@ export declare abstract class BaseProvider implements AIProvider {
117
155
  */
118
156
  private calculateActualCost;
119
157
  /**
120
- * Convert MCP JSON Schema to Zod schema for AI SDK tools
121
- * Handles common MCP schema patterns safely
158
+ * Create a permissive Zod schema that accepts all parameters as-is
122
159
  */
123
- private convertMCPSchemaToZod;
160
+ private createPermissiveZodSchema;
124
161
  /**
125
162
  * Set session context for MCP tools
126
163
  */