@juspay/neurolink 4.2.0 → 5.1.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 +47 -2
- package/README.md +51 -60
- package/dist/chat/sse-handler.js +5 -4
- package/dist/chat/websocket-chat-handler.js +9 -9
- package/dist/cli/commands/mcp.js +1 -1
- package/dist/cli/commands/ollama.js +3 -3
- package/dist/cli/factories/command-factory.d.ts +14 -0
- package/dist/cli/factories/command-factory.js +129 -0
- package/dist/cli/index.js +27 -29
- package/dist/cli/utils/interactive-setup.js +2 -2
- package/dist/core/evaluation.d.ts +9 -9
- package/dist/core/evaluation.js +14 -14
- package/dist/core/types.d.ts +41 -48
- package/dist/core/types.js +1 -0
- package/dist/factories/compatibility-factory.d.ts +20 -0
- package/dist/factories/compatibility-factory.js +69 -0
- package/dist/factories/provider-generate-factory.d.ts +20 -0
- package/dist/factories/provider-generate-factory.js +87 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.js +3 -1
- package/dist/lib/chat/sse-handler.js +5 -4
- package/dist/lib/chat/websocket-chat-handler.js +9 -9
- package/dist/lib/core/evaluation.d.ts +9 -9
- package/dist/lib/core/evaluation.js +14 -14
- package/dist/lib/core/types.d.ts +41 -48
- package/dist/lib/core/types.js +1 -0
- package/dist/lib/factories/compatibility-factory.d.ts +20 -0
- package/dist/lib/factories/compatibility-factory.js +69 -0
- package/dist/lib/factories/provider-generate-factory.d.ts +20 -0
- package/dist/lib/factories/provider-generate-factory.js +87 -0
- package/dist/lib/index.d.ts +4 -2
- package/dist/lib/index.js +3 -1
- package/dist/lib/mcp/client.js +5 -5
- package/dist/lib/mcp/dynamic-orchestrator.js +8 -8
- package/dist/lib/mcp/external-client.js +2 -2
- package/dist/lib/mcp/factory.d.ts +1 -1
- package/dist/lib/mcp/factory.js +1 -1
- package/dist/lib/mcp/neurolink-mcp-client.js +10 -10
- package/dist/lib/mcp/orchestrator.js +4 -4
- package/dist/lib/mcp/servers/ai-providers/ai-analysis-tools.js +10 -10
- package/dist/lib/mcp/servers/ai-providers/ai-core-server.js +5 -5
- package/dist/lib/mcp/servers/ai-providers/ai-workflow-tools.d.ts +2 -2
- package/dist/lib/mcp/servers/ai-providers/ai-workflow-tools.js +16 -16
- package/dist/lib/neurolink.d.ts +21 -73
- package/dist/lib/neurolink.js +230 -119
- package/dist/lib/providers/agent-enhanced-provider.d.ts +12 -8
- package/dist/lib/providers/agent-enhanced-provider.js +87 -96
- package/dist/lib/providers/amazonBedrock.d.ts +17 -8
- package/dist/lib/providers/amazonBedrock.js +60 -30
- package/dist/lib/providers/anthropic.d.ts +14 -10
- package/dist/lib/providers/anthropic.js +84 -154
- package/dist/lib/providers/azureOpenAI.d.ts +9 -6
- package/dist/lib/providers/azureOpenAI.js +70 -159
- package/dist/lib/providers/function-calling-provider.d.ts +14 -12
- package/dist/lib/providers/function-calling-provider.js +114 -64
- package/dist/lib/providers/googleAIStudio.d.ts +12 -19
- package/dist/lib/providers/googleAIStudio.js +65 -34
- package/dist/lib/providers/googleVertexAI.d.ts +11 -15
- package/dist/lib/providers/googleVertexAI.js +146 -118
- package/dist/lib/providers/huggingFace.d.ts +10 -11
- package/dist/lib/providers/huggingFace.js +61 -24
- package/dist/lib/providers/mcp-provider.d.ts +13 -8
- package/dist/lib/providers/mcp-provider.js +59 -18
- package/dist/lib/providers/mistralAI.d.ts +14 -11
- package/dist/lib/providers/mistralAI.js +60 -29
- package/dist/lib/providers/ollama.d.ts +9 -8
- package/dist/lib/providers/ollama.js +134 -91
- package/dist/lib/providers/openAI.d.ts +11 -12
- package/dist/lib/providers/openAI.js +132 -97
- package/dist/lib/types/generate-types.d.ts +79 -0
- package/dist/lib/types/generate-types.js +1 -0
- package/dist/lib/types/stream-types.d.ts +83 -0
- package/dist/lib/types/stream-types.js +1 -0
- package/dist/lib/utils/providerUtils-fixed.js +1 -1
- package/dist/lib/utils/streaming-utils.d.ts +14 -2
- package/dist/lib/utils/streaming-utils.js +0 -3
- package/dist/mcp/client.js +5 -5
- package/dist/mcp/dynamic-orchestrator.js +8 -8
- package/dist/mcp/external-client.js +2 -2
- package/dist/mcp/factory.d.ts +1 -1
- package/dist/mcp/factory.js +1 -1
- package/dist/mcp/neurolink-mcp-client.js +10 -10
- package/dist/mcp/orchestrator.js +4 -4
- package/dist/mcp/servers/ai-providers/ai-analysis-tools.js +10 -10
- package/dist/mcp/servers/ai-providers/ai-core-server.js +5 -5
- package/dist/mcp/servers/ai-providers/ai-workflow-tools.d.ts +2 -2
- package/dist/mcp/servers/ai-providers/ai-workflow-tools.js +16 -16
- package/dist/neurolink.d.ts +21 -73
- package/dist/neurolink.js +230 -119
- package/dist/providers/agent-enhanced-provider.d.ts +12 -8
- package/dist/providers/agent-enhanced-provider.js +87 -95
- package/dist/providers/amazonBedrock.d.ts +17 -8
- package/dist/providers/amazonBedrock.js +60 -30
- package/dist/providers/anthropic.d.ts +14 -10
- package/dist/providers/anthropic.js +84 -154
- package/dist/providers/azureOpenAI.d.ts +9 -6
- package/dist/providers/azureOpenAI.js +70 -159
- package/dist/providers/function-calling-provider.d.ts +14 -12
- package/dist/providers/function-calling-provider.js +114 -64
- package/dist/providers/googleAIStudio.d.ts +12 -19
- package/dist/providers/googleAIStudio.js +65 -34
- package/dist/providers/googleVertexAI.d.ts +11 -15
- package/dist/providers/googleVertexAI.js +146 -118
- package/dist/providers/huggingFace.d.ts +10 -11
- package/dist/providers/huggingFace.js +61 -24
- package/dist/providers/mcp-provider.d.ts +13 -8
- package/dist/providers/mcp-provider.js +59 -18
- package/dist/providers/mistralAI.d.ts +14 -11
- package/dist/providers/mistralAI.js +60 -29
- package/dist/providers/ollama.d.ts +9 -8
- package/dist/providers/ollama.js +133 -90
- package/dist/providers/openAI.d.ts +11 -12
- package/dist/providers/openAI.js +132 -97
- package/dist/types/generate-types.d.ts +79 -0
- package/dist/types/generate-types.js +1 -0
- package/dist/types/stream-types.d.ts +83 -0
- package/dist/types/stream-types.js +1 -0
- package/dist/utils/providerUtils-fixed.js +1 -1
- package/dist/utils/streaming-utils.d.ts +14 -2
- package/dist/utils/streaming-utils.js +0 -3
- package/package.json +2 -3
- package/dist/cli/commands/agent-generate.d.ts +0 -1
- package/dist/cli/commands/agent-generate.js +0 -67
|
@@ -139,7 +139,7 @@ export class ExternalMCPClient extends EventEmitter {
|
|
|
139
139
|
// Transform MCP response to NeuroLink format
|
|
140
140
|
const result = {
|
|
141
141
|
success: !response.isError,
|
|
142
|
-
data: response.
|
|
142
|
+
data: response.text || response.result || response,
|
|
143
143
|
metadata: {
|
|
144
144
|
toolName,
|
|
145
145
|
serverId: this.config.name,
|
|
@@ -150,7 +150,7 @@ export class ExternalMCPClient extends EventEmitter {
|
|
|
150
150
|
},
|
|
151
151
|
};
|
|
152
152
|
if (response.isError) {
|
|
153
|
-
result.error = response.
|
|
153
|
+
result.error = response.text?.[0]?.text || "Tool execution failed";
|
|
154
154
|
}
|
|
155
155
|
logger.debug(`[External MCP] Tool ${toolName} executed in ${executionTime}ms`);
|
|
156
156
|
return result;
|
|
@@ -134,7 +134,7 @@ export interface MCPServerConfig {
|
|
|
134
134
|
* });
|
|
135
135
|
*
|
|
136
136
|
* aiCoreServer.registerTool({
|
|
137
|
-
* name: 'generate
|
|
137
|
+
* name: 'generate',
|
|
138
138
|
* description: 'Generate text using AI providers',
|
|
139
139
|
* execute: async (params, context) => {
|
|
140
140
|
* // Tool implementation
|
package/dist/lib/mcp/factory.js
CHANGED
|
@@ -50,7 +50,7 @@ const ServerConfigSchema = z.object({
|
|
|
50
50
|
* });
|
|
51
51
|
*
|
|
52
52
|
* aiCoreServer.registerTool({
|
|
53
|
-
* name: 'generate
|
|
53
|
+
* name: 'generate',
|
|
54
54
|
* description: 'Generate text using AI providers',
|
|
55
55
|
* execute: async (params, context) => {
|
|
56
56
|
* // Tool implementation
|
|
@@ -94,14 +94,14 @@ Examples:
|
|
|
94
94
|
|
|
95
95
|
Response (JSON object only):`;
|
|
96
96
|
try {
|
|
97
|
-
const response = await this.provider.
|
|
97
|
+
const response = await this.provider.generate({
|
|
98
98
|
prompt: extractionPrompt,
|
|
99
99
|
temperature: 0,
|
|
100
100
|
maxTokens: 200,
|
|
101
101
|
});
|
|
102
|
-
if (response?.
|
|
102
|
+
if (response?.content) {
|
|
103
103
|
// Extract JSON object from response
|
|
104
|
-
const match = response.
|
|
104
|
+
const match = response.content.match(/\{([^}]*)\}/);
|
|
105
105
|
if (match) {
|
|
106
106
|
try {
|
|
107
107
|
const params = JSON.parse(match[0]);
|
|
@@ -153,14 +153,14 @@ Examples:
|
|
|
153
153
|
|
|
154
154
|
Response (JSON array only):`;
|
|
155
155
|
try {
|
|
156
|
-
const response = await this.provider.
|
|
156
|
+
const response = await this.provider.generate({
|
|
157
157
|
prompt: analysisPrompt,
|
|
158
158
|
temperature: 0,
|
|
159
159
|
maxTokens: 200,
|
|
160
160
|
});
|
|
161
|
-
if (response?.
|
|
161
|
+
if (response?.content) {
|
|
162
162
|
// Extract JSON array from response
|
|
163
|
-
const match = response.
|
|
163
|
+
const match = response.content.match(/\[([^\]]*)\]/);
|
|
164
164
|
if (match) {
|
|
165
165
|
try {
|
|
166
166
|
const toolNames = JSON.parse(match[0]);
|
|
@@ -317,8 +317,8 @@ Response (JSON array only):`;
|
|
|
317
317
|
async generateResponse(prompt, toolResults) {
|
|
318
318
|
// If no tools were used, generate regular response
|
|
319
319
|
if (toolResults.length === 0) {
|
|
320
|
-
const response = await this.provider.
|
|
321
|
-
return response?.
|
|
320
|
+
const response = await this.provider.generate({ prompt });
|
|
321
|
+
return response?.content || "";
|
|
322
322
|
}
|
|
323
323
|
// Extract human-readable results from tool executions
|
|
324
324
|
const toolResultsText = toolResults
|
|
@@ -379,12 +379,12 @@ Tool results: ${toolResultsText}
|
|
|
379
379
|
|
|
380
380
|
Please provide a natural response based on the tool results.`;
|
|
381
381
|
// Generate final response
|
|
382
|
-
const response = await this.provider.
|
|
382
|
+
const response = await this.provider.generate({
|
|
383
383
|
prompt: enhancedPrompt,
|
|
384
384
|
temperature: 0.7,
|
|
385
385
|
maxTokens: DEFAULT_MAX_TOKENS,
|
|
386
386
|
});
|
|
387
|
-
return response?.
|
|
387
|
+
return response?.content || toolResultsText;
|
|
388
388
|
}
|
|
389
389
|
/**
|
|
390
390
|
* Send a prompt and automatically execute any needed tools
|
|
@@ -303,8 +303,8 @@ export class MCPOrchestrator {
|
|
|
303
303
|
}
|
|
304
304
|
// Step 2: Text generation
|
|
305
305
|
steps.push({
|
|
306
|
-
stepId: "generate
|
|
307
|
-
toolName: "generate
|
|
306
|
+
stepId: "generate",
|
|
307
|
+
toolName: "generate",
|
|
308
308
|
params: {
|
|
309
309
|
prompt,
|
|
310
310
|
provider: options.provider,
|
|
@@ -324,7 +324,7 @@ export class MCPOrchestrator {
|
|
|
324
324
|
params: {
|
|
325
325
|
/* tool-specific params */
|
|
326
326
|
},
|
|
327
|
-
dependsOn: ["generate
|
|
327
|
+
dependsOn: ["generate"],
|
|
328
328
|
});
|
|
329
329
|
}
|
|
330
330
|
}
|
|
@@ -336,7 +336,7 @@ export class MCPOrchestrator {
|
|
|
336
336
|
});
|
|
337
337
|
const executionTime = Date.now() - startTime;
|
|
338
338
|
// Extract text generation result
|
|
339
|
-
const textResult = pipelineResult.results.get("generate
|
|
339
|
+
const textResult = pipelineResult.results.get("generate");
|
|
340
340
|
const providerResult = pipelineResult.results.get("select-provider");
|
|
341
341
|
if (!textResult || !textResult.success) {
|
|
342
342
|
throw new Error("Text generation failed");
|
|
@@ -108,15 +108,15 @@ export const analyzeAIUsageTool = {
|
|
|
108
108
|
- "analysis" should contain: timeRange, totalRequests, totalTokens, and a "providers" object.
|
|
109
109
|
- "insights" should contain: mostUsedProvider, avgCostPerToken, peakUsageHours, costOptimizationPotential, and an array of "recommendations".
|
|
110
110
|
`;
|
|
111
|
-
const result = await provider.
|
|
111
|
+
const result = await provider.generate({
|
|
112
112
|
prompt: analysisPrompt,
|
|
113
113
|
maxTokens: 800,
|
|
114
114
|
temperature: 0.5,
|
|
115
115
|
});
|
|
116
|
-
if (!result || !result.
|
|
116
|
+
if (!result || !result.content) {
|
|
117
117
|
throw new Error("AI provider returned no result for usage analysis.");
|
|
118
118
|
}
|
|
119
|
-
const parsedData = JSON.parse(result.
|
|
119
|
+
const parsedData = JSON.parse(result.content);
|
|
120
120
|
const executionTime = Date.now() - startTime;
|
|
121
121
|
return {
|
|
122
122
|
success: true,
|
|
@@ -190,8 +190,8 @@ export const benchmarkProviderPerformanceTool = {
|
|
|
190
190
|
for (const prompt of testPrompts) {
|
|
191
191
|
for (let i = 0; i < params.iterations; i++) {
|
|
192
192
|
const testStartTime = Date.now();
|
|
193
|
-
const result = await provider.
|
|
194
|
-
prompt,
|
|
193
|
+
const result = await provider.generate({
|
|
194
|
+
prompt: prompt,
|
|
195
195
|
maxTokens: params.maxTokens,
|
|
196
196
|
});
|
|
197
197
|
if (result && result.usage) {
|
|
@@ -274,7 +274,7 @@ export const optimizePromptParametersTool = {
|
|
|
274
274
|
const optimizationResults = [];
|
|
275
275
|
const temperatures = [0.2, 0.7, 1.0]; // Test a range of temperatures
|
|
276
276
|
for (const temp of temperatures) {
|
|
277
|
-
const result = await provider.
|
|
277
|
+
const result = await provider.generate({
|
|
278
278
|
prompt: params.prompt,
|
|
279
279
|
temperature: temp,
|
|
280
280
|
maxTokens: params.targetLength || 250,
|
|
@@ -282,7 +282,7 @@ export const optimizePromptParametersTool = {
|
|
|
282
282
|
if (result) {
|
|
283
283
|
optimizationResults.push({
|
|
284
284
|
parameters: { temperature: temp },
|
|
285
|
-
output: result.
|
|
285
|
+
output: result.content,
|
|
286
286
|
usage: result.usage,
|
|
287
287
|
});
|
|
288
288
|
}
|
|
@@ -300,14 +300,14 @@ export const optimizePromptParametersTool = {
|
|
|
300
300
|
Determine which set of parameters is optimal and provide a recommendation.
|
|
301
301
|
Return a valid JSON object with keys: "optimalParameters", "reasoning", "recommendations".
|
|
302
302
|
`;
|
|
303
|
-
const analysisResult = await analysisProvider.
|
|
303
|
+
const analysisResult = await analysisProvider.generate({
|
|
304
304
|
prompt: analysisPrompt,
|
|
305
305
|
maxTokens: 500,
|
|
306
306
|
});
|
|
307
|
-
if (!analysisResult || !analysisResult.
|
|
307
|
+
if (!analysisResult || !analysisResult.content) {
|
|
308
308
|
throw new Error("Optimization analysis failed.");
|
|
309
309
|
}
|
|
310
|
-
const parsedAnalysis = JSON.parse(analysisResult.
|
|
310
|
+
const parsedAnalysis = JSON.parse(analysisResult.content);
|
|
311
311
|
const executionTime = Date.now() - startTime;
|
|
312
312
|
return {
|
|
313
313
|
success: true,
|
|
@@ -75,7 +75,7 @@ const ProviderSelectionSchema = z.object({
|
|
|
75
75
|
* Core tool that leverages existing AIProviderFactory for text generation
|
|
76
76
|
*/
|
|
77
77
|
aiCoreServer.registerTool({
|
|
78
|
-
name: "generate
|
|
78
|
+
name: "generate",
|
|
79
79
|
description: "Generate text using AI providers with automatic fallback and provider selection",
|
|
80
80
|
category: "text-generation",
|
|
81
81
|
inputSchema: TextGenerationSchema,
|
|
@@ -88,7 +88,7 @@ aiCoreServer.registerTool({
|
|
|
88
88
|
const selectedProvider = params.provider || (await getBestProvider(params.provider));
|
|
89
89
|
const provider = await AIProviderFactory.createBestProvider(selectedProvider);
|
|
90
90
|
// Generate text using existing NeuroLink patterns
|
|
91
|
-
const result = await provider.
|
|
91
|
+
const result = await provider.generate({
|
|
92
92
|
prompt: params.prompt,
|
|
93
93
|
model: params.model,
|
|
94
94
|
temperature: params.temperature,
|
|
@@ -103,7 +103,7 @@ aiCoreServer.registerTool({
|
|
|
103
103
|
return {
|
|
104
104
|
success: true,
|
|
105
105
|
data: {
|
|
106
|
-
text: result.
|
|
106
|
+
text: result.content,
|
|
107
107
|
model: params.model || "default",
|
|
108
108
|
provider: selectedProvider,
|
|
109
109
|
generatedAt: new Date().toISOString(),
|
|
@@ -115,7 +115,7 @@ aiCoreServer.registerTool({
|
|
|
115
115
|
executionTime,
|
|
116
116
|
},
|
|
117
117
|
metadata: {
|
|
118
|
-
toolName: "generate
|
|
118
|
+
toolName: "generate",
|
|
119
119
|
serverId: "neurolink-ai-core",
|
|
120
120
|
sessionId: context.sessionId,
|
|
121
121
|
timestamp: Date.now(),
|
|
@@ -131,7 +131,7 @@ aiCoreServer.registerTool({
|
|
|
131
131
|
success: false,
|
|
132
132
|
error: errorMessage,
|
|
133
133
|
metadata: {
|
|
134
|
-
toolName: "generate
|
|
134
|
+
toolName: "generate",
|
|
135
135
|
serverId: "neurolink-ai-core",
|
|
136
136
|
sessionId: context.sessionId,
|
|
137
137
|
timestamp: Date.now(),
|
|
@@ -88,14 +88,14 @@ export declare const workflowToolSchemas: {
|
|
|
88
88
|
}, "strip", z.ZodTypeAny, {
|
|
89
89
|
aiOutput: string;
|
|
90
90
|
expectedBehavior: string;
|
|
91
|
-
outputType: "
|
|
91
|
+
outputType: "text" | "code" | "conversation" | "structured-data";
|
|
92
92
|
includeFixSuggestions: boolean;
|
|
93
93
|
context?: string | undefined;
|
|
94
94
|
}, {
|
|
95
95
|
aiOutput: string;
|
|
96
96
|
expectedBehavior: string;
|
|
97
97
|
context?: string | undefined;
|
|
98
|
-
outputType?: "
|
|
98
|
+
outputType?: "text" | "code" | "conversation" | "structured-data" | undefined;
|
|
99
99
|
includeFixSuggestions?: boolean | undefined;
|
|
100
100
|
}>;
|
|
101
101
|
};
|
|
@@ -144,16 +144,16 @@ Return ONLY a valid JSON object with this exact structure:
|
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
Generate 3-5 comprehensive test cases covering the requested types.`;
|
|
147
|
-
const result = await provider.
|
|
148
|
-
prompt,
|
|
147
|
+
const result = await provider.generate({
|
|
148
|
+
prompt: prompt,
|
|
149
149
|
maxTokens: Math.floor(DEFAULT_MAX_TOKENS * 1.2),
|
|
150
150
|
temperature: 0.3, // Lower temperature for more consistent structured output
|
|
151
151
|
});
|
|
152
|
-
if (!result || !result.
|
|
152
|
+
if (!result || !result.content) {
|
|
153
153
|
throw new Error("AI provider returned no result for test case generation.");
|
|
154
154
|
}
|
|
155
155
|
// Parse AI response
|
|
156
|
-
const aiResponse = JSON.parse(result.
|
|
156
|
+
const aiResponse = JSON.parse(result.content);
|
|
157
157
|
const testCases = aiResponse.testCases || [];
|
|
158
158
|
const executionTime = Date.now() - startTime;
|
|
159
159
|
const responseData = {
|
|
@@ -250,16 +250,16 @@ Return ONLY a valid JSON object with this exact structure:
|
|
|
250
250
|
}
|
|
251
251
|
|
|
252
252
|
Focus on real, actionable improvements based on the specified objectives.`;
|
|
253
|
-
const result = await provider.
|
|
254
|
-
prompt,
|
|
253
|
+
const result = await provider.generate({
|
|
254
|
+
prompt: prompt,
|
|
255
255
|
maxTokens: DEFAULT_MAX_TOKENS,
|
|
256
256
|
temperature: 0.2, // Very low temperature for consistent refactoring
|
|
257
257
|
});
|
|
258
|
-
if (!result || !result.
|
|
258
|
+
if (!result || !result.content) {
|
|
259
259
|
throw new Error("AI provider returned no result for code refactoring.");
|
|
260
260
|
}
|
|
261
261
|
// Parse AI response
|
|
262
|
-
const aiResponse = JSON.parse(result.
|
|
262
|
+
const aiResponse = JSON.parse(result.content);
|
|
263
263
|
const executionTime = Date.now() - startTime;
|
|
264
264
|
const responseData = {
|
|
265
265
|
refactoredCode: aiResponse.refactoredCode || code,
|
|
@@ -358,16 +358,16 @@ Return ONLY a valid JSON object with this exact structure:
|
|
|
358
358
|
}
|
|
359
359
|
|
|
360
360
|
Focus on creating accurate, useful documentation that explains the code's purpose, parameters, return values, and usage patterns.`;
|
|
361
|
-
const result = await provider.
|
|
362
|
-
prompt,
|
|
361
|
+
const result = await provider.generate({
|
|
362
|
+
prompt: prompt,
|
|
363
363
|
maxTokens: Math.floor(DEFAULT_MAX_TOKENS * 1.2),
|
|
364
364
|
temperature: 0.3, // Moderate temperature for creative but structured documentation
|
|
365
365
|
});
|
|
366
|
-
if (!result || !result.
|
|
366
|
+
if (!result || !result.content) {
|
|
367
367
|
throw new Error("AI provider returned no result for documentation generation.");
|
|
368
368
|
}
|
|
369
369
|
// Parse AI response
|
|
370
|
-
const aiResponse = JSON.parse(result.
|
|
370
|
+
const aiResponse = JSON.parse(result.content);
|
|
371
371
|
const executionTime = Date.now() - startTime;
|
|
372
372
|
const responseData = {
|
|
373
373
|
documentation: aiResponse.documentation || "Documentation generated successfully",
|
|
@@ -483,16 +483,16 @@ Return ONLY a valid JSON object with this exact structure:
|
|
|
483
483
|
}
|
|
484
484
|
|
|
485
485
|
Provide thorough, actionable analysis focused on improving AI output quality.`;
|
|
486
|
-
const result = await provider.
|
|
487
|
-
prompt,
|
|
486
|
+
const result = await provider.generate({
|
|
487
|
+
prompt: prompt,
|
|
488
488
|
maxTokens: DEFAULT_MAX_TOKENS,
|
|
489
489
|
temperature: 0.4, // Moderate temperature for analytical thinking
|
|
490
490
|
});
|
|
491
|
-
if (!result || !result.
|
|
491
|
+
if (!result || !result.content) {
|
|
492
492
|
throw new Error("AI provider returned no result for output debugging.");
|
|
493
493
|
}
|
|
494
494
|
// Parse AI response
|
|
495
|
-
const aiResponse = JSON.parse(result.
|
|
495
|
+
const aiResponse = JSON.parse(result.content);
|
|
496
496
|
const executionTime = Date.now() - startTime;
|
|
497
497
|
const responseData = {
|
|
498
498
|
issues: aiResponse.issues || [],
|
package/dist/lib/neurolink.d.ts
CHANGED
|
@@ -4,66 +4,9 @@
|
|
|
4
4
|
* Enhanced AI provider system with natural MCP tool access.
|
|
5
5
|
* Uses real MCP infrastructure for tool discovery and execution.
|
|
6
6
|
*/
|
|
7
|
-
import type { AIProviderName } from "./core/types.js";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
provider?: "openai" | "bedrock" | "vertex" | "anthropic" | "azure" | "google-ai" | "huggingface" | "ollama" | "mistral" | "auto";
|
|
11
|
-
model?: string;
|
|
12
|
-
temperature?: number;
|
|
13
|
-
maxTokens?: number;
|
|
14
|
-
systemPrompt?: string;
|
|
15
|
-
schema?: any;
|
|
16
|
-
timeout?: number | string;
|
|
17
|
-
disableTools?: boolean;
|
|
18
|
-
enableAnalytics?: boolean;
|
|
19
|
-
enableEvaluation?: boolean;
|
|
20
|
-
context?: Record<string, any>;
|
|
21
|
-
evaluationDomain?: string;
|
|
22
|
-
toolUsageContext?: string;
|
|
23
|
-
conversationHistory?: Array<{
|
|
24
|
-
role: string;
|
|
25
|
-
content: string;
|
|
26
|
-
}>;
|
|
27
|
-
}
|
|
28
|
-
export interface StreamTextOptions {
|
|
29
|
-
prompt: string;
|
|
30
|
-
provider?: "openai" | "bedrock" | "vertex" | "anthropic" | "azure" | "google-ai" | "huggingface" | "ollama" | "mistral" | "auto";
|
|
31
|
-
model?: string;
|
|
32
|
-
temperature?: number;
|
|
33
|
-
maxTokens?: number;
|
|
34
|
-
systemPrompt?: string;
|
|
35
|
-
schema?: any;
|
|
36
|
-
timeout?: number | string;
|
|
37
|
-
disableTools?: boolean;
|
|
38
|
-
enableAnalytics?: boolean;
|
|
39
|
-
enableEvaluation?: boolean;
|
|
40
|
-
context?: Record<string, any>;
|
|
41
|
-
}
|
|
42
|
-
export interface TextGenerationResult {
|
|
43
|
-
content: string;
|
|
44
|
-
provider?: string;
|
|
45
|
-
model?: string;
|
|
46
|
-
usage?: {
|
|
47
|
-
promptTokens?: number;
|
|
48
|
-
completionTokens?: number;
|
|
49
|
-
totalTokens?: number;
|
|
50
|
-
};
|
|
51
|
-
responseTime?: number;
|
|
52
|
-
toolsUsed?: string[];
|
|
53
|
-
toolExecutions?: Array<{
|
|
54
|
-
toolName: string;
|
|
55
|
-
executionTime: number;
|
|
56
|
-
success: boolean;
|
|
57
|
-
serverId?: string;
|
|
58
|
-
}>;
|
|
59
|
-
enhancedWithTools?: boolean;
|
|
60
|
-
availableTools?: Array<{
|
|
61
|
-
name: string;
|
|
62
|
-
description: string;
|
|
63
|
-
server: string;
|
|
64
|
-
category?: string;
|
|
65
|
-
}>;
|
|
66
|
-
}
|
|
7
|
+
import type { AIProviderName, TextGenerationOptions, TextGenerationResult } from "./core/types.js";
|
|
8
|
+
import type { GenerateOptions, GenerateResult } from "./types/generate-types.js";
|
|
9
|
+
import type { StreamOptions, StreamResult } from "./types/stream-types.js";
|
|
67
10
|
export declare class NeuroLink {
|
|
68
11
|
private mcpInitialized;
|
|
69
12
|
private contextManager;
|
|
@@ -78,26 +21,37 @@ export declare class NeuroLink {
|
|
|
78
21
|
*/
|
|
79
22
|
private doIsolatedMCPInitialization;
|
|
80
23
|
/**
|
|
81
|
-
* Generate
|
|
82
|
-
*
|
|
24
|
+
* PRIMARY METHOD: Generate content using AI (recommended for new code)
|
|
25
|
+
* Future-ready for multi-modal capabilities with current text focus
|
|
26
|
+
*/
|
|
27
|
+
generate(options: GenerateOptions): Promise<GenerateResult>;
|
|
28
|
+
/**
|
|
29
|
+
* BACKWARD COMPATIBILITY: Legacy generateText method
|
|
30
|
+
* Internally calls generate() and converts result format
|
|
83
31
|
*/
|
|
84
32
|
generateText(options: TextGenerationOptions): Promise<TextGenerationResult>;
|
|
85
33
|
/**
|
|
86
34
|
* Generate text with real MCP tool integration using automatic detection
|
|
87
35
|
*/
|
|
88
|
-
private
|
|
36
|
+
private generateWithTools;
|
|
89
37
|
/**
|
|
90
38
|
* Regular text generation (existing logic)
|
|
91
39
|
*/
|
|
92
|
-
private
|
|
40
|
+
private generateRegular;
|
|
93
41
|
/**
|
|
94
42
|
* Create tool-aware system prompt that informs AI about available tools
|
|
95
43
|
*/
|
|
96
44
|
private createToolAwareSystemPrompt;
|
|
97
45
|
/**
|
|
98
|
-
*
|
|
46
|
+
* PRIMARY METHOD: Stream content using AI (recommended for new code)
|
|
47
|
+
* Future-ready for multi-modal capabilities with current text focus
|
|
48
|
+
*/
|
|
49
|
+
stream(options: StreamOptions): Promise<StreamResult>;
|
|
50
|
+
/**
|
|
51
|
+
* BACKWARD COMPATIBILITY: Legacy streamText method
|
|
52
|
+
* Internally calls stream() and converts result format
|
|
99
53
|
*/
|
|
100
|
-
|
|
54
|
+
streamText(options: TextGenerationOptions): Promise<AsyncIterable<{
|
|
101
55
|
content: string;
|
|
102
56
|
}>>;
|
|
103
57
|
/**
|
|
@@ -171,13 +125,7 @@ export declare class NeuroLink {
|
|
|
171
125
|
timeout?: number;
|
|
172
126
|
}): Promise<void>;
|
|
173
127
|
/**
|
|
174
|
-
*
|
|
175
|
-
* @param options - Text generation options
|
|
176
|
-
* @returns Promise resolving to text generation result
|
|
177
|
-
*/
|
|
178
|
-
generate(options: TextGenerationOptions): Promise<TextGenerationResult>;
|
|
179
|
-
/**
|
|
180
|
-
* Short alias for generateText() - CLI-SDK consistency
|
|
128
|
+
* Short alias for generate() - CLI-SDK consistency
|
|
181
129
|
* @param options - Text generation options
|
|
182
130
|
* @returns Promise resolving to text generation result
|
|
183
131
|
*/
|