@juspay/neurolink 7.26.1 → 7.28.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 (33) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cli/commands/config.d.ts +3 -3
  3. package/dist/lib/mcp/toolDiscoveryService.js +1 -1
  4. package/dist/lib/neurolink.d.ts +7 -1
  5. package/dist/lib/neurolink.js +1130 -56
  6. package/dist/lib/providers/amazonBedrock.d.ts +2 -2
  7. package/dist/lib/providers/amazonBedrock.js +16 -7
  8. package/dist/lib/providers/googleVertex.d.ts +28 -3
  9. package/dist/lib/providers/googleVertex.js +1132 -84
  10. package/dist/lib/providers/litellm.d.ts +1 -1
  11. package/dist/lib/providers/litellm.js +7 -4
  12. package/dist/lib/providers/openaiCompatible.d.ts +1 -1
  13. package/dist/lib/providers/openaiCompatible.js +7 -4
  14. package/dist/lib/proxy/proxyFetch.js +124 -2
  15. package/dist/lib/utils/providerHealth.d.ts +57 -1
  16. package/dist/lib/utils/providerHealth.js +638 -33
  17. package/dist/lib/utils/transformationUtils.js +3 -3
  18. package/dist/mcp/toolDiscoveryService.js +1 -1
  19. package/dist/neurolink.d.ts +7 -1
  20. package/dist/neurolink.js +1130 -56
  21. package/dist/providers/amazonBedrock.d.ts +2 -2
  22. package/dist/providers/amazonBedrock.js +16 -7
  23. package/dist/providers/googleVertex.d.ts +28 -3
  24. package/dist/providers/googleVertex.js +1132 -84
  25. package/dist/providers/litellm.d.ts +1 -1
  26. package/dist/providers/litellm.js +7 -4
  27. package/dist/providers/openaiCompatible.d.ts +1 -1
  28. package/dist/providers/openaiCompatible.js +7 -4
  29. package/dist/proxy/proxyFetch.js +124 -2
  30. package/dist/utils/providerHealth.d.ts +57 -1
  31. package/dist/utils/providerHealth.js +638 -33
  32. package/dist/utils/transformationUtils.js +3 -3
  33. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  import type { ZodUnknownSchema } from "../types/typeAliases.js";
2
- import { type Schema, type LanguageModelV1 } from "ai";
2
+ import { type LanguageModelV1 } from "ai";
3
3
  import type { AIProviderName } from "../core/types.js";
4
4
  import type { StreamOptions, StreamResult } from "../types/streamTypes.js";
5
5
  import { BaseProvider } from "../core/baseProvider.js";
@@ -25,7 +25,7 @@ export declare class AmazonBedrockProvider extends BaseProvider {
25
25
  * Returns the Vercel AI SDK model instance for AWS Bedrock
26
26
  */
27
27
  protected getAISDKModel(): LanguageModelV1;
28
- protected executeStream(options: StreamOptions, analysisSchema?: ZodUnknownSchema | Schema<unknown>): Promise<StreamResult>;
28
+ protected executeStream(options: StreamOptions, _analysisSchema?: ZodUnknownSchema): Promise<StreamResult>;
29
29
  protected handleProviderError(error: unknown): Error;
30
30
  }
31
31
  export default AmazonBedrockProvider;
@@ -2,15 +2,18 @@ import { createAmazonBedrock } from "@ai-sdk/amazon-bedrock";
2
2
  import { streamText } from "ai";
3
3
  import { BaseProvider } from "../core/baseProvider.js";
4
4
  import { logger } from "../utils/logger.js";
5
- import { TimeoutError, } from "../utils/timeout.js";
5
+ import { createTimeoutController, TimeoutError } from "../utils/timeout.js";
6
6
  import { DEFAULT_MAX_TOKENS } from "../core/constants.js";
7
7
  import { validateApiKey, createAWSAccessKeyConfig, createAWSSecretConfig, getAWSRegion, getAWSSessionToken, } from "../utils/providerConfig.js";
8
8
  import { buildMessagesArray } from "../utils/messageBuilder.js";
9
+ import { createProxyFetch } from "../proxy/proxyFetch.js";
9
10
  // Configuration helpers
10
11
  const getBedrockModelId = () => {
11
- return (process.env.BEDROCK_MODEL ||
12
- process.env.BEDROCK_MODEL_ID ||
13
- "arn:aws:bedrock:us-east-2:225681119357:inference-profile/us.anthropic.claude-3-7-sonnet-20250219-v1:0");
12
+ const model = process.env.BEDROCK_MODEL || process.env.BEDROCK_MODEL_ID;
13
+ if (!model) {
14
+ throw new Error("BEDROCK_MODEL (or BEDROCK_MODEL_ID) is required. Example: 'anthropic.claude-3-haiku-20240307-v1:0' or a valid inference profile ARN.");
15
+ }
16
+ return model;
14
17
  };
15
18
  // Configuration helpers - now using consolidated utility
16
19
  const getAWSAccessKeyId = () => {
@@ -45,6 +48,7 @@ export class AmazonBedrockProvider extends BaseProvider {
45
48
  accessKeyId: getAWSAccessKeyId(),
46
49
  secretAccessKey: getAWSSecretAccessKey(),
47
50
  region: getAWSRegion(),
51
+ fetch: createProxyFetch(),
48
52
  };
49
53
  // Add session token for development environment
50
54
  if (getAppEnvironment() === "dev") {
@@ -77,18 +81,21 @@ export class AmazonBedrockProvider extends BaseProvider {
77
81
  return this.model;
78
82
  }
79
83
  // executeGenerate removed - BaseProvider handles all generation with tools
80
- async executeStream(options, analysisSchema) {
84
+ async executeStream(options, _analysisSchema) {
81
85
  try {
82
86
  this.validateStreamOptions(options);
87
+ const timeout = this.getTimeout(options);
88
+ const timeoutController = createTimeoutController(timeout, this.providerName, "stream");
83
89
  // Build message array from options
84
90
  const messages = buildMessagesArray(options);
85
- const result = await streamText({
91
+ const result = streamText({
86
92
  model: this.model,
87
93
  messages: messages,
88
94
  maxTokens: options.maxTokens || DEFAULT_MAX_TOKENS,
89
95
  temperature: options.temperature,
96
+ abortSignal: timeoutController?.controller.signal,
90
97
  });
91
- return {
98
+ const streamResult = {
92
99
  stream: (async function* () {
93
100
  for await (const chunk of result.textStream) {
94
101
  yield { content: chunk };
@@ -97,6 +104,8 @@ export class AmazonBedrockProvider extends BaseProvider {
97
104
  provider: this.providerName,
98
105
  model: this.modelName,
99
106
  };
107
+ timeoutController?.cleanup();
108
+ return streamResult;
100
109
  }
101
110
  catch (error) {
102
111
  throw this.handleProviderError(error);
@@ -25,7 +25,7 @@ export declare class GoogleVertexProvider extends BaseProvider {
25
25
  private static readonly MAX_CACHE_SIZE;
26
26
  private static maxTokensCache;
27
27
  private static maxTokensCacheTime;
28
- constructor(modelName?: string, providerName?: string, sdk?: unknown);
28
+ constructor(modelName?: string, _providerName?: string, sdk?: unknown);
29
29
  protected getProviderName(): AIProviderName;
30
30
  protected getDefaultModel(): string;
31
31
  /**
@@ -35,6 +35,7 @@ export declare class GoogleVertexProvider extends BaseProvider {
35
35
  protected getAISDKModel(): Promise<LanguageModel>;
36
36
  /**
37
37
  * Gets the appropriate model instance (Google or Anthropic)
38
+ * Uses dual provider architecture for proper model routing
38
39
  * Creates fresh instances for each request to ensure proper authentication
39
40
  */
40
41
  private getModel;
@@ -66,12 +67,36 @@ export declare class GoogleVertexProvider extends BaseProvider {
66
67
  */
67
68
  hasAnthropicSupport(): Promise<boolean>;
68
69
  /**
69
- * Create an Anthropic model instance if available
70
- * Uses fresh vertex settings for each request
70
+ * Create an Anthropic model instance using vertexAnthropic provider
71
+ * Uses fresh vertex settings for each request with comprehensive validation
71
72
  * @param modelName Anthropic model name (e.g., 'claude-3-sonnet@20240229')
72
73
  * @returns LanguageModelV1 instance or null if not available
73
74
  */
74
75
  createAnthropicModel(modelName: string): Promise<LanguageModelV1 | null>;
76
+ /**
77
+ * Validate Vertex AI authentication configuration
78
+ */
79
+ private validateVertexAuthentication;
80
+ /**
81
+ * Validate Vertex AI project configuration
82
+ */
83
+ private validateVertexProjectConfiguration;
84
+ /**
85
+ * Check if the specified region supports Anthropic models
86
+ */
87
+ private checkVertexRegionalSupport;
88
+ /**
89
+ * Validate Anthropic model name format and availability
90
+ */
91
+ private validateAnthropicModelName;
92
+ /**
93
+ * Analyze Anthropic model creation errors for detailed troubleshooting
94
+ */
95
+ private analyzeAnthropicCreationError;
96
+ /**
97
+ * Get detailed troubleshooting steps based on error analysis
98
+ */
99
+ private getAnthropicTroubleshootingSteps;
75
100
  /**
76
101
  * Register a tool with the AI provider
77
102
  * @param name The name of the tool