@juspay/neurolink 7.8.0 → 7.10.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 (52) hide show
  1. package/CHANGELOG.md +22 -5
  2. package/README.md +22 -7
  3. package/dist/agent/directTools.d.ts +23 -843
  4. package/dist/agent/directTools.js +1 -3
  5. package/dist/cli/commands/mcp.js +66 -27
  6. package/dist/cli/commands/ollama.js +7 -3
  7. package/dist/cli/commands/sagemaker.js +145 -144
  8. package/dist/cli/factories/commandFactory.js +10 -6
  9. package/dist/core/dynamicModels.js +6 -0
  10. package/dist/core/types.d.ts +15 -4
  11. package/dist/core/types.js +23 -3
  12. package/dist/factories/providerFactory.js +10 -1
  13. package/dist/factories/providerRegistry.js +1 -1
  14. package/dist/lib/agent/directTools.d.ts +23 -843
  15. package/dist/lib/agent/directTools.js +1 -3
  16. package/dist/lib/core/dynamicModels.js +6 -0
  17. package/dist/lib/core/types.d.ts +15 -4
  18. package/dist/lib/core/types.js +23 -3
  19. package/dist/lib/factories/providerFactory.js +10 -1
  20. package/dist/lib/factories/providerRegistry.js +1 -1
  21. package/dist/lib/neurolink.d.ts +15 -0
  22. package/dist/lib/neurolink.js +73 -1
  23. package/dist/lib/providers/googleVertex.d.ts +4 -0
  24. package/dist/lib/providers/googleVertex.js +44 -3
  25. package/dist/lib/providers/sagemaker/client.js +2 -2
  26. package/dist/lib/sdk/toolRegistration.d.ts +1 -1
  27. package/dist/lib/sdk/toolRegistration.js +13 -5
  28. package/dist/lib/utils/providerHealth.js +20 -5
  29. package/dist/mcp/servers/agent/directToolsServer.js +0 -1
  30. package/dist/mcp/servers/aiProviders/aiCoreServer.js +0 -1
  31. package/dist/models/modelResolver.js +0 -1
  32. package/dist/neurolink.d.ts +15 -0
  33. package/dist/neurolink.js +73 -1
  34. package/dist/providers/amazonBedrock.js +2 -2
  35. package/dist/providers/anthropic.js +2 -2
  36. package/dist/providers/anthropicBaseProvider.js +2 -2
  37. package/dist/providers/googleAiStudio.js +2 -3
  38. package/dist/providers/googleVertex.d.ts +4 -0
  39. package/dist/providers/googleVertex.js +44 -3
  40. package/dist/providers/litellm.js +4 -4
  41. package/dist/providers/ollama.js +1 -2
  42. package/dist/providers/openAI.js +2 -2
  43. package/dist/providers/openaiCompatible.js +1 -2
  44. package/dist/providers/sagemaker/client.js +2 -2
  45. package/dist/providers/sagemaker/errors.js +1 -1
  46. package/dist/providers/sagemaker/language-model.js +1 -1
  47. package/dist/sdk/toolRegistration.d.ts +1 -1
  48. package/dist/sdk/toolRegistration.js +13 -6
  49. package/dist/telemetry/telemetryService.js +0 -2
  50. package/dist/types/tools.js +0 -1
  51. package/dist/utils/providerHealth.js +20 -5
  52. package/package.json +43 -5
@@ -8,6 +8,7 @@ import chalk from "chalk";
8
8
  import ora from "ora";
9
9
  import inquirer from "inquirer";
10
10
  import { SageMakerClient, ListEndpointsCommand, } from "@aws-sdk/client-sagemaker";
11
+ import { logger } from "../../lib/utils/logger.js";
11
12
  import { checkSageMakerConfiguration, getSageMakerConfig, getConfigurationSummary, clearConfigurationCache, } from "../../lib/providers/sagemaker/config.js";
12
13
  import { AmazonSageMakerProvider } from "../../lib/providers/sagemaker/index.js";
13
14
  import { runQuickDiagnostics, formatDiagnosticReport, } from "../../lib/providers/sagemaker/diagnostics.js";
@@ -176,35 +177,35 @@ async function statusHandler() {
176
177
  try {
177
178
  const status = checkSageMakerConfiguration();
178
179
  spinner.stop();
179
- console.log(chalk.blue("\nšŸ” SageMaker Configuration Status\n"));
180
+ logger.always(chalk.blue("\nšŸ” SageMaker Configuration Status\n"));
180
181
  if (status.configured) {
181
- console.log(chalk.green("āœ… Configuration: Valid"));
182
+ logger.always(chalk.green("āœ… Configuration: Valid"));
182
183
  }
183
184
  else {
184
- console.log(chalk.red("āŒ Configuration: Invalid"));
185
+ logger.always(chalk.red("āŒ Configuration: Invalid"));
185
186
  }
186
187
  if (status.issues.length > 0) {
187
- console.log(chalk.yellow("\nāš ļø Issues found:"));
188
+ logger.always(chalk.yellow("\nāš ļø Issues found:"));
188
189
  status.issues.forEach((issue) => {
189
- console.log(` • ${issue}`);
190
+ logger.always(` • ${issue}`);
190
191
  });
191
192
  }
192
193
  // Show configuration summary (safe for display)
193
194
  if (status.summary) {
194
- console.log(chalk.blue("\nšŸ“‹ Configuration Summary:"));
195
+ logger.always(chalk.blue("\nšŸ“‹ Configuration Summary:"));
195
196
  if (typeof status.summary === "object" && status.summary.aws) {
196
197
  const aws = status.summary.aws;
197
- console.log(` Region: ${aws.region}`);
198
- console.log(` Access Key: ${aws.accessKeyId}`);
199
- console.log(` Timeout: ${aws.timeout}ms`);
200
- console.log(` Max Retries: ${aws.maxRetries}`);
198
+ logger.always(` Region: ${aws.region}`);
199
+ logger.always(` Access Key: ${aws.accessKeyId}`);
200
+ logger.always(` Timeout: ${aws.timeout}ms`);
201
+ logger.always(` Max Retries: ${aws.maxRetries}`);
201
202
  }
202
203
  }
203
204
  process.exit(status.configured ? 0 : 1);
204
205
  }
205
206
  catch (error) {
206
207
  spinner.fail("Failed to check SageMaker configuration");
207
- console.error(chalk.red(`Error: ${error instanceof Error ? error.message : String(error)}`));
208
+ logger.error(chalk.red(`Error: ${error instanceof Error ? error.message : String(error)}`));
208
209
  process.exit(1);
209
210
  }
210
211
  }
@@ -219,7 +220,7 @@ async function testEndpointHandler(argv) {
219
220
  const status = checkSageMakerConfiguration();
220
221
  if (!status.configured) {
221
222
  spinner.fail("SageMaker configuration is invalid");
222
- console.error(chalk.red("Please run 'neurolink sagemaker setup' first"));
223
+ logger.error(chalk.red("Please run 'neurolink sagemaker setup' first"));
223
224
  process.exit(1);
224
225
  }
225
226
  // Create provider and test connectivity
@@ -244,26 +245,26 @@ async function testEndpointHandler(argv) {
244
245
  maxTokens: 50,
245
246
  });
246
247
  spinner.succeed("āœ… Text generation test successful");
247
- console.log(chalk.blue("\nšŸ“ Test Response:"));
248
- console.log(` Input: "${prompt}"`);
249
- console.log(` Output: "${result.text?.substring(0, 100)}${result.text && result.text.length > 100 ? "..." : ""}"`);
250
- console.log(` Tokens: ${result.usage.promptTokens} → ${result.usage.completionTokens} (${result.usage.totalTokens ?? result.usage.promptTokens + result.usage.completionTokens} total)`);
251
- console.log(` Finish Reason: ${result.finishReason}`);
248
+ logger.always(chalk.blue("\nšŸ“ Test Response:"));
249
+ logger.always(` Input: "${prompt}"`);
250
+ logger.always(` Output: "${result.text?.substring(0, 100)}${result.text && result.text.length > 100 ? "..." : ""}"`);
251
+ logger.always(` Tokens: ${result.usage.promptTokens} → ${result.usage.completionTokens} (${result.usage.totalTokens ?? result.usage.promptTokens + result.usage.completionTokens} total)`);
252
+ logger.always(` Finish Reason: ${result.finishReason}`);
252
253
  }
253
254
  catch (genError) {
254
255
  spinner.fail("āŒ Text generation test failed");
255
- console.error(chalk.red(`Generation Error: ${genError instanceof Error ? genError.message : String(genError)}`));
256
+ logger.error(chalk.red(`Generation Error: ${genError instanceof Error ? genError.message : String(genError)}`));
256
257
  }
257
258
  }
258
259
  else {
259
260
  spinner.fail(`āŒ Endpoint '${endpoint}' is not accessible`);
260
- console.error(chalk.red(`Error: ${testResult.error}`));
261
+ logger.error(chalk.red(`Error: ${testResult.error}`));
261
262
  process.exit(1);
262
263
  }
263
264
  }
264
265
  catch (error) {
265
266
  spinner.fail("Failed to test SageMaker endpoint");
266
- console.error(chalk.red(`Error: ${error instanceof Error ? error.message : String(error)}`));
267
+ logger.error(chalk.red(`Error: ${error instanceof Error ? error.message : String(error)}`));
267
268
  process.exit(1);
268
269
  }
269
270
  }
@@ -290,34 +291,34 @@ async function listEndpointsHandler() {
290
291
  const endpoints = { Endpoints: response.Endpoints || [] };
291
292
  spinner.stop();
292
293
  if (endpoints.Endpoints && endpoints.Endpoints.length > 0) {
293
- console.log(chalk.blue("\nšŸ”— Available SageMaker Endpoints:\n"));
294
+ logger.always(chalk.blue("\nšŸ”— Available SageMaker Endpoints:\n"));
294
295
  endpoints.Endpoints.forEach((endpoint, index) => {
295
- console.log(`${index + 1}. ${chalk.green(endpoint.EndpointName)}`);
296
- console.log(` Status: ${endpoint.EndpointStatus}`);
297
- console.log(` Created: ${endpoint.CreationTime?.toLocaleDateString() ?? "Unknown"}`);
296
+ logger.always(`${index + 1}. ${chalk.green(endpoint.EndpointName)}`);
297
+ logger.always(` Status: ${endpoint.EndpointStatus}`);
298
+ logger.always(` Created: ${endpoint.CreationTime?.toLocaleDateString() ?? "Unknown"}`);
298
299
  if (endpoint.LastModifiedTime) {
299
- console.log(` Modified: ${endpoint.LastModifiedTime.toLocaleDateString()}`);
300
+ logger.always(` Modified: ${endpoint.LastModifiedTime.toLocaleDateString()}`);
300
301
  }
301
- console.log();
302
+ logger.always();
302
303
  });
303
304
  }
304
305
  else {
305
- console.log(chalk.yellow("No SageMaker endpoints found"));
306
+ logger.always(chalk.yellow("No SageMaker endpoints found"));
306
307
  }
307
308
  }
308
- catch (awsError) {
309
+ catch (_awsError) {
309
310
  spinner.fail("Failed to list endpoints");
310
- console.error(chalk.red("AWS SDK credentials error or insufficient permissions"));
311
- console.log(chalk.yellow("\nTo list endpoints, please:"));
312
- console.log("1. Set AWS_ACCESS_KEY_ID environment variable");
313
- console.log("2. Set AWS_SECRET_ACCESS_KEY environment variable");
314
- console.log("3. Set AWS_REGION environment variable (or use default)");
315
- console.log("4. Ensure you have sagemaker:ListEndpoints permission");
311
+ logger.error(chalk.red("AWS SDK credentials error or insufficient permissions"));
312
+ logger.always(chalk.yellow("\nTo list endpoints, please:"));
313
+ logger.always("1. Set AWS_ACCESS_KEY_ID environment variable");
314
+ logger.always("2. Set AWS_SECRET_ACCESS_KEY environment variable");
315
+ logger.always("3. Set AWS_REGION environment variable (or use default)");
316
+ logger.always("4. Ensure you have sagemaker:ListEndpoints permission");
316
317
  }
317
318
  }
318
319
  catch (error) {
319
320
  spinner.fail("Failed to list SageMaker endpoints");
320
- console.error(chalk.red(`Error: ${error instanceof Error ? error.message : String(error)}`));
321
+ logger.error(chalk.red(`Error: ${error instanceof Error ? error.message : String(error)}`));
321
322
  process.exit(1);
322
323
  }
323
324
  }
@@ -330,9 +331,9 @@ async function configHandler(args) {
330
331
  try {
331
332
  const summary = getConfigurationSummary();
332
333
  spinner.stop();
333
- console.log(chalk.blue("\nāš™ļø SageMaker Configuration\n"));
334
+ logger.always(chalk.blue("\nāš™ļø SageMaker Configuration\n"));
334
335
  if (format === "json") {
335
- console.log(JSON.stringify(summary, null, 2));
336
+ logger.always(JSON.stringify(summary, null, 2));
336
337
  }
337
338
  else if (format === "yaml") {
338
339
  // Simple YAML-like output
@@ -340,11 +341,11 @@ async function configHandler(args) {
340
341
  const spaces = " ".repeat(indent);
341
342
  for (const [key, value] of Object.entries(obj)) {
342
343
  if (typeof value === "object" && value !== null) {
343
- console.log(`${spaces}${key}:`);
344
+ logger.always(`${spaces}${key}:`);
344
345
  printYaml(value, indent + 2);
345
346
  }
346
347
  else {
347
- console.log(`${spaces}${key}: ${value}`);
348
+ logger.always(`${spaces}${key}: ${value}`);
348
349
  }
349
350
  }
350
351
  }
@@ -358,33 +359,33 @@ async function configHandler(args) {
358
359
  {});
359
360
  const environment = (summary.environment ||
360
361
  {});
361
- console.log(chalk.green("AWS Configuration:"));
362
- console.log(` Region: ${aws.region}`);
363
- console.log(` Access Key: ${aws.accessKeyId}`);
364
- console.log(` Secret Key: ${aws.secretAccessKey}`);
365
- console.log(` Session Token: ${aws.sessionToken}`);
366
- console.log(` Timeout: ${aws.timeout}ms`);
367
- console.log(` Max Retries: ${aws.maxRetries}`);
368
- console.log(` Custom Endpoint: ${aws.endpoint || "None"}`);
369
- console.log(chalk.blue("\nSageMaker Configuration:"));
370
- console.log(` Default Endpoint: ${sagemaker.defaultEndpoint}`);
371
- console.log(` Model Name: ${sagemaker.model}`);
362
+ logger.always(chalk.green("AWS Configuration:"));
363
+ logger.always(` Region: ${aws.region}`);
364
+ logger.always(` Access Key: ${aws.accessKeyId}`);
365
+ logger.always(` Secret Key: ${aws.secretAccessKey}`);
366
+ logger.always(` Session Token: ${aws.sessionToken}`);
367
+ logger.always(` Timeout: ${aws.timeout}ms`);
368
+ logger.always(` Max Retries: ${aws.maxRetries}`);
369
+ logger.always(` Custom Endpoint: ${aws.endpoint || "None"}`);
370
+ logger.always(chalk.blue("\nSageMaker Configuration:"));
371
+ logger.always(` Default Endpoint: ${sagemaker.defaultEndpoint}`);
372
+ logger.always(` Model Name: ${sagemaker.model}`);
372
373
  if (sagemaker.modelConfig) {
373
374
  const modelConfig = sagemaker.modelConfig;
374
- console.log(` Model Type: ${modelConfig.modelType}`);
375
- console.log(` Content Type: ${modelConfig.contentType}`);
376
- console.log(` Accept: ${modelConfig.accept}`);
375
+ logger.always(` Model Type: ${modelConfig.modelType}`);
376
+ logger.always(` Content Type: ${modelConfig.contentType}`);
377
+ logger.always(` Accept: ${modelConfig.accept}`);
377
378
  }
378
- console.log(chalk.yellow("\nEnvironment:"));
379
- console.log(` Node Environment: ${environment.nodeEnv}`);
380
- console.log(` SageMaker Configured: ${environment.sagemakerConfigured ? "Yes" : "No"}`);
381
- console.log(` AWS Configured: ${environment.awsConfigured ? "Yes" : "No"}`);
379
+ logger.always(chalk.yellow("\nEnvironment:"));
380
+ logger.always(` Node Environment: ${environment.nodeEnv}`);
381
+ logger.always(` SageMaker Configured: ${environment.sagemakerConfigured ? "Yes" : "No"}`);
382
+ logger.always(` AWS Configured: ${environment.awsConfigured ? "Yes" : "No"}`);
382
383
  }
383
384
  }
384
385
  }
385
386
  catch (error) {
386
387
  spinner.fail("Failed to load SageMaker configuration");
387
- console.error(chalk.red(`Error: ${error instanceof Error ? error.message : String(error)}`));
388
+ logger.error(chalk.red(`Error: ${error instanceof Error ? error.message : String(error)}`));
388
389
  process.exit(1);
389
390
  }
390
391
  }
@@ -392,9 +393,9 @@ async function configHandler(args) {
392
393
  * Handler for interactive setup
393
394
  */
394
395
  async function setupHandler() {
395
- console.log(chalk.blue("\nšŸš€ SageMaker Interactive Setup\n"));
396
+ logger.always(chalk.blue("\nšŸš€ SageMaker Interactive Setup\n"));
396
397
  // Pre-setup security advisory
397
- console.log(chalk.yellow.bold("šŸ”’ SECURITY NOTICE: You will be prompted to enter AWS credentials.\n" +
398
+ logger.always(chalk.yellow.bold("šŸ”’ SECURITY NOTICE: You will be prompted to enter AWS credentials.\n" +
398
399
  "These credentials will be stored temporarily in memory only.\n" +
399
400
  "For production use, consider using AWS credential files or IAM roles.\n"));
400
401
  // Ask for user confirmation before proceeding
@@ -407,11 +408,11 @@ async function setupHandler() {
407
408
  },
408
409
  ]);
409
410
  if (!confirmSetup) {
410
- console.log(chalk.blue("\nSetup cancelled. Consider using alternative credential methods:"));
411
- console.log("• AWS credential files: ~/.aws/credentials");
412
- console.log("• Environment variables in .env file");
413
- console.log("• AWS CLI configuration: aws configure");
414
- console.log("• IAM roles for production environments");
411
+ logger.always(chalk.blue("\nSetup cancelled. Consider using alternative credential methods:"));
412
+ logger.always("• AWS credential files: ~/.aws/credentials");
413
+ logger.always("• Environment variables in .env file");
414
+ logger.always("• AWS CLI configuration: aws configure");
415
+ logger.always("• IAM roles for production environments");
415
416
  return;
416
417
  }
417
418
  try {
@@ -456,8 +457,8 @@ async function setupHandler() {
456
457
  const spinner = ora("Setting up SageMaker configuration...").start();
457
458
  // Enhanced security warnings for credential handling
458
459
  spinner.stop();
459
- console.log(chalk.red.bold("\nšŸ”’ CRITICAL SECURITY WARNINGS\n"));
460
- console.log(chalk.yellow.bold("āš ļø CREDENTIAL PERSISTENCE: AWS credentials will only be set for this session.\n" +
460
+ logger.always(chalk.red.bold("\nšŸ”’ CRITICAL SECURITY WARNINGS\n"));
461
+ logger.always(chalk.yellow.bold("āš ļø CREDENTIAL PERSISTENCE: AWS credentials will only be set for this session.\n" +
461
462
  " They will NOT persist after you exit the CLI.\n\n" +
462
463
  "šŸ” SECURE STORAGE OPTIONS:\n" +
463
464
  " • Use environment variables in a secure .env file (never commit to git)\n" +
@@ -495,17 +496,17 @@ async function setupHandler() {
495
496
  try {
496
497
  validateSecureConfiguration(secureConfig); // Validate configuration is loadable
497
498
  spinner.succeed("āœ… Configuration validated successfully");
498
- console.log(chalk.green("\nšŸŽ‰ SageMaker setup complete!"));
499
- console.log(chalk.yellow("\nšŸ’” Next steps:"));
500
- console.log("1. Test your endpoint: neurolink sagemaker test <endpoint-name>");
501
- console.log("2. Check status: neurolink sagemaker status");
502
- console.log("3. List endpoints: neurolink sagemaker list-endpoints");
503
- console.log(chalk.blue("\nšŸ”’ Secure configuration validated:"));
504
- console.log(" āœ“ AWS credentials verified");
505
- console.log(" āœ“ AWS region validated");
506
- console.log(" āœ“ SageMaker endpoint configured");
507
- console.log(" āœ“ Timeout and retry settings applied");
508
- console.log(chalk.yellow("\nāš ļø For persistent configuration, add these to your .env file:\n" +
499
+ logger.always(chalk.green("\nšŸŽ‰ SageMaker setup complete!"));
500
+ logger.always(chalk.yellow("\nšŸ’” Next steps:"));
501
+ logger.always("1. Test your endpoint: neurolink sagemaker test <endpoint-name>");
502
+ logger.always("2. Check status: neurolink sagemaker status");
503
+ logger.always("3. List endpoints: neurolink sagemaker list-endpoints");
504
+ logger.always(chalk.blue("\nšŸ”’ Secure configuration validated:"));
505
+ logger.always(" āœ“ AWS credentials verified");
506
+ logger.always(" āœ“ AWS region validated");
507
+ logger.always(" āœ“ SageMaker endpoint configured");
508
+ logger.always(" āœ“ Timeout and retry settings applied");
509
+ logger.always(chalk.yellow("\nāš ļø For persistent configuration, add these to your .env file:\n" +
509
510
  " AWS_ACCESS_KEY_ID=your_access_key\n" +
510
511
  " AWS_SECRET_ACCESS_KEY=your_secret_key\n" +
511
512
  " AWS_REGION=" +
@@ -525,14 +526,14 @@ async function setupHandler() {
525
526
  }
526
527
  catch (configError) {
527
528
  spinner.fail("āŒ Configuration validation failed");
528
- console.error(chalk.red(`Error: ${configError instanceof Error ? configError.message : String(configError)}`));
529
+ logger.error(chalk.red(`Error: ${configError instanceof Error ? configError.message : String(configError)}`));
529
530
  // Clear secure credentials from memory on error
530
531
  clearSecureCredentials(secureConfig.sessionId);
531
532
  process.exit(1);
532
533
  }
533
534
  }
534
535
  catch (error) {
535
- console.error(chalk.red(`Setup failed: ${error instanceof Error ? error.message : String(error)}`));
536
+ logger.error(chalk.red(`Setup failed: ${error instanceof Error ? error.message : String(error)}`));
536
537
  process.exit(1);
537
538
  }
538
539
  }
@@ -544,27 +545,27 @@ async function validateHandler() {
544
545
  try {
545
546
  const status = checkSageMakerConfiguration();
546
547
  spinner.stop();
547
- console.log(chalk.blue("\nšŸ” Configuration Validation Results\n"));
548
+ logger.always(chalk.blue("\nšŸ” Configuration Validation Results\n"));
548
549
  if (status.configured) {
549
- console.log(chalk.green("āœ… All checks passed"));
550
- console.log(chalk.blue("šŸš€ SageMaker is ready to use"));
550
+ logger.always(chalk.green("āœ… All checks passed"));
551
+ logger.always(chalk.blue("šŸš€ SageMaker is ready to use"));
551
552
  }
552
553
  else {
553
- console.log(chalk.red("āŒ Configuration validation failed"));
554
+ logger.always(chalk.red("āŒ Configuration validation failed"));
554
555
  if (status.issues.length > 0) {
555
- console.log(chalk.yellow("\nšŸ”§ Issues to fix:"));
556
+ logger.always(chalk.yellow("\nšŸ”§ Issues to fix:"));
556
557
  status.issues.forEach((issue, index) => {
557
- console.log(`${index + 1}. ${issue}`);
558
+ logger.always(`${index + 1}. ${issue}`);
558
559
  });
559
560
  }
560
- console.log(chalk.blue("\nšŸ’” How to fix:"));
561
- console.log("Run: neurolink sagemaker setup");
561
+ logger.always(chalk.blue("\nšŸ’” How to fix:"));
562
+ logger.always("Run: neurolink sagemaker setup");
562
563
  process.exit(1);
563
564
  }
564
565
  }
565
566
  catch (error) {
566
567
  spinner.fail("Validation failed");
567
- console.error(chalk.red(`Error: ${error instanceof Error ? error.message : String(error)}`));
568
+ logger.error(chalk.red(`Error: ${error instanceof Error ? error.message : String(error)}`));
568
569
  process.exit(1);
569
570
  }
570
571
  }
@@ -573,18 +574,18 @@ async function validateHandler() {
573
574
  */
574
575
  async function benchmarkHandler(argv) {
575
576
  const { endpoint, requests = 10, concurrency = 2, maxTokens = 100 } = argv;
576
- console.log(chalk.blue(`\n⚔ SageMaker Performance Benchmark\n`));
577
- console.log(`Endpoint: ${endpoint}`);
578
- console.log(`Requests: ${requests}`);
579
- console.log(`Concurrency: ${concurrency}`);
580
- console.log(`Max Tokens: ${maxTokens}\n`);
577
+ logger.always(chalk.blue(`\n⚔ SageMaker Performance Benchmark\n`));
578
+ logger.always(`Endpoint: ${endpoint}`);
579
+ logger.always(`Requests: ${requests}`);
580
+ logger.always(`Concurrency: ${concurrency}`);
581
+ logger.always(`Max Tokens: ${maxTokens}\n`);
581
582
  const spinner = ora("Setting up benchmark...").start();
582
583
  try {
583
584
  // Check configuration first
584
585
  const status = checkSageMakerConfiguration();
585
586
  if (!status.configured) {
586
587
  spinner.fail("SageMaker configuration is invalid");
587
- console.error(chalk.red("Please run 'neurolink sagemaker setup' first"));
588
+ logger.error(chalk.red("Please run 'neurolink sagemaker setup' first"));
588
589
  process.exit(1);
589
590
  }
590
591
  const provider = new AmazonSageMakerProvider(undefined, endpoint);
@@ -593,7 +594,7 @@ async function benchmarkHandler(argv) {
593
594
  const connectivityTest = await provider.testConnectivity();
594
595
  if (!connectivityTest.success) {
595
596
  spinner.fail(`Endpoint '${endpoint}' is not accessible`);
596
- console.error(chalk.red(`Error: ${connectivityTest.error}`));
597
+ logger.error(chalk.red(`Error: ${connectivityTest.error}`));
597
598
  process.exit(1);
598
599
  }
599
600
  spinner.text = "Starting benchmark...";
@@ -651,35 +652,35 @@ async function benchmarkHandler(argv) {
651
652
  const failed = results.filter((r) => !r.success);
652
653
  const durations = successful.map((r) => r.duration);
653
654
  const totalTokens = successful.reduce((sum, r) => sum + r.tokens, 0);
654
- console.log(chalk.green("\nšŸ“Š Benchmark Results\n"));
655
- console.log(`Total Time: ${totalTime}ms`);
656
- console.log(`Successful Requests: ${successful.length}/${requests}`);
657
- console.log(`Failed Requests: ${failed.length}`);
658
- console.log(`Success Rate: ${((successful.length / requests) * 100).toFixed(1)}%`);
655
+ logger.always(chalk.green("\nšŸ“Š Benchmark Results\n"));
656
+ logger.always(`Total Time: ${totalTime}ms`);
657
+ logger.always(`Successful Requests: ${successful.length}/${requests}`);
658
+ logger.always(`Failed Requests: ${failed.length}`);
659
+ logger.always(`Success Rate: ${((successful.length / requests) * 100).toFixed(1)}%`);
659
660
  if (successful.length > 0) {
660
- console.log(`\nLatency Statistics:`);
661
- console.log(` Average: ${(durations.reduce((a, b) => a + b, 0) / durations.length).toFixed(0)}ms`);
662
- console.log(` Minimum: ${Math.min(...durations)}ms`);
663
- console.log(` Maximum: ${Math.max(...durations)}ms`);
664
- console.log(` Median: ${durations.sort((a, b) => a - b)[Math.floor(durations.length / 2)]}ms`);
665
- console.log(`\nThroughput:`);
666
- console.log(` Requests/sec: ${(successful.length / (totalTime / 1000)).toFixed(2)}`);
667
- console.log(` Tokens/sec: ${(totalTokens / (totalTime / 1000)).toFixed(2)}`);
668
- console.log(` Average tokens/request: ${(totalTokens / successful.length).toFixed(1)}`);
661
+ logger.always(`\nLatency Statistics:`);
662
+ logger.always(` Average: ${(durations.reduce((a, b) => a + b, 0) / durations.length).toFixed(0)}ms`);
663
+ logger.always(` Minimum: ${Math.min(...durations)}ms`);
664
+ logger.always(` Maximum: ${Math.max(...durations)}ms`);
665
+ logger.always(` Median: ${durations.sort((a, b) => a - b)[Math.floor(durations.length / 2)]}ms`);
666
+ logger.always(`\nThroughput:`);
667
+ logger.always(` Requests/sec: ${(successful.length / (totalTime / 1000)).toFixed(2)}`);
668
+ logger.always(` Tokens/sec: ${(totalTokens / (totalTime / 1000)).toFixed(2)}`);
669
+ logger.always(` Average tokens/request: ${(totalTokens / successful.length).toFixed(1)}`);
669
670
  }
670
671
  if (failed.length > 0) {
671
- console.log(chalk.red(`\nāŒ Failed Requests (${failed.length}):`));
672
+ logger.always(chalk.red(`\nāŒ Failed Requests (${failed.length}):`));
672
673
  failed.slice(0, 5).forEach((failure, index) => {
673
- console.log(` ${index + 1}. ${failure.error}`);
674
+ logger.always(` ${index + 1}. ${failure.error}`);
674
675
  });
675
676
  if (failed.length > 5) {
676
- console.log(` ... and ${failed.length - 5} more`);
677
+ logger.always(` ... and ${failed.length - 5} more`);
677
678
  }
678
679
  }
679
680
  }
680
681
  catch (error) {
681
682
  spinner.fail("Benchmark failed");
682
- console.error(chalk.red(`Error: ${error instanceof Error ? error.message : String(error)}`));
683
+ logger.error(chalk.red(`Error: ${error instanceof Error ? error.message : String(error)}`));
683
684
  process.exit(1);
684
685
  }
685
686
  }
@@ -691,11 +692,11 @@ async function clearCacheHandler() {
691
692
  try {
692
693
  clearConfigurationCache();
693
694
  spinner.succeed("āœ… Configuration cache cleared");
694
- console.log(chalk.blue("Configuration will be reloaded on next use"));
695
+ logger.always(chalk.blue("Configuration will be reloaded on next use"));
695
696
  }
696
697
  catch (error) {
697
698
  spinner.fail("Failed to clear cache");
698
- console.error(chalk.red(`Error: ${error instanceof Error ? error.message : String(error)}`));
699
+ logger.error(chalk.red(`Error: ${error instanceof Error ? error.message : String(error)}`));
699
700
  process.exit(1);
700
701
  }
701
702
  }
@@ -704,15 +705,15 @@ async function clearCacheHandler() {
704
705
  */
705
706
  async function diagnoseHandler(argv) {
706
707
  const { endpoint, quick, full, timeout } = argv;
707
- console.log(chalk.blue(`\nšŸ” SageMaker Streaming Diagnostics\n`));
708
+ logger.always(chalk.blue(`\nšŸ” SageMaker Streaming Diagnostics\n`));
708
709
  if (endpoint) {
709
- console.log(`Endpoint: ${endpoint}`);
710
+ logger.always(`Endpoint: ${endpoint}`);
710
711
  }
711
712
  else {
712
- console.log("Endpoint: Not specified (configuration tests only)");
713
+ logger.always("Endpoint: Not specified (configuration tests only)");
713
714
  }
714
- console.log(`Mode: ${quick ? "Quick" : full ? "Full" : "Standard"}`);
715
- console.log(`Timeout: ${timeout}ms\n`);
715
+ logger.always(`Mode: ${quick ? "Quick" : full ? "Full" : "Standard"}`);
716
+ logger.always(`Timeout: ${timeout}ms\n`);
716
717
  const spinner = ora("Starting diagnostics...").start();
717
718
  try {
718
719
  // Run diagnostics (simplified - advanced streaming diagnostics removed)
@@ -720,59 +721,59 @@ async function diagnoseHandler(argv) {
720
721
  spinner.stop();
721
722
  // Display results
722
723
  const formatted = formatDiagnosticReport(report);
723
- console.log(formatted);
724
+ logger.always(formatted);
724
725
  // Additional insights based on results
725
726
  if (report.overallStatus === "critical") {
726
- console.log(chalk.red("🚨 Critical Issues Detected"));
727
- console.log(chalk.red(" Your streaming configuration has serious problems that need immediate attention."));
728
- console.log(chalk.yellow(" See the recommendations above for resolution steps.\n"));
727
+ logger.always(chalk.red("🚨 Critical Issues Detected"));
728
+ logger.always(chalk.red(" Your streaming configuration has serious problems that need immediate attention."));
729
+ logger.always(chalk.yellow(" See the recommendations above for resolution steps.\n"));
729
730
  }
730
731
  else if (report.overallStatus === "issues") {
731
- console.log(chalk.yellow("āš ļø Issues Detected"));
732
- console.log(chalk.yellow(" Your streaming setup works but has some issues that could affect performance."));
733
- console.log(chalk.blue(" Consider addressing the recommendations above.\n"));
732
+ logger.always(chalk.yellow("āš ļø Issues Detected"));
733
+ logger.always(chalk.yellow(" Your streaming setup works but has some issues that could affect performance."));
734
+ logger.always(chalk.blue(" Consider addressing the recommendations above.\n"));
734
735
  }
735
736
  else {
736
- console.log(chalk.green("āœ… All Systems Go"));
737
- console.log(chalk.green(" Your SageMaker streaming configuration looks healthy!"));
737
+ logger.always(chalk.green("āœ… All Systems Go"));
738
+ logger.always(chalk.green(" Your SageMaker streaming configuration looks healthy!"));
738
739
  if (endpoint) {
739
- console.log(chalk.blue(" You can now use streaming features with confidence.\n"));
740
- console.log(chalk.dim(" Try: neurolink sagemaker stream " + endpoint));
740
+ logger.always(chalk.blue(" You can now use streaming features with confidence.\n"));
741
+ logger.always(chalk.dim(" Try: neurolink sagemaker stream " + endpoint));
741
742
  }
742
743
  }
743
744
  // Show additional help based on findings
744
745
  const failedTests = report.results.filter((r) => r.status === "fail");
745
746
  if (failedTests.length > 0) {
746
- console.log(chalk.blue("šŸ“š Additional Resources:"));
747
+ logger.always(chalk.blue("šŸ“š Additional Resources:"));
747
748
  const hasConnectivityIssues = failedTests.some((t) => t.category === "connectivity");
748
749
  const hasStreamingIssues = failedTests.some((t) => t.category === "streaming");
749
750
  const hasConfigIssues = failedTests.some((t) => t.category === "configuration");
750
751
  if (hasConfigIssues) {
751
- console.log(" • Configuration: neurolink sagemaker setup");
752
+ logger.always(" • Configuration: neurolink sagemaker setup");
752
753
  }
753
754
  if (hasConnectivityIssues) {
754
- console.log(" • Connectivity: neurolink sagemaker test " +
755
+ logger.always(" • Connectivity: neurolink sagemaker test " +
755
756
  (endpoint || "your-endpoint"));
756
757
  }
757
758
  if (hasStreamingIssues) {
758
- console.log(" • Streaming Guide: docs/providers/sagemaker/streaming-troubleshooting.md");
759
+ logger.always(" • Streaming Guide: docs/providers/sagemaker/streaming-troubleshooting.md");
759
760
  }
760
- console.log(" • Full Diagnostics: neurolink sagemaker diagnose " +
761
+ logger.always(" • Full Diagnostics: neurolink sagemaker diagnose " +
761
762
  (endpoint || "") +
762
763
  " --full");
763
- console.log();
764
+ logger.always();
764
765
  }
765
766
  // Exit with appropriate code
766
767
  process.exit(report.overallStatus === "critical" ? 1 : 0);
767
768
  }
768
769
  catch (error) {
769
770
  spinner.fail("Diagnostics failed");
770
- console.error(chalk.red(`Error: ${error instanceof Error ? error.message : String(error)}`));
771
- console.log(chalk.yellow("\nšŸ’” Diagnostic troubleshooting:"));
772
- console.log(" • Check your SageMaker configuration: neurolink sagemaker status");
773
- console.log(" • Verify AWS credentials and permissions");
774
- console.log(" • Try with a specific endpoint: neurolink sagemaker diagnose your-endpoint");
775
- console.log(" • Run quick mode: neurolink sagemaker diagnose --quick");
771
+ logger.error(chalk.red(`Error: ${error instanceof Error ? error.message : String(error)}`));
772
+ logger.always(chalk.yellow("\nšŸ’” Diagnostic troubleshooting:"));
773
+ logger.always(" • Check your SageMaker configuration: neurolink sagemaker status");
774
+ logger.always(" • Verify AWS credentials and permissions");
775
+ logger.always(" • Try with a specific endpoint: neurolink sagemaker diagnose your-endpoint");
776
+ logger.always(" • Run quick mode: neurolink sagemaker diagnose --quick");
776
777
  process.exit(1);
777
778
  }
778
779
  }
@@ -288,8 +288,12 @@ export class CLICommandFactory {
288
288
  let analyticsText = "\n\nšŸ“Š Analytics:\n";
289
289
  // Provider and model info
290
290
  analyticsText += ` Provider: ${analytics.provider}`;
291
- if (result.model) {
292
- analyticsText += ` (${result.model})`;
291
+ // Check for model in multiple locations: result.model, analytics.model, or any model property
292
+ const modelName = result.model ||
293
+ analytics.model ||
294
+ analytics.modelName;
295
+ if (modelName) {
296
+ analyticsText += ` (${modelName})`;
293
297
  }
294
298
  analyticsText += "\n";
295
299
  // Token usage
@@ -448,15 +452,15 @@ export class CLICommandFactory {
448
452
  describe: "Manage NeuroLink configuration",
449
453
  builder: (yargs) => {
450
454
  return yargs
451
- .command("init", "Interactive configuration setup wizard", (y) => this.buildOptions(y), async (argv) => {
455
+ .command("init", "Interactive configuration setup wizard", (y) => this.buildOptions(y), async (_argv) => {
452
456
  const { configManager } = await import("../commands/config.js");
453
457
  await configManager.initInteractive();
454
458
  })
455
- .command("show", "Display current configuration", (y) => this.buildOptions(y), async (argv) => {
459
+ .command("show", "Display current configuration", (y) => this.buildOptions(y), async (_argv) => {
456
460
  const { configManager } = await import("../commands/config.js");
457
461
  configManager.showConfig();
458
462
  })
459
- .command("validate", "Validate current configuration", (y) => this.buildOptions(y), async (argv) => {
463
+ .command("validate", "Validate current configuration", (y) => this.buildOptions(y), async (_argv) => {
460
464
  const { configManager } = await import("../commands/config.js");
461
465
  const result = configManager.validateConfig();
462
466
  if (result.valid) {
@@ -468,7 +472,7 @@ export class CLICommandFactory {
468
472
  process.exit(1);
469
473
  }
470
474
  })
471
- .command("reset", "Reset configuration to defaults", (y) => this.buildOptions(y), async (argv) => {
475
+ .command("reset", "Reset configuration to defaults", (y) => this.buildOptions(y), async (_argv) => {
472
476
  const { configManager } = await import("../commands/config.js");
473
477
  configManager.resetConfig();
474
478
  })
@@ -100,6 +100,12 @@ export class DynamicModelProvider {
100
100
  // Setup timeout and abort controller
101
101
  const controller = new AbortController();
102
102
  const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
103
+ // Load from URL
104
+ const response = await fetch(source, {
105
+ headers: {
106
+ "User-Agent": "NeuroLink/1.0 (+https://github.com/juspay/neurolink)",
107
+ },
108
+ });
103
109
  try {
104
110
  // Add health check for localhost before attempting full request
105
111
  if (source.includes("localhost") || source.includes("127.0.0.1")) {