@juspay/neurolink 5.1.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 +15 -9
- package/README.md +123 -126
- package/dist/agent/direct-tools.d.ts +6 -6
- package/dist/cli/commands/config.d.ts +3 -3
- package/dist/cli/commands/mcp.js +8 -7
- package/dist/cli/factories/command-factory.d.ts +4 -0
- package/dist/cli/factories/command-factory.js +57 -3
- package/dist/cli/index.js +87 -140
- 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 +8 -1
- package/dist/factories/compatibility-factory.js +1 -1
- package/dist/factories/provider-factory.d.ts +72 -0
- package/dist/factories/provider-factory.js +144 -0
- package/dist/factories/provider-registry.d.ts +38 -0
- package/dist/factories/provider-registry.js +107 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.js +2 -4
- package/dist/lib/agent/direct-tools.d.ts +6 -6
- 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 +8 -1
- package/dist/lib/factories/compatibility-factory.js +1 -1
- package/dist/lib/factories/provider-factory.d.ts +72 -0
- package/dist/lib/factories/provider-factory.js +144 -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 +4 -3
- package/dist/lib/index.js +2 -4
- package/dist/lib/mcp/config.js +28 -3
- 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/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-core-server.js +3 -1
- package/dist/lib/mcp/servers/ai-providers/ai-workflow-tools.d.ts +2 -2
- 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 +156 -117
- package/dist/lib/neurolink.js +619 -404
- 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 -43
- package/dist/lib/providers/anthropic.js +82 -306
- package/dist/lib/providers/azure-openai.d.ts +20 -0
- package/dist/lib/providers/azure-openai.js +89 -0
- 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 +32 -25
- package/dist/lib/providers/huggingFace.js +97 -431
- package/dist/lib/providers/index.d.ts +9 -9
- package/dist/lib/providers/index.js +9 -9
- package/dist/lib/providers/mcp-provider.js +4 -0
- 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 -36
- package/dist/lib/providers/ollama.js +297 -520
- package/dist/lib/providers/openAI.d.ts +19 -18
- package/dist/lib/providers/openAI.js +76 -275
- 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 +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 +30 -18
- package/dist/lib/types/universal-provider-options.d.ts +87 -0
- package/dist/lib/types/universal-provider-options.js +53 -0
- package/dist/mcp/config.js +28 -3
- 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/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-core-server.js +3 -1
- package/dist/mcp/servers/ai-providers/ai-workflow-tools.d.ts +2 -2
- package/dist/mcp/unified-registry.d.ts +4 -0
- package/dist/mcp/unified-registry.js +42 -9
- package/dist/neurolink.d.ts +156 -117
- package/dist/neurolink.js +619 -404
- 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 -43
- package/dist/providers/anthropic.js +81 -305
- package/dist/providers/azure-openai.d.ts +20 -0
- package/dist/providers/azure-openai.js +89 -0
- 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 +32 -25
- package/dist/providers/huggingFace.js +96 -430
- package/dist/providers/index.d.ts +9 -9
- package/dist/providers/index.js +9 -9
- package/dist/providers/mcp-provider.js +4 -0
- package/dist/providers/mistral.d.ts +42 -0
- package/dist/providers/mistral.js +160 -0
- package/dist/providers/ollama.d.ts +52 -36
- package/dist/providers/ollama.js +297 -519
- package/dist/providers/openAI.d.ts +19 -18
- package/dist/providers/openAI.js +76 -276
- 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 +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 +30 -18
- package/dist/types/universal-provider-options.d.ts +87 -0
- package/dist/types/universal-provider-options.js +53 -0
- package/package.json +15 -10
- package/dist/lib/providers/agent-enhanced-provider.d.ts +0 -93
- package/dist/lib/providers/agent-enhanced-provider.js +0 -605
- package/dist/lib/providers/amazonBedrock.d.ts +0 -28
- package/dist/lib/providers/amazonBedrock.js +0 -364
- package/dist/lib/providers/azureOpenAI.d.ts +0 -42
- package/dist/lib/providers/azureOpenAI.js +0 -347
- package/dist/lib/providers/googleAIStudio.d.ts +0 -42
- package/dist/lib/providers/googleAIStudio.js +0 -364
- package/dist/lib/providers/googleVertexAI.d.ts +0 -34
- package/dist/lib/providers/googleVertexAI.js +0 -547
- package/dist/lib/providers/mistralAI.d.ts +0 -37
- package/dist/lib/providers/mistralAI.js +0 -325
- package/dist/providers/agent-enhanced-provider.d.ts +0 -93
- package/dist/providers/agent-enhanced-provider.js +0 -606
- package/dist/providers/amazonBedrock.d.ts +0 -28
- package/dist/providers/amazonBedrock.js +0 -364
- package/dist/providers/azureOpenAI.d.ts +0 -42
- package/dist/providers/azureOpenAI.js +0 -348
- package/dist/providers/googleAIStudio.d.ts +0 -42
- package/dist/providers/googleAIStudio.js +0 -364
- package/dist/providers/googleVertexAI.d.ts +0 -34
- package/dist/providers/googleVertexAI.js +0 -547
- package/dist/providers/mistralAI.d.ts +0 -37
- package/dist/providers/mistralAI.js +0 -325
|
@@ -74,6 +74,7 @@ export class CLICommandFactory {
|
|
|
74
74
|
type: "string",
|
|
75
75
|
choices: ["text", "structured", "json"],
|
|
76
76
|
default: "text",
|
|
77
|
+
alias: "format",
|
|
77
78
|
})
|
|
78
79
|
.option("debug", {
|
|
79
80
|
describe: "Enable debug output",
|
|
@@ -84,6 +85,52 @@ export class CLICommandFactory {
|
|
|
84
85
|
handler: async (argv) => await CLICommandFactory.executeGenerate(argv),
|
|
85
86
|
};
|
|
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
|
+
}
|
|
87
134
|
/**
|
|
88
135
|
* Execute the generate command
|
|
89
136
|
*/
|
|
@@ -91,9 +138,10 @@ export class CLICommandFactory {
|
|
|
91
138
|
const spinner = ora("Generating content...").start();
|
|
92
139
|
try {
|
|
93
140
|
const sdk = new NeuroLink();
|
|
141
|
+
const outputFormat = argv.outputFormat || argv.format || "text";
|
|
94
142
|
const result = await sdk.generate({
|
|
95
143
|
input: { text: argv.input },
|
|
96
|
-
output: { format:
|
|
144
|
+
output: { format: outputFormat },
|
|
97
145
|
provider: argv.provider,
|
|
98
146
|
model: argv.model,
|
|
99
147
|
temperature: argv.temperature,
|
|
@@ -104,8 +152,14 @@ export class CLICommandFactory {
|
|
|
104
152
|
enableEvaluation: argv.enableEvaluation,
|
|
105
153
|
});
|
|
106
154
|
spinner.succeed("Content generated successfully!");
|
|
107
|
-
|
|
108
|
-
|
|
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
|
+
}
|
|
109
163
|
if (argv.debug) {
|
|
110
164
|
console.log("\n" + chalk.yellow("Debug Information:"));
|
|
111
165
|
console.log("Provider:", result.provider);
|
package/dist/cli/index.js
CHANGED
|
@@ -22,7 +22,6 @@ import fs from "fs";
|
|
|
22
22
|
import { addMCPCommands } from "./commands/mcp.js";
|
|
23
23
|
import { addOllamaCommands } from "./commands/ollama.js";
|
|
24
24
|
import { CLICommandFactory } from "./factories/command-factory.js";
|
|
25
|
-
import { AgentEnhancedProvider } from "../lib/providers/agent-enhanced-provider.js";
|
|
26
25
|
import { logger } from "../lib/utils/logger.js";
|
|
27
26
|
/**
|
|
28
27
|
* Helper functions for displaying analytics and evaluation results
|
|
@@ -193,6 +192,19 @@ function handleError(error, context) {
|
|
|
193
192
|
}
|
|
194
193
|
process.exit(1);
|
|
195
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
|
+
}
|
|
196
208
|
// Initialize SDK
|
|
197
209
|
const sdk = new NeuroLink();
|
|
198
210
|
// Manual pre-validation for unknown flags
|
|
@@ -303,6 +315,7 @@ const cli = yargs(args)
|
|
|
303
315
|
"openai",
|
|
304
316
|
"bedrock",
|
|
305
317
|
"vertex",
|
|
318
|
+
"google-vertex",
|
|
306
319
|
"anthropic",
|
|
307
320
|
"azure",
|
|
308
321
|
"google-ai",
|
|
@@ -432,7 +445,8 @@ const cli = yargs(args)
|
|
|
432
445
|
}
|
|
433
446
|
// Command is now the primary generate method
|
|
434
447
|
let originalConsole = {};
|
|
435
|
-
if (argv.format === "json"
|
|
448
|
+
if ((argv.format === "json" || argv.outputFormat === "json") &&
|
|
449
|
+
!argv.quiet) {
|
|
436
450
|
// Suppress only if not quiet, as quiet implies no spinners anyway
|
|
437
451
|
originalConsole = { ...console };
|
|
438
452
|
Object.keys(originalConsole).forEach((key) => {
|
|
@@ -441,7 +455,7 @@ const cli = yargs(args)
|
|
|
441
455
|
}
|
|
442
456
|
});
|
|
443
457
|
}
|
|
444
|
-
const spinner = argv.format === "json" || argv.quiet
|
|
458
|
+
const spinner = argv.outputFormat === "json" || argv.format === "json" || argv.quiet
|
|
445
459
|
? null
|
|
446
460
|
: ora("🤖 Generating text...").start();
|
|
447
461
|
try {
|
|
@@ -452,8 +466,6 @@ const cli = yargs(args)
|
|
|
452
466
|
reject(new Error(`CLI operation timed out after ${cliTimeout / 1000} seconds. Use --timeout to adjust.`));
|
|
453
467
|
}, cliTimeout);
|
|
454
468
|
});
|
|
455
|
-
// Use AgentEnhancedProvider when tools are enabled, otherwise use standard SDK
|
|
456
|
-
let generatePromise;
|
|
457
469
|
// Parse context if provided
|
|
458
470
|
let contextObj;
|
|
459
471
|
if (argv.context) {
|
|
@@ -464,60 +476,26 @@ const cli = yargs(args)
|
|
|
464
476
|
throw new Error("Invalid JSON provided for --context option");
|
|
465
477
|
}
|
|
466
478
|
}
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
}
|
|
488
|
-
else {
|
|
489
|
-
// Tools enabled - use AgentEnhancedProvider for tool calling capabilities
|
|
490
|
-
// Map provider to supported AgentEnhancedProvider types
|
|
491
|
-
const supportedProvider = (() => {
|
|
492
|
-
switch (argv.provider) {
|
|
493
|
-
case "openai":
|
|
494
|
-
case "anthropic":
|
|
495
|
-
case "google-ai":
|
|
496
|
-
return argv.provider;
|
|
497
|
-
case "auto":
|
|
498
|
-
default:
|
|
499
|
-
return "google-ai"; // Default to google-ai for best tool support
|
|
500
|
-
}
|
|
501
|
-
})();
|
|
502
|
-
const agentProvider = new AgentEnhancedProvider({
|
|
503
|
-
provider: supportedProvider,
|
|
504
|
-
model: argv.model, // Use specified model or default
|
|
505
|
-
toolCategory: "all", // Enable all tool categories
|
|
506
|
-
});
|
|
507
|
-
generatePromise = agentProvider.generate({
|
|
508
|
-
prompt: argv.prompt,
|
|
509
|
-
temperature: argv.temperature,
|
|
510
|
-
maxTokens: argv.maxTokens, // Respect user's token limit - no artificial caps
|
|
511
|
-
systemPrompt: argv.system,
|
|
512
|
-
// NEW: Analytics and evaluation support
|
|
513
|
-
enableAnalytics: argv.enableAnalytics,
|
|
514
|
-
enableEvaluation: argv.enableEvaluation,
|
|
515
|
-
context: contextObj,
|
|
516
|
-
// NEW: Lighthouse-compatible domain-aware evaluation
|
|
517
|
-
evaluationDomain: argv.evaluationDomain,
|
|
518
|
-
toolUsageContext: argv.toolUsageContext,
|
|
519
|
-
});
|
|
520
|
-
}
|
|
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
|
+
});
|
|
521
499
|
// Wrap generation with master timeout to prevent infinite hangs
|
|
522
500
|
const result = await Promise.race([generatePromise, timeoutPromise]);
|
|
523
501
|
if (argv.format === "json" && originalConsole.log) {
|
|
@@ -533,7 +511,8 @@ const cli = yargs(args)
|
|
|
533
511
|
completionTokens: 0,
|
|
534
512
|
totalTokens: 0,
|
|
535
513
|
};
|
|
536
|
-
if (argv.format === "json") {
|
|
514
|
+
if (argv.format === "json" || argv.outputFormat === "json") {
|
|
515
|
+
// CLI debug removed - analytics and evaluation now working correctly
|
|
537
516
|
const jsonOutput = {
|
|
538
517
|
content: responseText,
|
|
539
518
|
provider: typedResult?.provider || argv.provider,
|
|
@@ -645,6 +624,7 @@ const cli = yargs(args)
|
|
|
645
624
|
"openai",
|
|
646
625
|
"bedrock",
|
|
647
626
|
"vertex",
|
|
627
|
+
"google-vertex",
|
|
648
628
|
"anthropic",
|
|
649
629
|
"azure",
|
|
650
630
|
"google-ai",
|
|
@@ -659,6 +639,10 @@ const cli = yargs(args)
|
|
|
659
639
|
type: "number",
|
|
660
640
|
default: 0.7,
|
|
661
641
|
description: "Creativity level",
|
|
642
|
+
})
|
|
643
|
+
.option("max-tokens", {
|
|
644
|
+
type: "number",
|
|
645
|
+
description: "Maximum number of tokens to generate",
|
|
662
646
|
})
|
|
663
647
|
.option("timeout", {
|
|
664
648
|
type: "string",
|
|
@@ -744,77 +728,30 @@ const cli = yargs(args)
|
|
|
744
728
|
throw new Error("Invalid JSON provided for --context option");
|
|
745
729
|
}
|
|
746
730
|
}
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
else {
|
|
765
|
-
// Tools enabled - use AgentEnhancedProvider for streaming tool calls
|
|
766
|
-
// Map provider to supported AgentEnhancedProvider types
|
|
767
|
-
const supportedProvider = (() => {
|
|
768
|
-
switch (argv.provider) {
|
|
769
|
-
case "openai":
|
|
770
|
-
case "anthropic":
|
|
771
|
-
case "google-ai":
|
|
772
|
-
return argv.provider;
|
|
773
|
-
case "auto":
|
|
774
|
-
default:
|
|
775
|
-
return "google-ai"; // Default to google-ai for best tool support
|
|
776
|
-
}
|
|
777
|
-
})();
|
|
778
|
-
const agentProvider = new AgentEnhancedProvider({
|
|
779
|
-
provider: supportedProvider,
|
|
780
|
-
model: argv.model, // Use specified model or default
|
|
781
|
-
toolCategory: "all", // Enable all tool categories
|
|
782
|
-
});
|
|
783
|
-
// Note: AgentEnhancedProvider doesn't support streaming with tools yet
|
|
784
|
-
// Fall back to generate for now
|
|
785
|
-
const result = await agentProvider.generate({
|
|
786
|
-
prompt: argv.prompt,
|
|
787
|
-
temperature: argv.temperature,
|
|
788
|
-
// NEW: Analytics and evaluation support
|
|
789
|
-
enableAnalytics: argv.enableAnalytics,
|
|
790
|
-
enableEvaluation: argv.enableEvaluation,
|
|
791
|
-
context: contextObj,
|
|
792
|
-
});
|
|
793
|
-
// Simulate streaming by outputting the result
|
|
794
|
-
const text = result?.content || "";
|
|
795
|
-
const CHUNK_SIZE = 10;
|
|
796
|
-
const DELAY_MS = 50;
|
|
797
|
-
for (let i = 0; i < text.length; i += CHUNK_SIZE) {
|
|
798
|
-
process.stdout.write(text.slice(i, i + CHUNK_SIZE));
|
|
799
|
-
await new Promise((resolve) => setTimeout(resolve, DELAY_MS)); // Small delay
|
|
800
|
-
}
|
|
801
|
-
if (!argv.quiet) {
|
|
802
|
-
process.stdout.write("\n");
|
|
803
|
-
}
|
|
804
|
-
// Show analytics if enabled
|
|
805
|
-
// Show analytics and evaluation if enabled
|
|
806
|
-
displayAnalyticsAndEvaluation(result, argv);
|
|
807
|
-
return; // Exit early for agent mode
|
|
808
|
-
}
|
|
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
|
|
809
748
|
for await (const chunk of stream.stream) {
|
|
810
749
|
process.stdout.write(chunk.content);
|
|
811
|
-
// In debug mode, interleaved logging would appear here
|
|
812
|
-
// (SDK logs are controlled by NEUROLINK_DEBUG set in middleware)
|
|
813
750
|
}
|
|
814
751
|
if (!argv.quiet) {
|
|
815
752
|
process.stdout.write("\n");
|
|
816
|
-
}
|
|
817
|
-
//
|
|
753
|
+
}
|
|
754
|
+
// Clean exit for tools-disabled streaming
|
|
818
755
|
process.exit(0);
|
|
819
756
|
}
|
|
820
757
|
catch (error) {
|
|
@@ -844,6 +781,7 @@ const cli = yargs(args)
|
|
|
844
781
|
"openai",
|
|
845
782
|
"bedrock",
|
|
846
783
|
"vertex",
|
|
784
|
+
"google-vertex",
|
|
847
785
|
"anthropic",
|
|
848
786
|
"azure",
|
|
849
787
|
"google-ai",
|
|
@@ -983,6 +921,7 @@ const cli = yargs(args)
|
|
|
983
921
|
"openai",
|
|
984
922
|
"bedrock",
|
|
985
923
|
"vertex",
|
|
924
|
+
"google-vertex",
|
|
986
925
|
"anthropic",
|
|
987
926
|
"azure",
|
|
988
927
|
"google-ai",
|
|
@@ -1134,19 +1073,24 @@ const cli = yargs(args)
|
|
|
1134
1073
|
.example("$0 provider status", "Check all providers");
|
|
1135
1074
|
})
|
|
1136
1075
|
// Status command alias
|
|
1137
|
-
.command("status", "Check AI provider connectivity and performance (alias for provider status)", (yargsConfig) => yargsConfig
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
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);
|
|
1150
1094
|
})
|
|
1151
1095
|
// Configuration Command Group
|
|
1152
1096
|
.command("config <subcommand>", "Manage NeuroLink configuration", (yargsConfig) => {
|
|
@@ -1212,7 +1156,7 @@ const cli = yargs(args)
|
|
|
1212
1156
|
.example("$0 get-best-provider --format json", "Show in JSON format"), async (argv) => {
|
|
1213
1157
|
try {
|
|
1214
1158
|
const { getBestProvider } = await import("../lib/utils/providerUtils-fixed.js");
|
|
1215
|
-
const bestProvider = getBestProvider();
|
|
1159
|
+
const bestProvider = await getBestProvider();
|
|
1216
1160
|
if (argv.format === "json") {
|
|
1217
1161
|
process.stdout.write(JSON.stringify({ provider: bestProvider }, null, 2) + "\n");
|
|
1218
1162
|
}
|
|
@@ -1245,6 +1189,9 @@ addOllamaCommands(cli);
|
|
|
1245
1189
|
// Execute CLI
|
|
1246
1190
|
(async () => {
|
|
1247
1191
|
try {
|
|
1192
|
+
// Initialize CLI with manual MCP support
|
|
1193
|
+
await initializeCLI();
|
|
1194
|
+
// Parse and execute commands
|
|
1248
1195
|
await cli.parse();
|
|
1249
1196
|
}
|
|
1250
1197
|
catch (error) {
|