@juspay/neurolink 9.14.0 → 9.16.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 (241) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +15 -15
  3. package/dist/adapters/video/videoAnalyzer.d.ts +1 -1
  4. package/dist/adapters/video/videoAnalyzer.js +10 -8
  5. package/dist/auth/anthropicOAuth.d.ts +377 -0
  6. package/dist/auth/anthropicOAuth.js +914 -0
  7. package/dist/auth/index.d.ts +20 -0
  8. package/dist/auth/index.js +29 -0
  9. package/dist/auth/tokenStore.d.ts +225 -0
  10. package/dist/auth/tokenStore.js +521 -0
  11. package/dist/cli/commands/auth.d.ts +50 -0
  12. package/dist/cli/commands/auth.js +1115 -0
  13. package/dist/cli/commands/setup-anthropic.js +1 -14
  14. package/dist/cli/commands/setup-azure.js +1 -12
  15. package/dist/cli/commands/setup-bedrock.js +1 -9
  16. package/dist/cli/commands/setup-google-ai.js +1 -12
  17. package/dist/cli/commands/setup-openai.js +1 -14
  18. package/dist/cli/commands/workflow.d.ts +27 -0
  19. package/dist/cli/commands/workflow.js +216 -0
  20. package/dist/cli/factories/authCommandFactory.d.ts +52 -0
  21. package/dist/cli/factories/authCommandFactory.js +146 -0
  22. package/dist/cli/factories/commandFactory.d.ts +6 -0
  23. package/dist/cli/factories/commandFactory.js +171 -22
  24. package/dist/cli/index.js +0 -1
  25. package/dist/cli/parser.js +14 -2
  26. package/dist/cli/utils/maskCredential.d.ts +11 -0
  27. package/dist/cli/utils/maskCredential.js +23 -0
  28. package/dist/constants/contextWindows.js +107 -16
  29. package/dist/constants/enums.d.ts +119 -15
  30. package/dist/constants/enums.js +182 -22
  31. package/dist/constants/index.d.ts +3 -1
  32. package/dist/constants/index.js +11 -1
  33. package/dist/context/budgetChecker.js +1 -1
  34. package/dist/context/contextCompactor.js +31 -4
  35. package/dist/context/emergencyTruncation.d.ts +21 -0
  36. package/dist/context/emergencyTruncation.js +88 -0
  37. package/dist/context/errorDetection.d.ts +16 -0
  38. package/dist/context/errorDetection.js +48 -1
  39. package/dist/context/errors.d.ts +19 -0
  40. package/dist/context/errors.js +21 -0
  41. package/dist/context/stages/slidingWindowTruncator.d.ts +6 -0
  42. package/dist/context/stages/slidingWindowTruncator.js +159 -24
  43. package/dist/core/baseProvider.js +306 -200
  44. package/dist/core/conversationMemoryManager.js +104 -61
  45. package/dist/core/evaluationProviders.js +16 -33
  46. package/dist/core/factory.js +237 -164
  47. package/dist/core/modules/GenerationHandler.js +175 -116
  48. package/dist/core/modules/MessageBuilder.js +222 -170
  49. package/dist/core/modules/StreamHandler.d.ts +1 -0
  50. package/dist/core/modules/StreamHandler.js +95 -27
  51. package/dist/core/modules/TelemetryHandler.d.ts +10 -1
  52. package/dist/core/modules/TelemetryHandler.js +25 -7
  53. package/dist/core/modules/ToolsManager.js +115 -191
  54. package/dist/core/redisConversationMemoryManager.js +418 -282
  55. package/dist/factories/providerRegistry.d.ts +5 -0
  56. package/dist/factories/providerRegistry.js +20 -2
  57. package/dist/index.d.ts +3 -3
  58. package/dist/index.js +4 -2
  59. package/dist/lib/adapters/video/videoAnalyzer.d.ts +1 -1
  60. package/dist/lib/adapters/video/videoAnalyzer.js +10 -8
  61. package/dist/lib/auth/anthropicOAuth.d.ts +377 -0
  62. package/dist/lib/auth/anthropicOAuth.js +915 -0
  63. package/dist/lib/auth/index.d.ts +20 -0
  64. package/dist/lib/auth/index.js +30 -0
  65. package/dist/lib/auth/tokenStore.d.ts +225 -0
  66. package/dist/lib/auth/tokenStore.js +522 -0
  67. package/dist/lib/constants/contextWindows.js +107 -16
  68. package/dist/lib/constants/enums.d.ts +119 -15
  69. package/dist/lib/constants/enums.js +182 -22
  70. package/dist/lib/constants/index.d.ts +3 -1
  71. package/dist/lib/constants/index.js +11 -1
  72. package/dist/lib/context/budgetChecker.js +1 -1
  73. package/dist/lib/context/contextCompactor.js +31 -4
  74. package/dist/lib/context/emergencyTruncation.d.ts +21 -0
  75. package/dist/lib/context/emergencyTruncation.js +89 -0
  76. package/dist/lib/context/errorDetection.d.ts +16 -0
  77. package/dist/lib/context/errorDetection.js +48 -1
  78. package/dist/lib/context/errors.d.ts +19 -0
  79. package/dist/lib/context/errors.js +22 -0
  80. package/dist/lib/context/stages/slidingWindowTruncator.d.ts +6 -0
  81. package/dist/lib/context/stages/slidingWindowTruncator.js +159 -24
  82. package/dist/lib/core/baseProvider.js +306 -200
  83. package/dist/lib/core/conversationMemoryManager.js +104 -61
  84. package/dist/lib/core/evaluationProviders.js +16 -33
  85. package/dist/lib/core/factory.js +237 -164
  86. package/dist/lib/core/modules/GenerationHandler.js +175 -116
  87. package/dist/lib/core/modules/MessageBuilder.js +222 -170
  88. package/dist/lib/core/modules/StreamHandler.d.ts +1 -0
  89. package/dist/lib/core/modules/StreamHandler.js +95 -27
  90. package/dist/lib/core/modules/TelemetryHandler.d.ts +10 -1
  91. package/dist/lib/core/modules/TelemetryHandler.js +25 -7
  92. package/dist/lib/core/modules/ToolsManager.js +115 -191
  93. package/dist/lib/core/redisConversationMemoryManager.js +418 -282
  94. package/dist/lib/factories/providerRegistry.d.ts +5 -0
  95. package/dist/lib/factories/providerRegistry.js +20 -2
  96. package/dist/lib/index.d.ts +3 -3
  97. package/dist/lib/index.js +4 -2
  98. package/dist/lib/mcp/externalServerManager.js +66 -0
  99. package/dist/lib/mcp/mcpCircuitBreaker.js +24 -0
  100. package/dist/lib/mcp/mcpClientFactory.js +16 -0
  101. package/dist/lib/mcp/toolDiscoveryService.js +32 -6
  102. package/dist/lib/mcp/toolRegistry.js +193 -123
  103. package/dist/lib/models/anthropicModels.d.ts +267 -0
  104. package/dist/lib/models/anthropicModels.js +528 -0
  105. package/dist/lib/neurolink.d.ts +6 -0
  106. package/dist/lib/neurolink.js +1162 -646
  107. package/dist/lib/providers/amazonBedrock.d.ts +1 -1
  108. package/dist/lib/providers/amazonBedrock.js +521 -319
  109. package/dist/lib/providers/anthropic.d.ts +123 -2
  110. package/dist/lib/providers/anthropic.js +873 -27
  111. package/dist/lib/providers/anthropicBaseProvider.js +77 -17
  112. package/dist/lib/providers/googleAiStudio.d.ts +1 -1
  113. package/dist/lib/providers/googleAiStudio.js +292 -227
  114. package/dist/lib/providers/googleVertex.d.ts +36 -1
  115. package/dist/lib/providers/googleVertex.js +553 -260
  116. package/dist/lib/providers/ollama.js +329 -278
  117. package/dist/lib/providers/openAI.js +77 -19
  118. package/dist/lib/providers/sagemaker/parsers.js +3 -3
  119. package/dist/lib/providers/sagemaker/streaming.js +3 -3
  120. package/dist/lib/proxy/proxyFetch.js +81 -48
  121. package/dist/lib/rag/ChunkerFactory.js +1 -1
  122. package/dist/lib/rag/chunkers/MarkdownChunker.d.ts +22 -0
  123. package/dist/lib/rag/chunkers/MarkdownChunker.js +213 -9
  124. package/dist/lib/rag/chunking/markdownChunker.d.ts +16 -0
  125. package/dist/lib/rag/chunking/markdownChunker.js +174 -2
  126. package/dist/lib/rag/pipeline/contextAssembly.js +2 -1
  127. package/dist/lib/rag/ragIntegration.d.ts +18 -1
  128. package/dist/lib/rag/ragIntegration.js +94 -14
  129. package/dist/lib/rag/retrieval/vectorQueryTool.js +21 -4
  130. package/dist/lib/server/abstract/baseServerAdapter.js +4 -1
  131. package/dist/lib/server/adapters/fastifyAdapter.js +35 -30
  132. package/dist/lib/services/server/ai/observability/instrumentation.d.ts +32 -0
  133. package/dist/lib/services/server/ai/observability/instrumentation.js +39 -0
  134. package/dist/lib/telemetry/attributes.d.ts +52 -0
  135. package/dist/lib/telemetry/attributes.js +61 -0
  136. package/dist/lib/telemetry/index.d.ts +3 -0
  137. package/dist/lib/telemetry/index.js +3 -0
  138. package/dist/lib/telemetry/telemetryService.d.ts +6 -0
  139. package/dist/lib/telemetry/telemetryService.js +6 -0
  140. package/dist/lib/telemetry/tracers.d.ts +15 -0
  141. package/dist/lib/telemetry/tracers.js +17 -0
  142. package/dist/lib/telemetry/withSpan.d.ts +9 -0
  143. package/dist/lib/telemetry/withSpan.js +35 -0
  144. package/dist/lib/types/contextTypes.d.ts +10 -0
  145. package/dist/lib/types/errors.d.ts +62 -0
  146. package/dist/lib/types/errors.js +107 -0
  147. package/dist/lib/types/index.d.ts +2 -1
  148. package/dist/lib/types/index.js +2 -0
  149. package/dist/lib/types/providers.d.ts +107 -0
  150. package/dist/lib/types/providers.js +69 -0
  151. package/dist/lib/types/streamTypes.d.ts +14 -0
  152. package/dist/lib/types/subscriptionTypes.d.ts +893 -0
  153. package/dist/lib/types/subscriptionTypes.js +8 -0
  154. package/dist/lib/utils/conversationMemory.js +121 -82
  155. package/dist/lib/utils/logger.d.ts +5 -0
  156. package/dist/lib/utils/logger.js +50 -2
  157. package/dist/lib/utils/messageBuilder.js +22 -42
  158. package/dist/lib/utils/modelDetection.js +3 -3
  159. package/dist/lib/utils/providerConfig.d.ts +167 -0
  160. package/dist/lib/utils/providerConfig.js +619 -9
  161. package/dist/lib/utils/providerRetry.d.ts +41 -0
  162. package/dist/lib/utils/providerRetry.js +114 -0
  163. package/dist/lib/utils/retryability.d.ts +14 -0
  164. package/dist/lib/utils/retryability.js +23 -0
  165. package/dist/lib/utils/sanitizers/svg.js +4 -5
  166. package/dist/lib/utils/tokenEstimation.d.ts +11 -1
  167. package/dist/lib/utils/tokenEstimation.js +19 -4
  168. package/dist/lib/utils/videoAnalysisProcessor.js +7 -3
  169. package/dist/mcp/externalServerManager.js +66 -0
  170. package/dist/mcp/mcpCircuitBreaker.js +24 -0
  171. package/dist/mcp/mcpClientFactory.js +16 -0
  172. package/dist/mcp/toolDiscoveryService.js +32 -6
  173. package/dist/mcp/toolRegistry.js +193 -123
  174. package/dist/models/anthropicModels.d.ts +267 -0
  175. package/dist/models/anthropicModels.js +527 -0
  176. package/dist/neurolink.d.ts +6 -0
  177. package/dist/neurolink.js +1162 -646
  178. package/dist/providers/amazonBedrock.d.ts +1 -1
  179. package/dist/providers/amazonBedrock.js +521 -319
  180. package/dist/providers/anthropic.d.ts +123 -2
  181. package/dist/providers/anthropic.js +873 -27
  182. package/dist/providers/anthropicBaseProvider.js +77 -17
  183. package/dist/providers/googleAiStudio.d.ts +1 -1
  184. package/dist/providers/googleAiStudio.js +292 -227
  185. package/dist/providers/googleVertex.d.ts +36 -1
  186. package/dist/providers/googleVertex.js +553 -260
  187. package/dist/providers/ollama.js +329 -278
  188. package/dist/providers/openAI.js +77 -19
  189. package/dist/providers/sagemaker/parsers.js +3 -3
  190. package/dist/providers/sagemaker/streaming.js +3 -3
  191. package/dist/proxy/proxyFetch.js +81 -48
  192. package/dist/rag/ChunkerFactory.js +1 -1
  193. package/dist/rag/chunkers/MarkdownChunker.d.ts +22 -0
  194. package/dist/rag/chunkers/MarkdownChunker.js +213 -9
  195. package/dist/rag/chunking/markdownChunker.d.ts +16 -0
  196. package/dist/rag/chunking/markdownChunker.js +174 -2
  197. package/dist/rag/pipeline/contextAssembly.js +2 -1
  198. package/dist/rag/ragIntegration.d.ts +18 -1
  199. package/dist/rag/ragIntegration.js +94 -14
  200. package/dist/rag/retrieval/vectorQueryTool.js +21 -4
  201. package/dist/server/abstract/baseServerAdapter.js +4 -1
  202. package/dist/server/adapters/fastifyAdapter.js +35 -30
  203. package/dist/services/server/ai/observability/instrumentation.d.ts +32 -0
  204. package/dist/services/server/ai/observability/instrumentation.js +39 -0
  205. package/dist/telemetry/attributes.d.ts +52 -0
  206. package/dist/telemetry/attributes.js +60 -0
  207. package/dist/telemetry/index.d.ts +3 -0
  208. package/dist/telemetry/index.js +3 -0
  209. package/dist/telemetry/telemetryService.d.ts +6 -0
  210. package/dist/telemetry/telemetryService.js +6 -0
  211. package/dist/telemetry/tracers.d.ts +15 -0
  212. package/dist/telemetry/tracers.js +16 -0
  213. package/dist/telemetry/withSpan.d.ts +9 -0
  214. package/dist/telemetry/withSpan.js +34 -0
  215. package/dist/types/contextTypes.d.ts +10 -0
  216. package/dist/types/errors.d.ts +62 -0
  217. package/dist/types/errors.js +107 -0
  218. package/dist/types/index.d.ts +2 -1
  219. package/dist/types/index.js +2 -0
  220. package/dist/types/providers.d.ts +107 -0
  221. package/dist/types/providers.js +69 -0
  222. package/dist/types/streamTypes.d.ts +14 -0
  223. package/dist/types/subscriptionTypes.d.ts +893 -0
  224. package/dist/types/subscriptionTypes.js +7 -0
  225. package/dist/utils/conversationMemory.js +121 -82
  226. package/dist/utils/logger.d.ts +5 -0
  227. package/dist/utils/logger.js +50 -2
  228. package/dist/utils/messageBuilder.js +22 -42
  229. package/dist/utils/modelDetection.js +3 -3
  230. package/dist/utils/providerConfig.d.ts +167 -0
  231. package/dist/utils/providerConfig.js +619 -9
  232. package/dist/utils/providerRetry.d.ts +41 -0
  233. package/dist/utils/providerRetry.js +113 -0
  234. package/dist/utils/retryability.d.ts +14 -0
  235. package/dist/utils/retryability.js +22 -0
  236. package/dist/utils/sanitizers/svg.js +4 -5
  237. package/dist/utils/tokenEstimation.d.ts +11 -1
  238. package/dist/utils/tokenEstimation.js +19 -4
  239. package/dist/utils/videoAnalysisProcessor.js +7 -3
  240. package/dist/workflow/config.d.ts +26 -26
  241. package/package.json +2 -1
@@ -40,6 +40,7 @@ export class CLICommandFactory {
40
40
  "vertex",
41
41
  "googleVertex",
42
42
  "anthropic",
43
+ "anthropic-subscription", // Anthropic with subscription tier support
43
44
  "azure",
44
45
  "google-ai",
45
46
  "google-ai-studio",
@@ -50,9 +51,27 @@ export class CLICommandFactory {
50
51
  "sagemaker",
51
52
  ],
52
53
  default: "auto",
53
- description: "AI provider to use (auto-selects best available)",
54
+ description: "AI provider to use (auto-selects best available). Use 'anthropic-subscription' for Claude subscription plans.",
54
55
  alias: "p",
55
56
  },
57
+ // Anthropic subscription options
58
+ authMethod: {
59
+ type: "string",
60
+ choices: ["api-key", "oauth"],
61
+ default: "api-key",
62
+ description: "Authentication method for Anthropic: 'api-key' (default) or 'oauth' (for subscription plans)",
63
+ },
64
+ subscriptionTier: {
65
+ type: "string",
66
+ choices: ["free", "pro", "max", "max_5", "max_20", "api"],
67
+ description: "Anthropic subscription tier: free (limited), pro ($20/mo), max (highest limits), max_5/max_20 (extended), api (pay-per-use)",
68
+ },
69
+ enableBeta: {
70
+ type: "boolean",
71
+ default: false,
72
+ description: "Enable Anthropic beta features (experimental capabilities, computer use, etc.)",
73
+ alias: "beta",
74
+ },
56
75
  image: {
57
76
  type: "string",
58
77
  description: "Add image file for multimodal analysis (can be used multiple times)",
@@ -316,7 +335,7 @@ export class CLICommandFactory {
316
335
  },
317
336
  thinkingLevel: {
318
337
  type: "string",
319
- description: "Thinking level for Gemini 3 models: minimal, low, medium, high",
338
+ description: "Thinking level for extended reasoning (Anthropic Claude, Gemini 2.5+, Gemini 3): minimal, low, medium, high",
320
339
  choices: ["minimal", "low", "medium", "high"],
321
340
  },
322
341
  region: {
@@ -515,8 +534,58 @@ export class CLICommandFactory {
515
534
  thinkingLevel: argv.thinkingLevel,
516
535
  // Region option for cloud providers (Vertex AI, Bedrock, etc.)
517
536
  region: argv.region,
537
+ // Anthropic subscription options
538
+ authMethod: argv.authMethod,
539
+ subscriptionTier: argv.subscriptionTier,
540
+ enableBeta: argv.enableBeta,
518
541
  };
519
542
  }
543
+ /**
544
+ * Validate Anthropic subscription options
545
+ * Ensures subscription tier is provided when using anthropic-subscription provider
546
+ * or when oauth auth method is selected
547
+ */
548
+ static validateAnthropicSubscriptionOptions(options) {
549
+ const provider = options.provider;
550
+ const authMethod = options.authMethod;
551
+ let subscriptionTier = options.subscriptionTier;
552
+ const enableBeta = options.enableBeta;
553
+ // Check if using anthropic-subscription provider or oauth auth method
554
+ const isSubscriptionMode = provider === "anthropic-subscription" || authMethod === "oauth";
555
+ if (isSubscriptionMode && !subscriptionTier) {
556
+ logger.always(chalk.yellow("⚠️ Subscription tier not specified. Defaulting to 'api' tier."));
557
+ logger.always(chalk.gray(" Use --subscription-tier to specify: free, pro, max, or api"));
558
+ options.subscriptionTier = "api";
559
+ subscriptionTier = "api";
560
+ }
561
+ // Validate oauth is required for non-api subscription tiers
562
+ if (subscriptionTier &&
563
+ ["free", "pro", "max"].includes(subscriptionTier) &&
564
+ authMethod !== "oauth") {
565
+ logger.always(chalk.yellow(`⚠️ Subscription tier '${subscriptionTier}' typically uses OAuth authentication.`));
566
+ logger.always(chalk.gray(" Consider using --auth-method oauth for this tier."));
567
+ }
568
+ // Map anthropic-subscription to anthropic provider with subscription options
569
+ if (provider === "anthropic-subscription") {
570
+ options.provider = "anthropic";
571
+ options.useSubscription = true;
572
+ }
573
+ // Warn about beta features when enabled
574
+ if (enableBeta) {
575
+ logger.always(chalk.cyan("🧪 Beta features enabled for Anthropic. Experimental capabilities may be unstable."));
576
+ }
577
+ // Build Anthropic auth configuration for provider initialization
578
+ if (provider === "anthropic" || provider === "anthropic-subscription") {
579
+ const authConfig = {
580
+ method: (authMethod === "oauth"
581
+ ? "oauth"
582
+ : "api_key"),
583
+ subscriptionTier: subscriptionTier,
584
+ };
585
+ options.anthropicAuthConfig = authConfig;
586
+ options.enableBeta = enableBeta;
587
+ }
588
+ }
520
589
  // Helper method to handle output
521
590
  static handleOutput(result, options) {
522
591
  let output;
@@ -540,17 +609,10 @@ export class CLICommandFactory {
540
609
  try {
541
610
  // Use custom path or default
542
611
  let imagePath;
543
- const cwd = process.cwd();
544
612
  if (options.imageOutput) {
545
- imagePath = options.imageOutput;
546
- // Validate path is within current working directory for security
547
- const resolvedPath = path.resolve(imagePath);
548
- if (!resolvedPath.startsWith(cwd + path.sep) &&
549
- resolvedPath !== cwd) {
550
- throw new Error(`Image output path must be within current directory: ${cwd}`);
551
- }
613
+ imagePath = path.resolve(options.imageOutput);
552
614
  // Create parent directory if needed (cross-platform)
553
- const dir = path.dirname(resolvedPath);
615
+ const dir = path.dirname(imagePath);
554
616
  if (dir && dir !== "." && !fs.existsSync(dir)) {
555
617
  fs.mkdirSync(dir, { recursive: true });
556
618
  }
@@ -853,7 +915,9 @@ export class CLICommandFactory {
853
915
  .example('$0 generate "Mountain landscape" --model gemini-2.5-flash-image --imageOutput ./my-images/mountain.png', "Generate image with custom path")
854
916
  .example('$0 generate "Describe this video" --video path/to/video.mp4', "Analyze video content")
855
917
  .example('$0 generate "Product showcase video" --image ./product.jpg --outputMode video --videoOutput ./output.mp4', "Generate video from image")
856
- .example('$0 generate "Smooth camera movement" --image ./input.jpg --provider vertex --model veo-3.1-generate-001 --outputMode video --videoResolution 720p --videoLength 6 --videoAspectRatio 16:9 --videoOutput ./output.mp4', "Video generation with full options"));
918
+ .example('$0 generate "Smooth camera movement" --image ./input.jpg --provider vertex --model veo-3.1-generate-001 --outputMode video --videoResolution 720p --videoLength 6 --videoAspectRatio 16:9 --videoOutput ./output.mp4', "Video generation with full options")
919
+ .example('$0 generate "Explain AI" --provider anthropic --subscription-tier pro', "Use Anthropic with Pro subscription tier")
920
+ .example('$0 generate "Deep analysis" --provider anthropic-subscription --subscription-tier max --auth-method oauth', "Use Anthropic with Max subscription and OAuth"));
857
921
  },
858
922
  handler: async (argv) => await CLICommandFactory.executeGenerate(argv),
859
923
  };
@@ -1076,6 +1140,7 @@ export class CLICommandFactory {
1076
1140
  "openai",
1077
1141
  "openrouter",
1078
1142
  "anthropic",
1143
+ "anthropic-subscription", // Setup Anthropic with subscription tier
1079
1144
  "azure",
1080
1145
  "bedrock",
1081
1146
  "vertex",
@@ -1091,9 +1156,21 @@ export class CLICommandFactory {
1091
1156
  .option("status", {
1092
1157
  type: "boolean",
1093
1158
  description: "Show provider configuration status",
1159
+ })
1160
+ .option("subscription-tier", {
1161
+ type: "string",
1162
+ choices: ["free", "pro", "max", "max_5", "max_20", "api"],
1163
+ description: "Anthropic subscription tier for setup (free, pro, max, max_5, max_20, api)",
1164
+ })
1165
+ .option("auth-method", {
1166
+ type: "string",
1167
+ choices: ["api-key", "oauth"],
1168
+ description: "Authentication method for Anthropic (api-key or oauth)",
1094
1169
  })
1095
1170
  .example("$0 setup", "Interactive setup wizard")
1096
1171
  .example("$0 setup --provider openai", "Setup specific provider")
1172
+ .example("$0 setup --provider anthropic --subscription-tier pro", "Setup Anthropic with Pro subscription")
1173
+ .example("$0 setup --provider anthropic --auth-method oauth", "Setup Anthropic with OAuth authentication")
1097
1174
  .example("$0 setup --list", "List all providers")
1098
1175
  .example("$0 setup --status", "Check provider status"));
1099
1176
  },
@@ -1391,6 +1468,8 @@ export class CLICommandFactory {
1391
1468
  throw new Error('Input required. Use: neurolink generate "your prompt" or echo "prompt" | neurolink generate');
1392
1469
  }
1393
1470
  const options = CLICommandFactory.processOptions(argv);
1471
+ // Validate Anthropic subscription options if using Anthropic provider
1472
+ this.validateAnthropicSubscriptionOptions(options);
1394
1473
  // Determine if video generation mode is enabled
1395
1474
  const isVideoMode = options.outputMode === "video";
1396
1475
  const spinnerMessage = isVideoMode
@@ -1562,6 +1641,20 @@ export class CLICommandFactory {
1562
1641
  topK: argv.ragTopK,
1563
1642
  }
1564
1643
  : undefined,
1644
+ // TTS configuration
1645
+ tts: enhancedOptions.tts
1646
+ ? {
1647
+ enabled: true,
1648
+ useAiResponse: true,
1649
+ voice: enhancedOptions.ttsVoice,
1650
+ format: enhancedOptions.ttsFormat ||
1651
+ undefined,
1652
+ speed: enhancedOptions.ttsSpeed,
1653
+ quality: enhancedOptions.ttsQuality,
1654
+ output: enhancedOptions.ttsOutput,
1655
+ play: enhancedOptions.ttsPlay,
1656
+ }
1657
+ : undefined,
1565
1658
  });
1566
1659
  if (spinner) {
1567
1660
  if (isVideoMode) {
@@ -1779,16 +1872,59 @@ export class CLICommandFactory {
1779
1872
  topK: argv.ragTopK,
1780
1873
  }
1781
1874
  : undefined,
1875
+ // TTS configuration
1876
+ tts: enhancedOptions.tts
1877
+ ? {
1878
+ enabled: true,
1879
+ useAiResponse: true,
1880
+ voice: enhancedOptions.ttsVoice,
1881
+ format: enhancedOptions.ttsFormat ||
1882
+ undefined,
1883
+ speed: enhancedOptions.ttsSpeed,
1884
+ quality: enhancedOptions.ttsQuality,
1885
+ output: enhancedOptions.ttsOutput,
1886
+ play: enhancedOptions.ttsPlay,
1887
+ }
1888
+ : undefined,
1782
1889
  });
1783
- const fullContent = await CLICommandFactory.processStreamWithTimeout(stream, options);
1784
- await CLICommandFactory.displayStreamResults(stream, fullContent, options);
1785
- return fullContent;
1890
+ const streamResult = await CLICommandFactory.processStreamWithTimeout(stream, options);
1891
+ await CLICommandFactory.displayStreamResults(stream, streamResult.content, options);
1892
+ // Handle image output from stream (image models emit image events)
1893
+ if (streamResult.imageBase64) {
1894
+ try {
1895
+ let imagePath;
1896
+ if (options.imageOutput) {
1897
+ imagePath = path.resolve(options.imageOutput);
1898
+ const dir = path.dirname(imagePath);
1899
+ if (dir && dir !== "." && !fs.existsSync(dir)) {
1900
+ fs.mkdirSync(dir, { recursive: true });
1901
+ }
1902
+ }
1903
+ else {
1904
+ const imageDir = "generated-images";
1905
+ const timestamp = new Date().toISOString().replace(/[:.]/g, "-");
1906
+ imagePath = path.join(imageDir, `image-${timestamp}.png`);
1907
+ if (!fs.existsSync(imageDir)) {
1908
+ fs.mkdirSync(imageDir, { recursive: true });
1909
+ }
1910
+ }
1911
+ const imageBuffer = Buffer.from(streamResult.imageBase64, "base64");
1912
+ fs.writeFileSync(imagePath, imageBuffer);
1913
+ logger.always(`\n📸 Generated image saved to: ${imagePath}`);
1914
+ logger.always(` Image size: ${(imageBuffer.length / 1024).toFixed(2)} KB`);
1915
+ }
1916
+ catch (error) {
1917
+ handleError(error, "Failed to save streamed image");
1918
+ }
1919
+ }
1920
+ return streamResult.content;
1786
1921
  }
1787
1922
  /**
1788
1923
  * Process stream with timeout handling
1789
1924
  */
1790
1925
  static async processStreamWithTimeout(stream, options) {
1791
1926
  let fullContent = "";
1927
+ let lastImageBase64;
1792
1928
  let contentReceived = false;
1793
1929
  const abortController = new AbortController();
1794
1930
  // Create timeout promise for stream consumption (default: 30 seconds, respects user-provided timeout)
@@ -1848,10 +1984,20 @@ export class CLICommandFactory {
1848
1984
  const isAudio = (o) => !!o &&
1849
1985
  typeof o === "object" &&
1850
1986
  o.type === "audio";
1851
- const isImage = (o) => !!o &&
1852
- typeof o === "object" &&
1853
- o.type === "image" &&
1854
- typeof o.imageOutput === "object";
1987
+ const isImage = (o) => {
1988
+ if (!o || typeof o !== "object") {
1989
+ return false;
1990
+ }
1991
+ const record = o;
1992
+ if (record.type !== "image") {
1993
+ return false;
1994
+ }
1995
+ if (!record.imageOutput || typeof record.imageOutput !== "object") {
1996
+ return false;
1997
+ }
1998
+ return (typeof record.imageOutput.base64 ===
1999
+ "string");
2000
+ };
1855
2001
  if (isText(evt)) {
1856
2002
  process.stdout.write(evt.content);
1857
2003
  fullContent += evt.content;
@@ -1862,8 +2008,7 @@ export class CLICommandFactory {
1862
2008
  }
1863
2009
  }
1864
2010
  else if (isImage(evt)) {
1865
- // Image events are handled after stream completes (in generate flow)
1866
- // This handler ensures they're not silently dropped
2011
+ lastImageBase64 = evt.imageOutput.base64;
1867
2012
  if (options.debug && !options.quiet) {
1868
2013
  process.stdout.write("[image-received]");
1869
2014
  }
@@ -1881,7 +2026,7 @@ export class CLICommandFactory {
1881
2026
  if (!options.quiet) {
1882
2027
  process.stdout.write("\n");
1883
2028
  }
1884
- return fullContent;
2029
+ return { content: fullContent, imageBase64: lastImageBase64 };
1885
2030
  }
1886
2031
  /**
1887
2032
  * Display analytics and evaluation results
@@ -1995,6 +2140,8 @@ export class CLICommandFactory {
1995
2140
  static async executeStream(argv) {
1996
2141
  await CLICommandFactory.handleStdinInput(argv);
1997
2142
  const options = CLICommandFactory.processOptions(argv);
2143
+ // Validate Anthropic subscription options if using Anthropic provider
2144
+ this.validateAnthropicSubscriptionOptions(options);
1998
2145
  if (!options.quiet) {
1999
2146
  logger.always(chalk.blue("🔄 Streaming..."));
2000
2147
  }
@@ -2025,6 +2172,8 @@ export class CLICommandFactory {
2025
2172
  */
2026
2173
  static async executeBatch(argv) {
2027
2174
  const options = CLICommandFactory.processOptions(argv);
2175
+ // Validate Anthropic subscription options if using Anthropic provider
2176
+ CLICommandFactory.validateAnthropicSubscriptionOptions(options);
2028
2177
  const spinner = options.quiet ? null : ora().start();
2029
2178
  try {
2030
2179
  if (!argv.file) {
package/dist/cli/index.js CHANGED
@@ -26,7 +26,6 @@ catch {
26
26
  // Environment variables should be set externally in production
27
27
  }
28
28
  // Enhanced CLI with Professional UX
29
- // Note: Workflow functionality is accessed via generate/stream commands with --workflow-config option
30
29
  const cli = initializeCliParser();
31
30
  // Execute CLI
32
31
  (async () => {
@@ -11,6 +11,8 @@ import { ServerCommandFactory } from "./commands/server.js";
11
11
  import { ServeCommandFactory } from "./commands/serve.js";
12
12
  import { ragCommand } from "./commands/rag.js";
13
13
  import { DocsCommandFactory } from "./commands/docs.js";
14
+ import { AuthCommandFactory } from "./factories/authCommandFactory.js";
15
+ import { WorkflowCommandFactory } from "./commands/workflow.js";
14
16
  // Enhanced CLI with Professional UX
15
17
  export function initializeCliParser() {
16
18
  return (yargs(hideBin(process.argv))
@@ -24,7 +26,13 @@ export function initializeCliParser() {
24
26
  .strictCommands()
25
27
  .demandCommand(1, "")
26
28
  .recommendCommands()
27
- .epilogue("For more info: https://github.com/juspay/neurolink")
29
+ .epilogue("For more info: https://github.com/juspay/neurolink\n\n" +
30
+ "Anthropic Subscription Tiers:\n" +
31
+ " free - Limited free tier access\n" +
32
+ " pro - Professional tier ($20/mo)\n" +
33
+ " max - Maximum tier with highest limits\n" +
34
+ " api - Direct API access (pay-per-use)\n\n" +
35
+ "Use 'neurolink auth login anthropic' to configure authentication")
28
36
  .showHelpOnFail(true, "Specify --help for available options")
29
37
  .middleware((argv) => {
30
38
  // Handle no-color option globally
@@ -169,6 +177,10 @@ export function initializeCliParser() {
169
177
  // RAG Document Processing Commands
170
178
  .command(ragCommand)
171
179
  // Docs MCP Server Command
172
- .command(DocsCommandFactory.createDocsCommand())); // Close the main return statement
180
+ .command(DocsCommandFactory.createDocsCommand())
181
+ // Auth Commands - Using AuthCommandFactory
182
+ .command(AuthCommandFactory.createAuthCommands())
183
+ // Workflow Commands
184
+ .command(WorkflowCommandFactory.createWorkflowCommands())); // Close the main return statement
173
185
  }
174
186
  //# sourceMappingURL=parser.js.map
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Unified credential masking utility for CLI setup commands.
3
+ *
4
+ * Preserves known provider prefixes (sk-, sk-ant-, AIza, AKIA) so
5
+ * users can identify which key is configured, while hiding the secret
6
+ * portion with asterisks.
7
+ *
8
+ * @param credential - Raw API key or secret
9
+ * @returns Masked string, e.g. "sk-****abcd"
10
+ */
11
+ export declare function maskCredential(credential: string): string;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Unified credential masking utility for CLI setup commands.
3
+ *
4
+ * Preserves known provider prefixes (sk-, sk-ant-, AIza, AKIA) so
5
+ * users can identify which key is configured, while hiding the secret
6
+ * portion with asterisks.
7
+ *
8
+ * @param credential - Raw API key or secret
9
+ * @returns Masked string, e.g. "sk-****abcd"
10
+ */
11
+ export function maskCredential(credential) {
12
+ if (!credential || credential.length <= 8) {
13
+ return "****";
14
+ }
15
+ // Provider-specific prefixes ordered longest-first so "sk-ant-" wins over "sk-"
16
+ const knownPrefixes = ["sk-ant-", "sk-", "AIza", "AKIA"];
17
+ const prefix = knownPrefixes.find((p) => credential.startsWith(p)) ??
18
+ credential.slice(0, 4);
19
+ const end = credential.slice(-4);
20
+ const stars = "*".repeat(Math.max(4, credential.length - prefix.length - 4));
21
+ return `${prefix}${stars}${end}`;
22
+ }
23
+ //# sourceMappingURL=maskCredential.js.map
@@ -25,8 +25,18 @@ export const DEFAULT_OUTPUT_RESERVE_RATIO = 0.35;
25
25
  export const MODEL_CONTEXT_WINDOWS = {
26
26
  anthropic: {
27
27
  _default: 200_000,
28
+ // Claude 4.6 (Feb 2026) — 200K standard, 1M with beta header
29
+ "claude-opus-4-6": 200_000,
30
+ "claude-sonnet-4-6": 200_000,
31
+ // Claude 4.5
32
+ "claude-opus-4-5-20251101": 200_000,
33
+ "claude-sonnet-4-5-20250929": 200_000,
34
+ "claude-haiku-4-5-20251001": 200_000,
35
+ // Claude 4.x
36
+ "claude-opus-4-1-20250805": 200_000,
28
37
  "claude-opus-4-20250514": 200_000,
29
38
  "claude-sonnet-4-20250514": 200_000,
39
+ // Claude 3.x
30
40
  "claude-3-7-sonnet-20250219": 200_000,
31
41
  "claude-3-5-sonnet-20241022": 200_000,
32
42
  "claude-3-5-haiku-20241022": 200_000,
@@ -36,67 +46,144 @@ export const MODEL_CONTEXT_WINDOWS = {
36
46
  },
37
47
  openai: {
38
48
  _default: 128_000,
49
+ // GPT-5.x family — 400K context
50
+ "gpt-5.3-codex": 400_000,
51
+ "gpt-5.2": 400_000,
52
+ "gpt-5.2-pro": 400_000,
53
+ "gpt-5.2-codex": 400_000,
54
+ "gpt-5.2-chat-latest": 128_000,
55
+ "gpt-5.1": 400_000,
56
+ "gpt-5.1-codex": 400_000,
57
+ "gpt-5.1-codex-max": 400_000,
58
+ "gpt-5.1-codex-mini": 400_000,
59
+ "gpt-5.1-chat-latest": 128_000,
60
+ "gpt-5": 400_000,
61
+ "gpt-5-mini": 400_000,
62
+ "gpt-5-nano": 400_000,
63
+ "gpt-5-pro": 400_000,
64
+ "gpt-5-codex": 400_000,
65
+ "gpt-5-chat-latest": 128_000,
66
+ // GPT Open Source
67
+ "gpt-oss-120b": 128_000,
68
+ "gpt-oss-20b": 128_000,
69
+ // GPT-4.1 family — 1M context
70
+ "gpt-4.1": 1_047_576,
71
+ "gpt-4.1-mini": 1_047_576,
72
+ "gpt-4.1-nano": 1_047_576,
73
+ // GPT-4o
39
74
  "gpt-4o": 128_000,
40
75
  "gpt-4o-mini": 128_000,
41
- "gpt-4-turbo": 128_000,
42
- "gpt-4": 8_192,
43
- "gpt-3.5-turbo": 16_385,
76
+ // O-series reasoning — 200K context
44
77
  o1: 200_000,
45
78
  "o1-mini": 128_000,
46
79
  "o1-pro": 200_000,
47
80
  o3: 200_000,
48
81
  "o3-mini": 200_000,
82
+ "o3-pro": 200_000,
49
83
  "o4-mini": 200_000,
50
- "gpt-4.1": 1_047_576,
51
- "gpt-4.1-mini": 1_047_576,
52
- "gpt-4.1-nano": 1_047_576,
53
- "gpt-5": 1_047_576,
84
+ // Legacy
85
+ "gpt-4-turbo": 128_000,
86
+ "gpt-4": 8_192,
87
+ "gpt-3.5-turbo": 16_385,
54
88
  },
55
89
  "google-ai": {
56
90
  _default: 1_048_576,
91
+ "gemini-3.1-pro-preview": 1_048_576,
92
+ "gemini-3-pro-preview": 1_048_576,
93
+ "gemini-3-pro-image-preview": 65_536,
94
+ "gemini-3-flash-preview": 1_048_576,
95
+ "gemini-3-flash": 1_048_576,
57
96
  "gemini-2.5-pro": 1_048_576,
58
97
  "gemini-2.5-flash": 1_048_576,
98
+ "gemini-2.5-flash-lite": 1_048_576,
99
+ "gemini-2.5-flash-image": 32_768,
59
100
  "gemini-2.0-flash": 1_048_576,
60
101
  "gemini-1.5-pro": 2_097_152,
61
102
  "gemini-1.5-flash": 1_048_576,
62
- "gemini-3-flash-preview": 1_048_576,
63
- "gemini-3-pro-preview": 1_048_576,
64
103
  },
65
104
  vertex: {
66
105
  _default: 1_048_576,
106
+ // Claude on Vertex
107
+ "claude-opus-4-6": 200_000,
108
+ "claude-sonnet-4-6": 200_000,
109
+ "claude-sonnet-4-5": 200_000,
110
+ "claude-opus-4-5": 200_000,
111
+ "claude-haiku-4-5": 200_000,
112
+ "claude-sonnet-4": 200_000,
113
+ "claude-sonnet-4-20250514": 200_000,
114
+ "claude-opus-4-20250514": 200_000,
115
+ "claude-opus-4": 200_000,
116
+ // Gemini on Vertex
117
+ "gemini-3.1-pro-preview": 1_048_576,
118
+ "gemini-3-pro-preview": 1_048_576,
119
+ "gemini-3-pro-latest": 1_048_576,
120
+ "gemini-3-flash-preview": 1_048_576,
121
+ "gemini-3-flash-latest": 1_048_576,
67
122
  "gemini-2.5-pro": 1_048_576,
68
123
  "gemini-2.5-flash": 1_048_576,
69
124
  "gemini-2.0-flash": 1_048_576,
70
125
  "gemini-1.5-pro": 2_097_152,
71
126
  "gemini-1.5-flash": 1_048_576,
72
- "claude-sonnet-4-5": 200_000,
73
- "claude-sonnet-4-20250514": 200_000,
74
- "claude-opus-4": 200_000,
75
- "claude-opus-4-20250514": 200_000,
76
127
  },
77
128
  bedrock: {
78
129
  _default: 200_000,
79
- "anthropic.claude-3-5-sonnet-20241022-v2:0": 200_000,
130
+ // Claude 4.6
131
+ "anthropic.claude-opus-4-6-v1:0": 200_000,
132
+ "anthropic.claude-sonnet-4-6": 200_000,
133
+ // Claude 4.5
134
+ "anthropic.claude-opus-4-5-20251124-v1:0": 200_000,
135
+ "anthropic.claude-sonnet-4-5-20250929-v1:0": 200_000,
136
+ "anthropic.claude-haiku-4-5-20251001-v1:0": 200_000,
137
+ // Claude legacy
138
+ "anthropic.claude-3-5-sonnet-20241022-v1:0": 200_000,
80
139
  "anthropic.claude-3-5-haiku-20241022-v1:0": 200_000,
81
140
  "anthropic.claude-3-opus-20240229-v1:0": 200_000,
82
141
  "anthropic.claude-3-sonnet-20240229-v1:0": 200_000,
83
142
  "anthropic.claude-3-haiku-20240307-v1:0": 200_000,
143
+ // Amazon Nova
84
144
  "amazon.nova-pro-v1:0": 300_000,
85
145
  "amazon.nova-lite-v1:0": 300_000,
146
+ "amazon.nova-2-lite-v1:0": 1_000_000,
147
+ // Writer
148
+ "writer.palmyra-x5-v1:0": 1_000_000,
149
+ "writer.palmyra-x4-v1:0": 128_000,
150
+ // NVIDIA
151
+ "nvidia.nemotron-nano-3-30b": 256_000,
86
152
  },
87
153
  azure: {
88
154
  _default: 128_000,
155
+ // GPT-5.x
156
+ "gpt-5.2": 400_000,
157
+ "gpt-5.2-pro": 400_000,
158
+ "gpt-5.2-codex": 400_000,
159
+ "gpt-5.1": 400_000,
160
+ "gpt-5": 400_000,
161
+ "gpt-5-mini": 400_000,
162
+ // GPT-4.1
163
+ "gpt-4.1": 1_047_576,
164
+ "gpt-4.1-mini": 1_047_576,
165
+ // GPT-4o
89
166
  "gpt-4o": 128_000,
90
167
  "gpt-4o-mini": 128_000,
168
+ // O-series
169
+ o3: 200_000,
170
+ "o3-mini": 200_000,
171
+ "o4-mini": 200_000,
172
+ // Legacy
91
173
  "gpt-4-turbo": 128_000,
92
174
  "gpt-4": 8_192,
93
175
  },
94
176
  mistral: {
95
177
  _default: 128_000,
96
- "mistral-large-latest": 128_000,
97
- "mistral-medium-latest": 32_000,
178
+ "mistral-large-latest": 256_000,
179
+ "mistral-large-2512": 256_000,
180
+ "mistral-medium-latest": 128_000,
98
181
  "mistral-small-latest": 128_000,
99
182
  "codestral-latest": 256_000,
183
+ "codestral-2508": 256_000,
184
+ "devstral-2512": 256_000,
185
+ "devstral-small-2512": 256_000,
186
+ "magistral-medium-latest": 128_000,
100
187
  },
101
188
  ollama: {
102
189
  _default: 128_000,
@@ -109,6 +196,10 @@ export const MODEL_CONTEXT_WINDOWS = {
109
196
  },
110
197
  sagemaker: {
111
198
  _default: 128_000,
199
+ // NVIDIA Nemotron 3 Nano (February 2026) — 1M context
200
+ "nvidia-nemotron-3-nano-30b": 1_000_000,
201
+ // Qwen3 VL — 32K context
202
+ "qwen3-vl-8b-instruct": 32_768,
112
203
  },
113
204
  };
114
205
  /**