@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.
Files changed (214) hide show
  1. package/CHANGELOG.md +20 -7
  2. package/README.md +160 -172
  3. package/dist/agent/direct-tools.d.ts +6 -6
  4. package/dist/chat/sse-handler.js +5 -4
  5. package/dist/chat/websocket-chat-handler.js +9 -9
  6. package/dist/cli/commands/config.d.ts +3 -3
  7. package/dist/cli/commands/mcp.js +9 -8
  8. package/dist/cli/commands/ollama.js +3 -3
  9. package/dist/cli/factories/command-factory.d.ts +18 -0
  10. package/dist/cli/factories/command-factory.js +183 -0
  11. package/dist/cli/index.js +105 -157
  12. package/dist/cli/utils/interactive-setup.js +2 -2
  13. package/dist/core/base-provider.d.ts +423 -0
  14. package/dist/core/base-provider.js +365 -0
  15. package/dist/core/constants.d.ts +1 -1
  16. package/dist/core/constants.js +1 -1
  17. package/dist/core/dynamic-models.d.ts +6 -6
  18. package/dist/core/evaluation.d.ts +19 -80
  19. package/dist/core/evaluation.js +185 -484
  20. package/dist/core/factory.d.ts +3 -3
  21. package/dist/core/factory.js +31 -91
  22. package/dist/core/service-registry.d.ts +47 -0
  23. package/dist/core/service-registry.js +112 -0
  24. package/dist/core/types.d.ts +49 -49
  25. package/dist/core/types.js +1 -0
  26. package/dist/factories/compatibility-factory.d.ts +20 -0
  27. package/dist/factories/compatibility-factory.js +69 -0
  28. package/dist/factories/provider-factory.d.ts +72 -0
  29. package/dist/factories/provider-factory.js +144 -0
  30. package/dist/factories/provider-generate-factory.d.ts +20 -0
  31. package/dist/factories/provider-generate-factory.js +87 -0
  32. package/dist/factories/provider-registry.d.ts +38 -0
  33. package/dist/factories/provider-registry.js +107 -0
  34. package/dist/index.d.ts +8 -5
  35. package/dist/index.js +5 -5
  36. package/dist/lib/agent/direct-tools.d.ts +6 -6
  37. package/dist/lib/chat/sse-handler.js +5 -4
  38. package/dist/lib/chat/websocket-chat-handler.js +9 -9
  39. package/dist/lib/core/base-provider.d.ts +423 -0
  40. package/dist/lib/core/base-provider.js +365 -0
  41. package/dist/lib/core/constants.d.ts +1 -1
  42. package/dist/lib/core/constants.js +1 -1
  43. package/dist/lib/core/dynamic-models.d.ts +6 -6
  44. package/dist/lib/core/evaluation.d.ts +19 -80
  45. package/dist/lib/core/evaluation.js +185 -484
  46. package/dist/lib/core/factory.d.ts +3 -3
  47. package/dist/lib/core/factory.js +30 -91
  48. package/dist/lib/core/service-registry.d.ts +47 -0
  49. package/dist/lib/core/service-registry.js +112 -0
  50. package/dist/lib/core/types.d.ts +49 -49
  51. package/dist/lib/core/types.js +1 -0
  52. package/dist/lib/factories/compatibility-factory.d.ts +20 -0
  53. package/dist/lib/factories/compatibility-factory.js +69 -0
  54. package/dist/lib/factories/provider-factory.d.ts +72 -0
  55. package/dist/lib/factories/provider-factory.js +144 -0
  56. package/dist/lib/factories/provider-generate-factory.d.ts +20 -0
  57. package/dist/lib/factories/provider-generate-factory.js +87 -0
  58. package/dist/lib/factories/provider-registry.d.ts +38 -0
  59. package/dist/lib/factories/provider-registry.js +107 -0
  60. package/dist/lib/index.d.ts +8 -5
  61. package/dist/lib/index.js +5 -5
  62. package/dist/lib/mcp/client.js +5 -5
  63. package/dist/lib/mcp/config.js +28 -3
  64. package/dist/lib/mcp/dynamic-orchestrator.js +8 -8
  65. package/dist/lib/mcp/external-client.js +2 -2
  66. package/dist/lib/mcp/factory.d.ts +1 -1
  67. package/dist/lib/mcp/factory.js +1 -1
  68. package/dist/lib/mcp/function-calling.js +1 -1
  69. package/dist/lib/mcp/initialize-tools.d.ts +1 -1
  70. package/dist/lib/mcp/initialize-tools.js +45 -1
  71. package/dist/lib/mcp/initialize.js +16 -6
  72. package/dist/lib/mcp/neurolink-mcp-client.js +10 -10
  73. package/dist/lib/mcp/orchestrator.js +4 -4
  74. package/dist/lib/mcp/servers/agent/direct-tools-server.d.ts +8 -0
  75. package/dist/lib/mcp/servers/agent/direct-tools-server.js +109 -0
  76. package/dist/lib/mcp/servers/ai-providers/ai-analysis-tools.js +10 -10
  77. package/dist/lib/mcp/servers/ai-providers/ai-core-server.js +8 -6
  78. package/dist/lib/mcp/servers/ai-providers/ai-workflow-tools.d.ts +2 -2
  79. package/dist/lib/mcp/servers/ai-providers/ai-workflow-tools.js +16 -16
  80. package/dist/lib/mcp/unified-registry.d.ts +4 -0
  81. package/dist/lib/mcp/unified-registry.js +42 -9
  82. package/dist/lib/neurolink.d.ts +161 -174
  83. package/dist/lib/neurolink.js +723 -397
  84. package/dist/lib/providers/amazon-bedrock.d.ts +32 -0
  85. package/dist/lib/providers/amazon-bedrock.js +143 -0
  86. package/dist/lib/providers/analytics-helper.js +7 -4
  87. package/dist/lib/providers/anthropic-baseprovider.d.ts +23 -0
  88. package/dist/lib/providers/anthropic-baseprovider.js +114 -0
  89. package/dist/lib/providers/anthropic.d.ts +19 -39
  90. package/dist/lib/providers/anthropic.js +84 -378
  91. package/dist/lib/providers/azure-openai.d.ts +20 -0
  92. package/dist/lib/providers/azure-openai.js +89 -0
  93. package/dist/lib/providers/function-calling-provider.d.ts +14 -12
  94. package/dist/lib/providers/function-calling-provider.js +114 -64
  95. package/dist/lib/providers/google-ai-studio.d.ts +23 -0
  96. package/dist/lib/providers/google-ai-studio.js +107 -0
  97. package/dist/lib/providers/google-vertex.d.ts +47 -0
  98. package/dist/lib/providers/google-vertex.js +205 -0
  99. package/dist/lib/providers/huggingFace.d.ts +33 -27
  100. package/dist/lib/providers/huggingFace.js +103 -400
  101. package/dist/lib/providers/index.d.ts +9 -9
  102. package/dist/lib/providers/index.js +9 -9
  103. package/dist/lib/providers/mcp-provider.d.ts +13 -8
  104. package/dist/lib/providers/mcp-provider.js +63 -18
  105. package/dist/lib/providers/mistral.d.ts +42 -0
  106. package/dist/lib/providers/mistral.js +160 -0
  107. package/dist/lib/providers/ollama.d.ts +52 -35
  108. package/dist/lib/providers/ollama.js +297 -477
  109. package/dist/lib/providers/openAI.d.ts +21 -21
  110. package/dist/lib/providers/openAI.js +81 -245
  111. package/dist/lib/sdk/tool-extension.d.ts +181 -0
  112. package/dist/lib/sdk/tool-extension.js +283 -0
  113. package/dist/lib/sdk/tool-registration.d.ts +95 -0
  114. package/dist/lib/sdk/tool-registration.js +167 -0
  115. package/dist/lib/types/generate-types.d.ts +80 -0
  116. package/dist/lib/types/generate-types.js +1 -0
  117. package/dist/lib/types/mcp-types.d.ts +116 -0
  118. package/dist/lib/types/mcp-types.js +5 -0
  119. package/dist/lib/types/stream-types.d.ts +95 -0
  120. package/dist/lib/types/stream-types.js +1 -0
  121. package/dist/lib/types/universal-provider-options.d.ts +87 -0
  122. package/dist/lib/types/universal-provider-options.js +53 -0
  123. package/dist/lib/utils/providerUtils-fixed.js +1 -1
  124. package/dist/lib/utils/streaming-utils.d.ts +14 -2
  125. package/dist/lib/utils/streaming-utils.js +0 -3
  126. package/dist/mcp/client.js +5 -5
  127. package/dist/mcp/config.js +28 -3
  128. package/dist/mcp/dynamic-orchestrator.js +8 -8
  129. package/dist/mcp/external-client.js +2 -2
  130. package/dist/mcp/factory.d.ts +1 -1
  131. package/dist/mcp/factory.js +1 -1
  132. package/dist/mcp/function-calling.js +1 -1
  133. package/dist/mcp/initialize-tools.d.ts +1 -1
  134. package/dist/mcp/initialize-tools.js +45 -1
  135. package/dist/mcp/initialize.js +16 -6
  136. package/dist/mcp/neurolink-mcp-client.js +10 -10
  137. package/dist/mcp/orchestrator.js +4 -4
  138. package/dist/mcp/servers/agent/direct-tools-server.d.ts +8 -0
  139. package/dist/mcp/servers/agent/direct-tools-server.js +109 -0
  140. package/dist/mcp/servers/ai-providers/ai-analysis-tools.js +10 -10
  141. package/dist/mcp/servers/ai-providers/ai-core-server.js +8 -6
  142. package/dist/mcp/servers/ai-providers/ai-workflow-tools.d.ts +2 -2
  143. package/dist/mcp/servers/ai-providers/ai-workflow-tools.js +16 -16
  144. package/dist/mcp/unified-registry.d.ts +4 -0
  145. package/dist/mcp/unified-registry.js +42 -9
  146. package/dist/neurolink.d.ts +161 -174
  147. package/dist/neurolink.js +723 -397
  148. package/dist/providers/amazon-bedrock.d.ts +32 -0
  149. package/dist/providers/amazon-bedrock.js +143 -0
  150. package/dist/providers/analytics-helper.js +7 -4
  151. package/dist/providers/anthropic-baseprovider.d.ts +23 -0
  152. package/dist/providers/anthropic-baseprovider.js +114 -0
  153. package/dist/providers/anthropic.d.ts +19 -39
  154. package/dist/providers/anthropic.js +83 -377
  155. package/dist/providers/azure-openai.d.ts +20 -0
  156. package/dist/providers/azure-openai.js +89 -0
  157. package/dist/providers/function-calling-provider.d.ts +14 -12
  158. package/dist/providers/function-calling-provider.js +114 -64
  159. package/dist/providers/google-ai-studio.d.ts +23 -0
  160. package/dist/providers/google-ai-studio.js +108 -0
  161. package/dist/providers/google-vertex.d.ts +47 -0
  162. package/dist/providers/google-vertex.js +205 -0
  163. package/dist/providers/huggingFace.d.ts +33 -27
  164. package/dist/providers/huggingFace.js +102 -399
  165. package/dist/providers/index.d.ts +9 -9
  166. package/dist/providers/index.js +9 -9
  167. package/dist/providers/mcp-provider.d.ts +13 -8
  168. package/dist/providers/mcp-provider.js +63 -18
  169. package/dist/providers/mistral.d.ts +42 -0
  170. package/dist/providers/mistral.js +160 -0
  171. package/dist/providers/ollama.d.ts +52 -35
  172. package/dist/providers/ollama.js +297 -476
  173. package/dist/providers/openAI.d.ts +21 -21
  174. package/dist/providers/openAI.js +81 -246
  175. package/dist/sdk/tool-extension.d.ts +181 -0
  176. package/dist/sdk/tool-extension.js +283 -0
  177. package/dist/sdk/tool-registration.d.ts +95 -0
  178. package/dist/sdk/tool-registration.js +168 -0
  179. package/dist/types/generate-types.d.ts +80 -0
  180. package/dist/types/generate-types.js +1 -0
  181. package/dist/types/mcp-types.d.ts +116 -0
  182. package/dist/types/mcp-types.js +5 -0
  183. package/dist/types/stream-types.d.ts +95 -0
  184. package/dist/types/stream-types.js +1 -0
  185. package/dist/types/universal-provider-options.d.ts +87 -0
  186. package/dist/types/universal-provider-options.js +53 -0
  187. package/dist/utils/providerUtils-fixed.js +1 -1
  188. package/dist/utils/streaming-utils.d.ts +14 -2
  189. package/dist/utils/streaming-utils.js +0 -3
  190. package/package.json +15 -10
  191. package/dist/lib/providers/agent-enhanced-provider.d.ts +0 -89
  192. package/dist/lib/providers/agent-enhanced-provider.js +0 -614
  193. package/dist/lib/providers/amazonBedrock.d.ts +0 -19
  194. package/dist/lib/providers/amazonBedrock.js +0 -334
  195. package/dist/lib/providers/azureOpenAI.d.ts +0 -39
  196. package/dist/lib/providers/azureOpenAI.js +0 -436
  197. package/dist/lib/providers/googleAIStudio.d.ts +0 -49
  198. package/dist/lib/providers/googleAIStudio.js +0 -333
  199. package/dist/lib/providers/googleVertexAI.d.ts +0 -38
  200. package/dist/lib/providers/googleVertexAI.js +0 -519
  201. package/dist/lib/providers/mistralAI.d.ts +0 -34
  202. package/dist/lib/providers/mistralAI.js +0 -294
  203. package/dist/providers/agent-enhanced-provider.d.ts +0 -89
  204. package/dist/providers/agent-enhanced-provider.js +0 -614
  205. package/dist/providers/amazonBedrock.d.ts +0 -19
  206. package/dist/providers/amazonBedrock.js +0 -334
  207. package/dist/providers/azureOpenAI.d.ts +0 -39
  208. package/dist/providers/azureOpenAI.js +0 -437
  209. package/dist/providers/googleAIStudio.d.ts +0 -49
  210. package/dist/providers/googleAIStudio.js +0 -333
  211. package/dist/providers/googleVertexAI.d.ts +0 -38
  212. package/dist/providers/googleVertexAI.js +0 -519
  213. package/dist/providers/mistralAI.d.ts +0 -34
  214. 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 { AgentEnhancedProvider } from "../lib/providers/agent-enhanced-provider.js";
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 Text Command
293
- .command(["generate-text [prompt]", "generate [prompt]", "gen [prompt]"], "Generate text using AI providers", (yargsInstance) => yargsInstance
294
- .usage("Usage: $0 generate-text [prompt] [options]")
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-text "Hello world"', "Basic text generation")
382
- .example('$0 generate-text "Write a story" --provider openai', "Use specific provider")
383
- .example('$0 generate-text "What time is it?"', "Use with natural tool integration (default)")
384
- .example('$0 generate-text "Hello world" --disable-tools', "Use without tool integration"), async (argv) => {
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
- // Check if generate-text was used specifically (for deprecation warning)
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" && !argv.quiet) {
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
- if (argv.disableTools === true) {
471
- // Tools disabled - use standard SDK
472
- generatePromise = sdk.generateText({
473
- prompt: argv.prompt,
474
- provider: argv.provider === "auto"
475
- ? undefined
476
- : argv.provider,
477
- model: argv.model,
478
- temperature: argv.temperature,
479
- maxTokens: argv.maxTokens,
480
- systemPrompt: argv.system,
481
- timeout: argv.timeout,
482
- // NEW: Analytics and evaluation support
483
- enableAnalytics: argv.enableAnalytics,
484
- enableEvaluation: argv.enableEvaluation,
485
- context: contextObj,
486
- // NEW: Lighthouse-compatible domain-aware evaluation
487
- evaluationDomain: argv.evaluationDomain,
488
- toolUsageContext: argv.toolUsageContext,
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 text generation in real-time", (yargsInstance) => yargsInstance
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
- let stream;
751
- if (argv.disableTools === true) {
752
- // Tools disabled - use standard SDK
753
- stream = await sdk.generateTextStream({
754
- prompt: argv.prompt,
755
- provider: argv.provider === "auto"
756
- ? undefined
757
- : argv.provider,
758
- model: argv.model,
759
- temperature: argv.temperature,
760
- timeout: argv.timeout,
761
- // NEW: Analytics and evaluation support
762
- enableAnalytics: argv.enableAnalytics,
763
- enableEvaluation: argv.enableEvaluation,
764
- context: contextObj,
765
- });
766
- }
767
- else {
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
- } // Ensure newline after stream
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.generateText({
915
- prompt: prompts[i],
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.generateText({
1078
- prompt: "test",
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.example("$0 status", "Quick provider status check"), async (argv) => {
1139
- // Simply redirect to provider status
1140
- process.argv = [
1141
- process.argv[0],
1142
- process.argv[1],
1143
- "provider",
1144
- "status",
1145
- ...process.argv.slice(3),
1146
- ];
1147
- const { hideBin } = await import("yargs/helpers");
1148
- const redirectedCli = yargs(hideBin(process.argv));
1149
- // Re-run with provider status
1150
- await cli.parse("provider status");
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.generateText({ prompt: "test", provider, maxTokens: 1 });
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-text "Hello, AI!"'));
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."));