@juspay/neurolink 5.0.0 → 5.2.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 +20 -7
- package/README.md +160 -172
- package/dist/agent/direct-tools.d.ts +6 -6
- package/dist/chat/sse-handler.js +5 -4
- package/dist/chat/websocket-chat-handler.js +9 -9
- package/dist/cli/commands/config.d.ts +3 -3
- package/dist/cli/commands/mcp.js +9 -8
- package/dist/cli/commands/ollama.js +3 -3
- package/dist/cli/factories/command-factory.d.ts +18 -0
- package/dist/cli/factories/command-factory.js +183 -0
- package/dist/cli/index.js +105 -157
- package/dist/cli/utils/interactive-setup.js +2 -2
- package/dist/core/base-provider.d.ts +423 -0
- package/dist/core/base-provider.js +365 -0
- package/dist/core/constants.d.ts +1 -1
- package/dist/core/constants.js +1 -1
- package/dist/core/dynamic-models.d.ts +6 -6
- package/dist/core/evaluation.d.ts +19 -80
- package/dist/core/evaluation.js +185 -484
- package/dist/core/factory.d.ts +3 -3
- package/dist/core/factory.js +31 -91
- package/dist/core/service-registry.d.ts +47 -0
- package/dist/core/service-registry.js +112 -0
- package/dist/core/types.d.ts +49 -49
- 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-factory.d.ts +72 -0
- package/dist/factories/provider-factory.js +144 -0
- package/dist/factories/provider-generate-factory.d.ts +20 -0
- package/dist/factories/provider-generate-factory.js +87 -0
- package/dist/factories/provider-registry.d.ts +38 -0
- package/dist/factories/provider-registry.js +107 -0
- package/dist/index.d.ts +8 -5
- package/dist/index.js +5 -5
- package/dist/lib/agent/direct-tools.d.ts +6 -6
- package/dist/lib/chat/sse-handler.js +5 -4
- package/dist/lib/chat/websocket-chat-handler.js +9 -9
- package/dist/lib/core/base-provider.d.ts +423 -0
- package/dist/lib/core/base-provider.js +365 -0
- package/dist/lib/core/constants.d.ts +1 -1
- package/dist/lib/core/constants.js +1 -1
- package/dist/lib/core/dynamic-models.d.ts +6 -6
- package/dist/lib/core/evaluation.d.ts +19 -80
- package/dist/lib/core/evaluation.js +185 -484
- package/dist/lib/core/factory.d.ts +3 -3
- package/dist/lib/core/factory.js +30 -91
- package/dist/lib/core/service-registry.d.ts +47 -0
- package/dist/lib/core/service-registry.js +112 -0
- package/dist/lib/core/types.d.ts +49 -49
- 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-factory.d.ts +72 -0
- package/dist/lib/factories/provider-factory.js +144 -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/factories/provider-registry.d.ts +38 -0
- package/dist/lib/factories/provider-registry.js +107 -0
- package/dist/lib/index.d.ts +8 -5
- package/dist/lib/index.js +5 -5
- package/dist/lib/mcp/client.js +5 -5
- package/dist/lib/mcp/config.js +28 -3
- 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/function-calling.js +1 -1
- package/dist/lib/mcp/initialize-tools.d.ts +1 -1
- package/dist/lib/mcp/initialize-tools.js +45 -1
- package/dist/lib/mcp/initialize.js +16 -6
- package/dist/lib/mcp/neurolink-mcp-client.js +10 -10
- package/dist/lib/mcp/orchestrator.js +4 -4
- package/dist/lib/mcp/servers/agent/direct-tools-server.d.ts +8 -0
- package/dist/lib/mcp/servers/agent/direct-tools-server.js +109 -0
- package/dist/lib/mcp/servers/ai-providers/ai-analysis-tools.js +10 -10
- package/dist/lib/mcp/servers/ai-providers/ai-core-server.js +8 -6
- 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/mcp/unified-registry.d.ts +4 -0
- package/dist/lib/mcp/unified-registry.js +42 -9
- package/dist/lib/neurolink.d.ts +161 -174
- package/dist/lib/neurolink.js +723 -397
- package/dist/lib/providers/amazon-bedrock.d.ts +32 -0
- package/dist/lib/providers/amazon-bedrock.js +143 -0
- package/dist/lib/providers/analytics-helper.js +7 -4
- package/dist/lib/providers/anthropic-baseprovider.d.ts +23 -0
- package/dist/lib/providers/anthropic-baseprovider.js +114 -0
- package/dist/lib/providers/anthropic.d.ts +19 -39
- package/dist/lib/providers/anthropic.js +84 -378
- package/dist/lib/providers/azure-openai.d.ts +20 -0
- package/dist/lib/providers/azure-openai.js +89 -0
- 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/google-ai-studio.d.ts +23 -0
- package/dist/lib/providers/google-ai-studio.js +107 -0
- package/dist/lib/providers/google-vertex.d.ts +47 -0
- package/dist/lib/providers/google-vertex.js +205 -0
- package/dist/lib/providers/huggingFace.d.ts +33 -27
- package/dist/lib/providers/huggingFace.js +103 -400
- package/dist/lib/providers/index.d.ts +9 -9
- package/dist/lib/providers/index.js +9 -9
- package/dist/lib/providers/mcp-provider.d.ts +13 -8
- package/dist/lib/providers/mcp-provider.js +63 -18
- package/dist/lib/providers/mistral.d.ts +42 -0
- package/dist/lib/providers/mistral.js +160 -0
- package/dist/lib/providers/ollama.d.ts +52 -35
- package/dist/lib/providers/ollama.js +297 -477
- package/dist/lib/providers/openAI.d.ts +21 -21
- package/dist/lib/providers/openAI.js +81 -245
- package/dist/lib/sdk/tool-extension.d.ts +181 -0
- package/dist/lib/sdk/tool-extension.js +283 -0
- package/dist/lib/sdk/tool-registration.d.ts +95 -0
- package/dist/lib/sdk/tool-registration.js +167 -0
- package/dist/lib/types/generate-types.d.ts +80 -0
- package/dist/lib/types/generate-types.js +1 -0
- package/dist/lib/types/mcp-types.d.ts +116 -0
- package/dist/lib/types/mcp-types.js +5 -0
- package/dist/lib/types/stream-types.d.ts +95 -0
- package/dist/lib/types/stream-types.js +1 -0
- package/dist/lib/types/universal-provider-options.d.ts +87 -0
- package/dist/lib/types/universal-provider-options.js +53 -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/config.js +28 -3
- 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/function-calling.js +1 -1
- package/dist/mcp/initialize-tools.d.ts +1 -1
- package/dist/mcp/initialize-tools.js +45 -1
- package/dist/mcp/initialize.js +16 -6
- package/dist/mcp/neurolink-mcp-client.js +10 -10
- package/dist/mcp/orchestrator.js +4 -4
- package/dist/mcp/servers/agent/direct-tools-server.d.ts +8 -0
- package/dist/mcp/servers/agent/direct-tools-server.js +109 -0
- package/dist/mcp/servers/ai-providers/ai-analysis-tools.js +10 -10
- package/dist/mcp/servers/ai-providers/ai-core-server.js +8 -6
- 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/mcp/unified-registry.d.ts +4 -0
- package/dist/mcp/unified-registry.js +42 -9
- package/dist/neurolink.d.ts +161 -174
- package/dist/neurolink.js +723 -397
- package/dist/providers/amazon-bedrock.d.ts +32 -0
- package/dist/providers/amazon-bedrock.js +143 -0
- package/dist/providers/analytics-helper.js +7 -4
- package/dist/providers/anthropic-baseprovider.d.ts +23 -0
- package/dist/providers/anthropic-baseprovider.js +114 -0
- package/dist/providers/anthropic.d.ts +19 -39
- package/dist/providers/anthropic.js +83 -377
- package/dist/providers/azure-openai.d.ts +20 -0
- package/dist/providers/azure-openai.js +89 -0
- package/dist/providers/function-calling-provider.d.ts +14 -12
- package/dist/providers/function-calling-provider.js +114 -64
- package/dist/providers/google-ai-studio.d.ts +23 -0
- package/dist/providers/google-ai-studio.js +108 -0
- package/dist/providers/google-vertex.d.ts +47 -0
- package/dist/providers/google-vertex.js +205 -0
- package/dist/providers/huggingFace.d.ts +33 -27
- package/dist/providers/huggingFace.js +102 -399
- package/dist/providers/index.d.ts +9 -9
- package/dist/providers/index.js +9 -9
- package/dist/providers/mcp-provider.d.ts +13 -8
- package/dist/providers/mcp-provider.js +63 -18
- package/dist/providers/mistral.d.ts +42 -0
- package/dist/providers/mistral.js +160 -0
- package/dist/providers/ollama.d.ts +52 -35
- package/dist/providers/ollama.js +297 -476
- package/dist/providers/openAI.d.ts +21 -21
- package/dist/providers/openAI.js +81 -246
- package/dist/sdk/tool-extension.d.ts +181 -0
- package/dist/sdk/tool-extension.js +283 -0
- package/dist/sdk/tool-registration.d.ts +95 -0
- package/dist/sdk/tool-registration.js +168 -0
- package/dist/types/generate-types.d.ts +80 -0
- package/dist/types/generate-types.js +1 -0
- package/dist/types/mcp-types.d.ts +116 -0
- package/dist/types/mcp-types.js +5 -0
- package/dist/types/stream-types.d.ts +95 -0
- package/dist/types/stream-types.js +1 -0
- package/dist/types/universal-provider-options.d.ts +87 -0
- package/dist/types/universal-provider-options.js +53 -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 +15 -10
- package/dist/lib/providers/agent-enhanced-provider.d.ts +0 -89
- package/dist/lib/providers/agent-enhanced-provider.js +0 -614
- package/dist/lib/providers/amazonBedrock.d.ts +0 -19
- package/dist/lib/providers/amazonBedrock.js +0 -334
- package/dist/lib/providers/azureOpenAI.d.ts +0 -39
- package/dist/lib/providers/azureOpenAI.js +0 -436
- package/dist/lib/providers/googleAIStudio.d.ts +0 -49
- package/dist/lib/providers/googleAIStudio.js +0 -333
- package/dist/lib/providers/googleVertexAI.d.ts +0 -38
- package/dist/lib/providers/googleVertexAI.js +0 -519
- package/dist/lib/providers/mistralAI.d.ts +0 -34
- package/dist/lib/providers/mistralAI.js +0 -294
- package/dist/providers/agent-enhanced-provider.d.ts +0 -89
- package/dist/providers/agent-enhanced-provider.js +0 -614
- package/dist/providers/amazonBedrock.d.ts +0 -19
- package/dist/providers/amazonBedrock.js +0 -334
- package/dist/providers/azureOpenAI.d.ts +0 -39
- package/dist/providers/azureOpenAI.js +0 -437
- package/dist/providers/googleAIStudio.d.ts +0 -49
- package/dist/providers/googleAIStudio.js +0 -333
- package/dist/providers/googleVertexAI.d.ts +0 -38
- package/dist/providers/googleVertexAI.js +0 -519
- package/dist/providers/mistralAI.d.ts +0 -34
- package/dist/providers/mistralAI.js +0 -294
|
@@ -60,12 +60,12 @@ export class WebSocketChatHandler extends SSEChatHandler {
|
|
|
60
60
|
latencyTarget: 200,
|
|
61
61
|
});
|
|
62
62
|
// Generate AI response
|
|
63
|
-
const result = await this.provider.
|
|
63
|
+
const result = await this.provider.generate({
|
|
64
64
|
prompt: request.prompt,
|
|
65
65
|
temperature: request.options?.temperature,
|
|
66
66
|
maxTokens: request.options?.maxTokens,
|
|
67
67
|
});
|
|
68
|
-
if (!result || !result.
|
|
68
|
+
if (!result || !result.content) {
|
|
69
69
|
throw new Error("Invalid AI response");
|
|
70
70
|
}
|
|
71
71
|
// Send response via WebSocket
|
|
@@ -75,7 +75,7 @@ export class WebSocketChatHandler extends SSEChatHandler {
|
|
|
75
75
|
connectionId,
|
|
76
76
|
timestamp: Date.now(),
|
|
77
77
|
data: {
|
|
78
|
-
text: result.
|
|
78
|
+
text: result.content,
|
|
79
79
|
sessionId: request.sessionId,
|
|
80
80
|
metadata: {
|
|
81
81
|
provider: this.provider.constructor.name,
|
|
@@ -98,12 +98,12 @@ export class WebSocketChatHandler extends SSEChatHandler {
|
|
|
98
98
|
async handleGroupChat(roomId, request) {
|
|
99
99
|
try {
|
|
100
100
|
// Process AI request
|
|
101
|
-
const result = await this.provider.
|
|
101
|
+
const result = await this.provider.generate({
|
|
102
102
|
prompt: request.prompt,
|
|
103
103
|
temperature: request.options?.temperature,
|
|
104
104
|
maxTokens: request.options?.maxTokens,
|
|
105
105
|
});
|
|
106
|
-
if (!result || !result.
|
|
106
|
+
if (!result || !result.content) {
|
|
107
107
|
throw new Error("Invalid AI response");
|
|
108
108
|
}
|
|
109
109
|
// Broadcast to room
|
|
@@ -113,7 +113,7 @@ export class WebSocketChatHandler extends SSEChatHandler {
|
|
|
113
113
|
connectionId: "system",
|
|
114
114
|
timestamp: Date.now(),
|
|
115
115
|
data: {
|
|
116
|
-
text: result.
|
|
116
|
+
text: result.content,
|
|
117
117
|
sessionId: request.sessionId,
|
|
118
118
|
userId: request.userId,
|
|
119
119
|
isGroupMessage: true,
|
|
@@ -136,11 +136,11 @@ export class WebSocketChatHandler extends SSEChatHandler {
|
|
|
136
136
|
const channelId = randomUUID();
|
|
137
137
|
const channel = this.wsServer.createStreamingChannel(connectionId, channelId);
|
|
138
138
|
// Generate response
|
|
139
|
-
const result = await this.provider.
|
|
139
|
+
const result = await this.provider.generate({
|
|
140
140
|
prompt: request.prompt,
|
|
141
141
|
...request.options,
|
|
142
142
|
});
|
|
143
|
-
if (!result || !result.
|
|
143
|
+
if (!result || !result.content) {
|
|
144
144
|
throw new Error("Invalid AI response");
|
|
145
145
|
}
|
|
146
146
|
// Send complete response
|
|
@@ -150,7 +150,7 @@ export class WebSocketChatHandler extends SSEChatHandler {
|
|
|
150
150
|
connectionId,
|
|
151
151
|
timestamp: Date.now(),
|
|
152
152
|
data: {
|
|
153
|
-
text: result.
|
|
153
|
+
text: result.content,
|
|
154
154
|
isStreamingComplete: true,
|
|
155
155
|
channelId,
|
|
156
156
|
},
|
|
@@ -58,8 +58,8 @@ declare const ConfigSchema: z.ZodObject<{
|
|
|
58
58
|
clientEmail?: string | undefined;
|
|
59
59
|
privateKey?: string | undefined;
|
|
60
60
|
}, {
|
|
61
|
-
model?: string | undefined;
|
|
62
61
|
projectId?: string | undefined;
|
|
62
|
+
model?: string | undefined;
|
|
63
63
|
location?: string | undefined;
|
|
64
64
|
credentials?: string | undefined;
|
|
65
65
|
serviceAccountKey?: string | undefined;
|
|
@@ -198,8 +198,8 @@ declare const ConfigSchema: z.ZodObject<{
|
|
|
198
198
|
baseURL?: string | undefined;
|
|
199
199
|
} | undefined;
|
|
200
200
|
vertex?: {
|
|
201
|
-
model?: string | undefined;
|
|
202
201
|
projectId?: string | undefined;
|
|
202
|
+
model?: string | undefined;
|
|
203
203
|
location?: string | undefined;
|
|
204
204
|
credentials?: string | undefined;
|
|
205
205
|
serviceAccountKey?: string | undefined;
|
|
@@ -333,8 +333,8 @@ declare const ConfigSchema: z.ZodObject<{
|
|
|
333
333
|
baseURL?: string | undefined;
|
|
334
334
|
} | undefined;
|
|
335
335
|
vertex?: {
|
|
336
|
-
model?: string | undefined;
|
|
337
336
|
projectId?: string | undefined;
|
|
337
|
+
model?: string | undefined;
|
|
338
338
|
location?: string | undefined;
|
|
339
339
|
credentials?: string | undefined;
|
|
340
340
|
serviceAccountKey?: string | undefined;
|
package/dist/cli/commands/mcp.js
CHANGED
|
@@ -14,6 +14,7 @@ import { ContextManager } from "../../lib/mcp/context-manager.js";
|
|
|
14
14
|
import { MCPOrchestrator } from "../../lib/mcp/orchestrator.js";
|
|
15
15
|
import { initializeNeuroLinkMCP } from "../../lib/mcp/initialize.js";
|
|
16
16
|
import { mcpLogger, setGlobalMCPLogLevel } from "../../lib/mcp/logging.js";
|
|
17
|
+
// import type { LogLevel } from "../../lib/mcp/logging.js"; // Commented out as unused
|
|
17
18
|
import { defaultTimeoutManager } from "../../lib/utils/timeout-manager.js";
|
|
18
19
|
// Default MCP config file location
|
|
19
20
|
const MCP_CONFIG_FILE = path.join(process.cwd(), ".mcp-config.json");
|
|
@@ -158,7 +159,7 @@ async function listMCPServerTools(serverConfig) {
|
|
|
158
159
|
});
|
|
159
160
|
return new Promise((resolve, reject) => {
|
|
160
161
|
let responseData = "";
|
|
161
|
-
let initialized = false;
|
|
162
|
+
// let initialized = false; // Commented out as unused
|
|
162
163
|
child.stdout?.on("data", (data) => {
|
|
163
164
|
responseData += data.toString();
|
|
164
165
|
try {
|
|
@@ -168,7 +169,7 @@ async function listMCPServerTools(serverConfig) {
|
|
|
168
169
|
const response = JSON.parse(line.trim());
|
|
169
170
|
if (response.id === 1 && response.result.capabilities) {
|
|
170
171
|
// Initialize successful, now list tools
|
|
171
|
-
initialized = true;
|
|
172
|
+
// initialized = true; // Commented out as unused
|
|
172
173
|
const listToolsRequest = {
|
|
173
174
|
jsonrpc: "2.0",
|
|
174
175
|
id: 2,
|
|
@@ -232,7 +233,7 @@ export async function executeMCPTool(serverConfig, toolName, toolParams) {
|
|
|
232
233
|
});
|
|
233
234
|
return new Promise((resolve, reject) => {
|
|
234
235
|
let responseData = "";
|
|
235
|
-
let initialized = false;
|
|
236
|
+
// let initialized = false; // Commented out as unused
|
|
236
237
|
child.stdout?.on("data", (data) => {
|
|
237
238
|
responseData += data.toString();
|
|
238
239
|
try {
|
|
@@ -242,7 +243,7 @@ export async function executeMCPTool(serverConfig, toolName, toolParams) {
|
|
|
242
243
|
const response = JSON.parse(line.trim());
|
|
243
244
|
if (response.id === 1 && response.result.capabilities) {
|
|
244
245
|
// Initialize successful, now execute tool
|
|
245
|
-
initialized = true;
|
|
246
|
+
// initialized = true; // Commented out as unused
|
|
246
247
|
const toolCallRequest = {
|
|
247
248
|
jsonrpc: "2.0",
|
|
248
249
|
id: 2,
|
|
@@ -319,7 +320,7 @@ export async function executeMCPTool(serverConfig, toolName, toolParams) {
|
|
|
319
320
|
/**
|
|
320
321
|
* Display discovery results in table format
|
|
321
322
|
*/
|
|
322
|
-
function
|
|
323
|
+
function _displayTable(discoveryResult) {
|
|
323
324
|
console.log(chalk.green(`\n📋 Found ${discoveryResult.discovered.length} MCP servers:`));
|
|
324
325
|
console.log(chalk.gray("─".repeat(80)));
|
|
325
326
|
discoveryResult.discovered.forEach((server, index) => {
|
|
@@ -361,7 +362,7 @@ function displayTable(discoveryResult) {
|
|
|
361
362
|
/**
|
|
362
363
|
* Display discovery results in summary format
|
|
363
364
|
*/
|
|
364
|
-
function
|
|
365
|
+
function _displaySummary(discoveryResult) {
|
|
365
366
|
console.log(chalk.green(`\n📊 Discovery Summary`));
|
|
366
367
|
console.log(chalk.gray("==================="));
|
|
367
368
|
console.log(`${chalk.cyan("Total servers found:")} ${discoveryResult.discovered.length}`);
|
|
@@ -430,7 +431,7 @@ function getSourceTypeIcon(sourceType) {
|
|
|
430
431
|
/**
|
|
431
432
|
* Get icon for server status
|
|
432
433
|
*/
|
|
433
|
-
function
|
|
434
|
+
function _getStatusIcon(status) {
|
|
434
435
|
const icons = {
|
|
435
436
|
available: "✅",
|
|
436
437
|
unavailable: "❌",
|
|
@@ -891,7 +892,7 @@ export function addMCPCommands(yargs) {
|
|
|
891
892
|
type: "boolean",
|
|
892
893
|
description: "Disable fallback to other sources",
|
|
893
894
|
})
|
|
894
|
-
.example('$0 mcp run generate
|
|
895
|
+
.example('$0 mcp run generate --params \'{"prompt": "Hello world"}\'', "Run tool with fallback")
|
|
895
896
|
.example('$0 mcp run read_file --params \'{"path": "README.md"}\' --source manual', "Prefer manual config"), async (argv) => {
|
|
896
897
|
console.log(chalk.blue(`🚀 Executing tool: ${argv.tool}`));
|
|
897
898
|
const spinner = ora("Initializing NeuroLink MCP...").start();
|
|
@@ -53,7 +53,7 @@ async function pullModelHandler(argv) {
|
|
|
53
53
|
try {
|
|
54
54
|
execSync(`ollama pull ${model}`, { stdio: "inherit" });
|
|
55
55
|
console.log(chalk.green(`\n✅ Successfully downloaded ${model}`));
|
|
56
|
-
console.log(chalk.blue(`\nTest it with: npx @juspay/neurolink generate
|
|
56
|
+
console.log(chalk.blue(`\nTest it with: npx @juspay/neurolink generate "Hello!" --provider ollama --model ${model}`));
|
|
57
57
|
}
|
|
58
58
|
catch (error) {
|
|
59
59
|
console.error(chalk.red(`\n❌ Failed to download ${model}`));
|
|
@@ -322,9 +322,9 @@ async function setupHandler() {
|
|
|
322
322
|
console.log(chalk.blue("Next steps:"));
|
|
323
323
|
console.log("1. List models: " + chalk.gray("neurolink ollama list-models"));
|
|
324
324
|
console.log("2. Generate text: " +
|
|
325
|
-
chalk.gray('neurolink generate
|
|
325
|
+
chalk.gray('neurolink generate "Hello!" --provider ollama'));
|
|
326
326
|
console.log("3. Use specific model: " +
|
|
327
|
-
chalk.gray('neurolink generate
|
|
327
|
+
chalk.gray('neurolink generate "Hello!" --provider ollama --model codellama'));
|
|
328
328
|
console.log(chalk.gray("\nFor more information, see: https://docs.neurolink.ai/providers/ollama"));
|
|
329
329
|
}
|
|
330
330
|
export default addOllamaCommands;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { CommandModule } from "yargs";
|
|
2
|
+
/**
|
|
3
|
+
* CLI Command Factory for generate commands
|
|
4
|
+
*/
|
|
5
|
+
export declare class CLICommandFactory {
|
|
6
|
+
/**
|
|
7
|
+
* Create the new primary 'generate' command
|
|
8
|
+
*/
|
|
9
|
+
static createGenerateCommand(): CommandModule;
|
|
10
|
+
/**
|
|
11
|
+
* Execute provider status command
|
|
12
|
+
*/
|
|
13
|
+
executeProviderStatus(argv: any): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Execute the generate command
|
|
16
|
+
*/
|
|
17
|
+
private static executeGenerate;
|
|
18
|
+
}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { NeuroLink } from "../../lib/neurolink.js";
|
|
2
|
+
import ora from "ora";
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
/**
|
|
5
|
+
* CLI Command Factory for generate commands
|
|
6
|
+
*/
|
|
7
|
+
export class CLICommandFactory {
|
|
8
|
+
/**
|
|
9
|
+
* Create the new primary 'generate' command
|
|
10
|
+
*/
|
|
11
|
+
static createGenerateCommand() {
|
|
12
|
+
return {
|
|
13
|
+
command: "generate <input>",
|
|
14
|
+
describe: "Generate content using AI (primary command)",
|
|
15
|
+
builder: (yargs) => {
|
|
16
|
+
return yargs
|
|
17
|
+
.positional("input", {
|
|
18
|
+
describe: "Text input for generation",
|
|
19
|
+
type: "string",
|
|
20
|
+
})
|
|
21
|
+
.option("provider", {
|
|
22
|
+
describe: "AI provider to use",
|
|
23
|
+
type: "string",
|
|
24
|
+
choices: [
|
|
25
|
+
"google-ai",
|
|
26
|
+
"vertex",
|
|
27
|
+
"openai",
|
|
28
|
+
"anthropic",
|
|
29
|
+
"bedrock",
|
|
30
|
+
"azure",
|
|
31
|
+
"huggingface",
|
|
32
|
+
"ollama",
|
|
33
|
+
"mistral",
|
|
34
|
+
],
|
|
35
|
+
default: "google-ai",
|
|
36
|
+
})
|
|
37
|
+
.option("model", {
|
|
38
|
+
describe: "Specific model to use",
|
|
39
|
+
type: "string",
|
|
40
|
+
})
|
|
41
|
+
.option("temperature", {
|
|
42
|
+
describe: "Temperature (0-1)",
|
|
43
|
+
type: "number",
|
|
44
|
+
})
|
|
45
|
+
.option("max-tokens", {
|
|
46
|
+
describe: "Maximum tokens",
|
|
47
|
+
type: "number",
|
|
48
|
+
})
|
|
49
|
+
.option("system-prompt", {
|
|
50
|
+
describe: "System prompt",
|
|
51
|
+
type: "string",
|
|
52
|
+
})
|
|
53
|
+
.option("timeout", {
|
|
54
|
+
describe: "Timeout (e.g., 30s, 2m)",
|
|
55
|
+
type: "string",
|
|
56
|
+
})
|
|
57
|
+
.option("disable-tools", {
|
|
58
|
+
describe: "Disable MCP tools",
|
|
59
|
+
type: "boolean",
|
|
60
|
+
default: false,
|
|
61
|
+
})
|
|
62
|
+
.option("enable-analytics", {
|
|
63
|
+
describe: "Enable usage analytics",
|
|
64
|
+
type: "boolean",
|
|
65
|
+
default: false,
|
|
66
|
+
})
|
|
67
|
+
.option("enable-evaluation", {
|
|
68
|
+
describe: "Enable AI quality evaluation",
|
|
69
|
+
type: "boolean",
|
|
70
|
+
default: false,
|
|
71
|
+
})
|
|
72
|
+
.option("output-format", {
|
|
73
|
+
describe: "Output format",
|
|
74
|
+
type: "string",
|
|
75
|
+
choices: ["text", "structured", "json"],
|
|
76
|
+
default: "text",
|
|
77
|
+
alias: "format",
|
|
78
|
+
})
|
|
79
|
+
.option("debug", {
|
|
80
|
+
describe: "Enable debug output",
|
|
81
|
+
type: "boolean",
|
|
82
|
+
default: false,
|
|
83
|
+
});
|
|
84
|
+
},
|
|
85
|
+
handler: async (argv) => await CLICommandFactory.executeGenerate(argv),
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Execute provider status command
|
|
90
|
+
*/
|
|
91
|
+
async executeProviderStatus(argv) {
|
|
92
|
+
if (argv.verbose && !argv.quiet) {
|
|
93
|
+
console.log(chalk.yellow("ℹ️ Verbose mode enabled. Displaying detailed status.\n"));
|
|
94
|
+
}
|
|
95
|
+
const spinner = argv.quiet
|
|
96
|
+
? null
|
|
97
|
+
: ora("🔍 Checking AI provider status...\n").start();
|
|
98
|
+
try {
|
|
99
|
+
// Use SDK's provider diagnostic method instead of manual testing
|
|
100
|
+
const sdk = new NeuroLink();
|
|
101
|
+
const results = await sdk.getProviderStatus();
|
|
102
|
+
if (spinner) {
|
|
103
|
+
const working = results.filter((r) => r.status === "working").length;
|
|
104
|
+
const configured = results.filter((r) => r.configured).length;
|
|
105
|
+
spinner.succeed(`Provider check complete: ${working}/${configured} providers working`);
|
|
106
|
+
}
|
|
107
|
+
// Display results
|
|
108
|
+
for (const result of results) {
|
|
109
|
+
const status = result.status === "working"
|
|
110
|
+
? chalk.green("✅ Working")
|
|
111
|
+
: result.status === "failed"
|
|
112
|
+
? chalk.red("❌ Failed")
|
|
113
|
+
: chalk.gray("⚪ Not configured");
|
|
114
|
+
const time = result.responseTime ? ` (${result.responseTime}ms)` : "";
|
|
115
|
+
const model = result.model ? ` [${result.model}]` : "";
|
|
116
|
+
console.log(`${result.provider}: ${status}${time}${model}`);
|
|
117
|
+
if (argv.verbose && result.error) {
|
|
118
|
+
console.log(` Error: ${chalk.red(result.error)}`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (argv.verbose && !argv.quiet) {
|
|
122
|
+
console.log(chalk.blue("\n📋 Detailed Results:"));
|
|
123
|
+
console.log(JSON.stringify(results, null, 2));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
if (spinner) {
|
|
128
|
+
spinner.fail("Provider status check failed");
|
|
129
|
+
}
|
|
130
|
+
console.error(chalk.red("Error checking provider status:"), error);
|
|
131
|
+
process.exit(1);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Execute the generate command
|
|
136
|
+
*/
|
|
137
|
+
static async executeGenerate(argv) {
|
|
138
|
+
const spinner = ora("Generating content...").start();
|
|
139
|
+
try {
|
|
140
|
+
const sdk = new NeuroLink();
|
|
141
|
+
const outputFormat = argv.outputFormat || argv.format || "text";
|
|
142
|
+
const result = await sdk.generate({
|
|
143
|
+
input: { text: argv.input },
|
|
144
|
+
output: { format: outputFormat },
|
|
145
|
+
provider: argv.provider,
|
|
146
|
+
model: argv.model,
|
|
147
|
+
temperature: argv.temperature,
|
|
148
|
+
maxTokens: argv.maxTokens,
|
|
149
|
+
systemPrompt: argv.systemPrompt,
|
|
150
|
+
timeout: argv.timeout,
|
|
151
|
+
enableAnalytics: argv.enableAnalytics,
|
|
152
|
+
enableEvaluation: argv.enableEvaluation,
|
|
153
|
+
});
|
|
154
|
+
spinner.succeed("Content generated successfully!");
|
|
155
|
+
// Handle different output formats
|
|
156
|
+
if (outputFormat === "json") {
|
|
157
|
+
console.log(JSON.stringify(result, null, 2));
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
console.log("\n" + chalk.cyan("Generated Content:"));
|
|
161
|
+
console.log(result.content);
|
|
162
|
+
}
|
|
163
|
+
if (argv.debug) {
|
|
164
|
+
console.log("\n" + chalk.yellow("Debug Information:"));
|
|
165
|
+
console.log("Provider:", result.provider);
|
|
166
|
+
console.log("Model:", result.model);
|
|
167
|
+
if (result.analytics) {
|
|
168
|
+
console.log("Analytics:", JSON.stringify(result.analytics, null, 2));
|
|
169
|
+
}
|
|
170
|
+
if (result.evaluation) {
|
|
171
|
+
console.log("Evaluation:", JSON.stringify(result.evaluation, null, 2));
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
// Exit successfully
|
|
175
|
+
process.exit(0);
|
|
176
|
+
}
|
|
177
|
+
catch (error) {
|
|
178
|
+
spinner.fail("Generation failed");
|
|
179
|
+
console.error(chalk.red("Error:"), error);
|
|
180
|
+
process.exit(1);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|