@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
package/dist/cli/index.js
CHANGED
|
@@ -21,7 +21,7 @@ import chalk from "chalk";
|
|
|
21
21
|
import fs from "fs";
|
|
22
22
|
import { addMCPCommands } from "./commands/mcp.js";
|
|
23
23
|
import { addOllamaCommands } from "./commands/ollama.js";
|
|
24
|
-
import {
|
|
24
|
+
import { CLICommandFactory } from "./factories/command-factory.js";
|
|
25
25
|
import { logger } from "../lib/utils/logger.js";
|
|
26
26
|
/**
|
|
27
27
|
* Helper functions for displaying analytics and evaluation results
|
|
@@ -192,6 +192,19 @@ function handleError(error, context) {
|
|
|
192
192
|
}
|
|
193
193
|
process.exit(1);
|
|
194
194
|
}
|
|
195
|
+
// Initialize MCP system for CLI with manual config enabled
|
|
196
|
+
async function initializeCLI() {
|
|
197
|
+
// Import and configure for CLI mode
|
|
198
|
+
const { ProviderRegistry } = await import("../lib/factories/provider-registry.js");
|
|
199
|
+
const { initializeNeuroLinkMCP } = await import("../lib/mcp/initialize.js");
|
|
200
|
+
// Enable manual MCP only for CLI
|
|
201
|
+
ProviderRegistry.setOptions({
|
|
202
|
+
enableManualMCP: true,
|
|
203
|
+
});
|
|
204
|
+
// Initialize MCP system
|
|
205
|
+
await initializeNeuroLinkMCP();
|
|
206
|
+
logger.debug("CLI initialized with manual MCP support enabled");
|
|
207
|
+
}
|
|
195
208
|
// Initialize SDK
|
|
196
209
|
const sdk = new NeuroLink();
|
|
197
210
|
// Manual pre-validation for unknown flags
|
|
@@ -289,9 +302,9 @@ const cli = yargs(args)
|
|
|
289
302
|
}
|
|
290
303
|
exitProcess(); // Default exit
|
|
291
304
|
})
|
|
292
|
-
// Generate
|
|
293
|
-
.command(["generate
|
|
294
|
-
.usage("Usage: $0 generate
|
|
305
|
+
// Generate Command (Primary)
|
|
306
|
+
.command(["generate [prompt]", "gen [prompt]"], "Generate content using AI providers", (yargsInstance) => yargsInstance
|
|
307
|
+
.usage("Usage: $0 generate [prompt] [options]")
|
|
295
308
|
.positional("prompt", {
|
|
296
309
|
type: "string",
|
|
297
310
|
description: "Text prompt for AI generation (or read from stdin)",
|
|
@@ -302,6 +315,7 @@ const cli = yargs(args)
|
|
|
302
315
|
"openai",
|
|
303
316
|
"bedrock",
|
|
304
317
|
"vertex",
|
|
318
|
+
"google-vertex",
|
|
305
319
|
"anthropic",
|
|
306
320
|
"azure",
|
|
307
321
|
"google-ai",
|
|
@@ -378,10 +392,10 @@ const cli = yargs(args)
|
|
|
378
392
|
type: "string",
|
|
379
393
|
description: "JSON context object for custom data",
|
|
380
394
|
})
|
|
381
|
-
.example('$0 generate
|
|
382
|
-
.example('$0 generate
|
|
383
|
-
.example('$0 generate
|
|
384
|
-
.example('$0 generate
|
|
395
|
+
.example('$0 generate "Hello world"', "Basic content generation")
|
|
396
|
+
.example('$0 generate "Write a story" --provider openai', "Use specific provider")
|
|
397
|
+
.example('$0 generate "What time is it?"', "Use with natural tool integration (default)")
|
|
398
|
+
.example('$0 generate "Hello world" --disable-tools', "Use without tool integration"), async (argv) => {
|
|
385
399
|
// SOLUTION 1: Handle stdin input if no prompt provided
|
|
386
400
|
if (!argv.prompt && !process.stdin.isTTY) {
|
|
387
401
|
// Read from stdin
|
|
@@ -429,13 +443,10 @@ const cli = yargs(args)
|
|
|
429
443
|
if (errors.length > 0) {
|
|
430
444
|
throw new Error(`Parameter validation failed:\n${errors.map((e) => ` ⢠${e}`).join("\n")}\n\nUse --help for valid parameter ranges.`);
|
|
431
445
|
}
|
|
432
|
-
//
|
|
433
|
-
const usedCommand = argv._[0];
|
|
434
|
-
if (usedCommand === "generate-text" && !argv.quiet) {
|
|
435
|
-
console.warn(chalk.yellow('ā ļø Warning: "generate-text" is deprecated. Use "generate" or "gen" instead for multimodal support.'));
|
|
436
|
-
}
|
|
446
|
+
// Command is now the primary generate method
|
|
437
447
|
let originalConsole = {};
|
|
438
|
-
if (argv.format === "json"
|
|
448
|
+
if ((argv.format === "json" || argv.outputFormat === "json") &&
|
|
449
|
+
!argv.quiet) {
|
|
439
450
|
// Suppress only if not quiet, as quiet implies no spinners anyway
|
|
440
451
|
originalConsole = { ...console };
|
|
441
452
|
Object.keys(originalConsole).forEach((key) => {
|
|
@@ -444,7 +455,7 @@ const cli = yargs(args)
|
|
|
444
455
|
}
|
|
445
456
|
});
|
|
446
457
|
}
|
|
447
|
-
const spinner = argv.format === "json" || argv.quiet
|
|
458
|
+
const spinner = argv.outputFormat === "json" || argv.format === "json" || argv.quiet
|
|
448
459
|
? null
|
|
449
460
|
: ora("š¤ Generating text...").start();
|
|
450
461
|
try {
|
|
@@ -455,8 +466,6 @@ const cli = yargs(args)
|
|
|
455
466
|
reject(new Error(`CLI operation timed out after ${cliTimeout / 1000} seconds. Use --timeout to adjust.`));
|
|
456
467
|
}, cliTimeout);
|
|
457
468
|
});
|
|
458
|
-
// Use AgentEnhancedProvider when tools are enabled, otherwise use standard SDK
|
|
459
|
-
let generatePromise;
|
|
460
469
|
// Parse context if provided
|
|
461
470
|
let contextObj;
|
|
462
471
|
if (argv.context) {
|
|
@@ -467,60 +476,26 @@ const cli = yargs(args)
|
|
|
467
476
|
throw new Error("Invalid JSON provided for --context option");
|
|
468
477
|
}
|
|
469
478
|
}
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
}
|
|
491
|
-
else {
|
|
492
|
-
// Tools enabled - use AgentEnhancedProvider for tool calling capabilities
|
|
493
|
-
// Map provider to supported AgentEnhancedProvider types
|
|
494
|
-
const supportedProvider = (() => {
|
|
495
|
-
switch (argv.provider) {
|
|
496
|
-
case "openai":
|
|
497
|
-
case "anthropic":
|
|
498
|
-
case "google-ai":
|
|
499
|
-
return argv.provider;
|
|
500
|
-
case "auto":
|
|
501
|
-
default:
|
|
502
|
-
return "google-ai"; // Default to google-ai for best tool support
|
|
503
|
-
}
|
|
504
|
-
})();
|
|
505
|
-
const agentProvider = new AgentEnhancedProvider({
|
|
506
|
-
provider: supportedProvider,
|
|
507
|
-
model: argv.model, // Use specified model or default
|
|
508
|
-
toolCategory: "all", // Enable all tool categories
|
|
509
|
-
});
|
|
510
|
-
generatePromise = agentProvider.generateText({
|
|
511
|
-
prompt: argv.prompt,
|
|
512
|
-
temperature: argv.temperature,
|
|
513
|
-
maxTokens: argv.maxTokens, // Respect user's token limit - no artificial caps
|
|
514
|
-
systemPrompt: argv.system,
|
|
515
|
-
// NEW: Analytics and evaluation support
|
|
516
|
-
enableAnalytics: argv.enableAnalytics,
|
|
517
|
-
enableEvaluation: argv.enableEvaluation,
|
|
518
|
-
context: contextObj,
|
|
519
|
-
// NEW: Lighthouse-compatible domain-aware evaluation
|
|
520
|
-
evaluationDomain: argv.evaluationDomain,
|
|
521
|
-
toolUsageContext: argv.toolUsageContext,
|
|
522
|
-
});
|
|
523
|
-
}
|
|
479
|
+
// Use standard SDK for all generation - tools are now built into BaseProvider
|
|
480
|
+
const generatePromise = sdk.generate({
|
|
481
|
+
input: { text: argv.prompt },
|
|
482
|
+
provider: argv.provider === "auto"
|
|
483
|
+
? undefined
|
|
484
|
+
: argv.provider,
|
|
485
|
+
model: argv.model,
|
|
486
|
+
temperature: argv.temperature,
|
|
487
|
+
maxTokens: argv.maxTokens,
|
|
488
|
+
systemPrompt: argv.system,
|
|
489
|
+
timeout: argv.timeout,
|
|
490
|
+
disableTools: argv.disableTools === true, // Tools are enabled by default
|
|
491
|
+
// NEW: Analytics and evaluation support
|
|
492
|
+
enableAnalytics: argv.enableAnalytics,
|
|
493
|
+
enableEvaluation: argv.enableEvaluation,
|
|
494
|
+
context: contextObj,
|
|
495
|
+
// NEW: Lighthouse-compatible domain-aware evaluation
|
|
496
|
+
evaluationDomain: argv.evaluationDomain,
|
|
497
|
+
toolUsageContext: argv.toolUsageContext,
|
|
498
|
+
});
|
|
524
499
|
// Wrap generation with master timeout to prevent infinite hangs
|
|
525
500
|
const result = await Promise.race([generatePromise, timeoutPromise]);
|
|
526
501
|
if (argv.format === "json" && originalConsole.log) {
|
|
@@ -536,7 +511,8 @@ const cli = yargs(args)
|
|
|
536
511
|
completionTokens: 0,
|
|
537
512
|
totalTokens: 0,
|
|
538
513
|
};
|
|
539
|
-
if (argv.format === "json") {
|
|
514
|
+
if (argv.format === "json" || argv.outputFormat === "json") {
|
|
515
|
+
// CLI debug removed - analytics and evaluation now working correctly
|
|
540
516
|
const jsonOutput = {
|
|
541
517
|
content: responseText,
|
|
542
518
|
provider: typedResult?.provider || argv.provider,
|
|
@@ -636,7 +612,7 @@ const cli = yargs(args)
|
|
|
636
612
|
}
|
|
637
613
|
})
|
|
638
614
|
// Stream Text Command
|
|
639
|
-
.command("stream [prompt]", "Stream
|
|
615
|
+
.command("stream [prompt]", "Stream generation in real-time", (yargsInstance) => yargsInstance
|
|
640
616
|
.usage("Usage: $0 stream [prompt] [options]")
|
|
641
617
|
.positional("prompt", {
|
|
642
618
|
type: "string",
|
|
@@ -648,6 +624,7 @@ const cli = yargs(args)
|
|
|
648
624
|
"openai",
|
|
649
625
|
"bedrock",
|
|
650
626
|
"vertex",
|
|
627
|
+
"google-vertex",
|
|
651
628
|
"anthropic",
|
|
652
629
|
"azure",
|
|
653
630
|
"google-ai",
|
|
@@ -662,6 +639,10 @@ const cli = yargs(args)
|
|
|
662
639
|
type: "number",
|
|
663
640
|
default: 0.7,
|
|
664
641
|
description: "Creativity level",
|
|
642
|
+
})
|
|
643
|
+
.option("max-tokens", {
|
|
644
|
+
type: "number",
|
|
645
|
+
description: "Maximum number of tokens to generate",
|
|
665
646
|
})
|
|
666
647
|
.option("timeout", {
|
|
667
648
|
type: "string",
|
|
@@ -747,76 +728,31 @@ const cli = yargs(args)
|
|
|
747
728
|
throw new Error("Invalid JSON provided for --context option");
|
|
748
729
|
}
|
|
749
730
|
}
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
// Tools enabled - use AgentEnhancedProvider for streaming tool calls
|
|
769
|
-
// Map provider to supported AgentEnhancedProvider types
|
|
770
|
-
const supportedProvider = (() => {
|
|
771
|
-
switch (argv.provider) {
|
|
772
|
-
case "openai":
|
|
773
|
-
case "anthropic":
|
|
774
|
-
case "google-ai":
|
|
775
|
-
return argv.provider;
|
|
776
|
-
case "auto":
|
|
777
|
-
default:
|
|
778
|
-
return "google-ai"; // Default to google-ai for best tool support
|
|
779
|
-
}
|
|
780
|
-
})();
|
|
781
|
-
const agentProvider = new AgentEnhancedProvider({
|
|
782
|
-
provider: supportedProvider,
|
|
783
|
-
model: argv.model, // Use specified model or default
|
|
784
|
-
toolCategory: "all", // Enable all tool categories
|
|
785
|
-
});
|
|
786
|
-
// Note: AgentEnhancedProvider doesn't support streaming with tools yet
|
|
787
|
-
// Fall back to generateText for now
|
|
788
|
-
const result = await agentProvider.generateText({
|
|
789
|
-
prompt: argv.prompt,
|
|
790
|
-
temperature: argv.temperature,
|
|
791
|
-
// NEW: Analytics and evaluation support
|
|
792
|
-
enableAnalytics: argv.enableAnalytics,
|
|
793
|
-
enableEvaluation: argv.enableEvaluation,
|
|
794
|
-
context: contextObj,
|
|
795
|
-
});
|
|
796
|
-
// Simulate streaming by outputting the result
|
|
797
|
-
const text = result?.text || "";
|
|
798
|
-
const CHUNK_SIZE = 10;
|
|
799
|
-
const DELAY_MS = 50;
|
|
800
|
-
for (let i = 0; i < text.length; i += CHUNK_SIZE) {
|
|
801
|
-
process.stdout.write(text.slice(i, i + CHUNK_SIZE));
|
|
802
|
-
await new Promise((resolve) => setTimeout(resolve, DELAY_MS)); // Small delay
|
|
803
|
-
}
|
|
804
|
-
if (!argv.quiet) {
|
|
805
|
-
process.stdout.write("\n");
|
|
806
|
-
}
|
|
807
|
-
// Show analytics if enabled
|
|
808
|
-
// Show analytics and evaluation if enabled
|
|
809
|
-
displayAnalyticsAndEvaluation(result, argv);
|
|
810
|
-
return; // Exit early for agent mode
|
|
811
|
-
}
|
|
812
|
-
for await (const chunk of stream) {
|
|
731
|
+
// Use standard SDK streaming - tools are handled automatically
|
|
732
|
+
const sdk = new NeuroLink();
|
|
733
|
+
const stream = await sdk.stream({
|
|
734
|
+
input: { text: argv.prompt },
|
|
735
|
+
provider: argv.provider === "auto"
|
|
736
|
+
? undefined
|
|
737
|
+
: argv.provider,
|
|
738
|
+
model: argv.model,
|
|
739
|
+
temperature: argv.temperature,
|
|
740
|
+
timeout: argv.timeout,
|
|
741
|
+
disableTools: argv.disableTools === true, // Tools are enabled by default
|
|
742
|
+
// NEW: Analytics and evaluation support
|
|
743
|
+
enableAnalytics: argv.enableAnalytics,
|
|
744
|
+
enableEvaluation: argv.enableEvaluation,
|
|
745
|
+
context: contextObj,
|
|
746
|
+
});
|
|
747
|
+
// Process the stream
|
|
748
|
+
for await (const chunk of stream.stream) {
|
|
813
749
|
process.stdout.write(chunk.content);
|
|
814
|
-
// In debug mode, interleaved logging would appear here
|
|
815
|
-
// (SDK logs are controlled by NEUROLINK_DEBUG set in middleware)
|
|
816
750
|
}
|
|
817
751
|
if (!argv.quiet) {
|
|
818
752
|
process.stdout.write("\n");
|
|
819
|
-
}
|
|
753
|
+
}
|
|
754
|
+
// Clean exit for tools-disabled streaming
|
|
755
|
+
process.exit(0);
|
|
820
756
|
}
|
|
821
757
|
catch (error) {
|
|
822
758
|
handleError(error, "Text streaming");
|
|
@@ -845,6 +781,7 @@ const cli = yargs(args)
|
|
|
845
781
|
"openai",
|
|
846
782
|
"bedrock",
|
|
847
783
|
"vertex",
|
|
784
|
+
"google-vertex",
|
|
848
785
|
"anthropic",
|
|
849
786
|
"azure",
|
|
850
787
|
"google-ai",
|
|
@@ -911,8 +848,8 @@ const cli = yargs(args)
|
|
|
911
848
|
spinner.text = `Processing ${i + 1}/${prompts.length}: ${prompts[i].substring(0, 30)}...`;
|
|
912
849
|
}
|
|
913
850
|
try {
|
|
914
|
-
const result = await sdk.
|
|
915
|
-
|
|
851
|
+
const result = await sdk.generate({
|
|
852
|
+
input: { text: prompts[i] },
|
|
916
853
|
provider: argv.provider === "auto"
|
|
917
854
|
? undefined
|
|
918
855
|
: argv.provider,
|
|
@@ -984,6 +921,7 @@ const cli = yargs(args)
|
|
|
984
921
|
"openai",
|
|
985
922
|
"bedrock",
|
|
986
923
|
"vertex",
|
|
924
|
+
"google-vertex",
|
|
987
925
|
"anthropic",
|
|
988
926
|
"azure",
|
|
989
927
|
"google-ai",
|
|
@@ -1074,8 +1012,8 @@ const cli = yargs(args)
|
|
|
1074
1012
|
try {
|
|
1075
1013
|
const start = Date.now();
|
|
1076
1014
|
// Add timeout to prevent hanging
|
|
1077
|
-
const testPromise = sdk.
|
|
1078
|
-
|
|
1015
|
+
const testPromise = sdk.generate({
|
|
1016
|
+
input: { text: "test" },
|
|
1079
1017
|
provider: p,
|
|
1080
1018
|
maxTokens: 1,
|
|
1081
1019
|
disableTools: true, // Disable tools for faster status check
|
|
@@ -1135,19 +1073,24 @@ const cli = yargs(args)
|
|
|
1135
1073
|
.example("$0 provider status", "Check all providers");
|
|
1136
1074
|
})
|
|
1137
1075
|
// Status command alias
|
|
1138
|
-
.command("status", "Check AI provider connectivity and performance (alias for provider status)", (yargsConfig) => yargsConfig
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1076
|
+
.command("status", "Check AI provider connectivity and performance (alias for provider status)", (yargsConfig) => yargsConfig
|
|
1077
|
+
.usage("Usage: $0 status [options]")
|
|
1078
|
+
.option("verbose", {
|
|
1079
|
+
type: "boolean",
|
|
1080
|
+
alias: "v",
|
|
1081
|
+
description: "Show detailed information",
|
|
1082
|
+
})
|
|
1083
|
+
.option("quiet", {
|
|
1084
|
+
type: "boolean",
|
|
1085
|
+
alias: "q",
|
|
1086
|
+
description: "Suppress non-essential output",
|
|
1087
|
+
})
|
|
1088
|
+
.example("$0 status", "Quick provider status check")
|
|
1089
|
+
.example("$0 status --verbose", "Show detailed status information"), async (argv) => {
|
|
1090
|
+
// Direct implementation instead of redirect to avoid recursion
|
|
1091
|
+
const { CLICommandFactory } = await import("./factories/command-factory.js");
|
|
1092
|
+
const commandFactory = new CLICommandFactory();
|
|
1093
|
+
await commandFactory.executeProviderStatus(argv);
|
|
1151
1094
|
})
|
|
1152
1095
|
// Configuration Command Group
|
|
1153
1096
|
.command("config <subcommand>", "Manage NeuroLink configuration", (yargsConfig) => {
|
|
@@ -1213,7 +1156,7 @@ const cli = yargs(args)
|
|
|
1213
1156
|
.example("$0 get-best-provider --format json", "Show in JSON format"), async (argv) => {
|
|
1214
1157
|
try {
|
|
1215
1158
|
const { getBestProvider } = await import("../lib/utils/providerUtils-fixed.js");
|
|
1216
|
-
const bestProvider = getBestProvider();
|
|
1159
|
+
const bestProvider = await getBestProvider();
|
|
1217
1160
|
if (argv.format === "json") {
|
|
1218
1161
|
process.stdout.write(JSON.stringify({ provider: bestProvider }, null, 2) + "\n");
|
|
1219
1162
|
}
|
|
@@ -1237,6 +1180,8 @@ const cli = yargs(args)
|
|
|
1237
1180
|
.example("$0 completion >> ~/.zshrc", "Add to zsh"), async (argv) => {
|
|
1238
1181
|
cli.showCompletionScript();
|
|
1239
1182
|
});
|
|
1183
|
+
// Add NEW Generate Command (Primary)
|
|
1184
|
+
cli.command(CLICommandFactory.createGenerateCommand());
|
|
1240
1185
|
// Add MCP Commands
|
|
1241
1186
|
addMCPCommands(cli);
|
|
1242
1187
|
// Add Ollama Commands
|
|
@@ -1244,6 +1189,9 @@ addOllamaCommands(cli);
|
|
|
1244
1189
|
// Execute CLI
|
|
1245
1190
|
(async () => {
|
|
1246
1191
|
try {
|
|
1192
|
+
// Initialize CLI with manual MCP support
|
|
1193
|
+
await initializeCLI();
|
|
1194
|
+
// Parse and execute commands
|
|
1247
1195
|
await cli.parse();
|
|
1248
1196
|
}
|
|
1249
1197
|
catch (error) {
|
|
@@ -244,7 +244,7 @@ export async function testProviderConnectivity(providers, quiet = false) {
|
|
|
244
244
|
}
|
|
245
245
|
try {
|
|
246
246
|
const start = Date.now();
|
|
247
|
-
await sdk.
|
|
247
|
+
await sdk.generate({ input: { text: "test" }, provider, maxTokens: 1 });
|
|
248
248
|
const duration = Date.now() - start;
|
|
249
249
|
results.push({ provider, status: "working", responseTime: duration });
|
|
250
250
|
if (spinner) {
|
|
@@ -291,7 +291,7 @@ export function displaySetupSummary(result, quiet = false) {
|
|
|
291
291
|
if (working > 0) {
|
|
292
292
|
console.log(chalk.green("\nā
Setup completed successfully!"));
|
|
293
293
|
console.log(chalk.yellow("š” You can now use NeuroLink with your configured providers."));
|
|
294
|
-
console.log(chalk.gray(' Try: neurolink generate
|
|
294
|
+
console.log(chalk.gray(' Try: neurolink generate "Hello, AI!"'));
|
|
295
295
|
}
|
|
296
296
|
else {
|
|
297
297
|
console.log(chalk.red("\nā No providers are working."));
|