@juspay/neurolink 7.30.0 → 7.30.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## [7.30.1](https://github.com/juspay/neurolink/compare/v7.30.0...v7.30.1) (2025-08-31)
2
+
3
+ ### Bug Fixes
4
+
5
+ - **(bedrock):** migrate from ai-sdk to native AWS SDK implementation ([e5d8a4c](https://github.com/juspay/neurolink/commit/e5d8a4c85144ed558167f5083abd89d125576ab0))
6
+
1
7
  ## [7.30.0](https://github.com/juspay/neurolink/compare/v7.29.3...v7.30.0) (2025-08-29)
2
8
 
3
9
  ### Features
@@ -3,7 +3,7 @@
3
3
  * Handles in-memory conversation storage, session management, and context injection
4
4
  */
5
5
  import { ConversationMemoryError } from "../types/conversationTypes.js";
6
- import { DEFAULT_MAX_TURNS_PER_SESSION, DEFAULT_MAX_SESSIONS, MESSAGES_PER_TURN } from "../config/conversationMemoryConfig.js";
6
+ import { DEFAULT_MAX_TURNS_PER_SESSION, DEFAULT_MAX_SESSIONS, MESSAGES_PER_TURN, } from "../config/conversationMemoryConfig.js";
7
7
  import { logger } from "../utils/logger.js";
8
8
  import { NeuroLink } from "../neurolink.js";
9
9
  export class ConversationMemoryManager {
@@ -49,13 +49,15 @@ export class ConversationMemoryManager {
49
49
  session.messages.push({ role: "user", content: userMessage }, { role: "assistant", content: aiResponse });
50
50
  session.lastActivity = Date.now();
51
51
  if (this.config.enableSummarization) {
52
- const currentTurnCount = session.messages.length / MESSAGES_PER_TURN;
53
- if (currentTurnCount > (this.config.summarizationThresholdTurns || 20)) {
52
+ const userAssistantCount = session.messages.filter((msg) => msg.role === "user" || msg.role === "assistant").length;
53
+ const currentTurnCount = Math.floor(userAssistantCount / MESSAGES_PER_TURN);
54
+ if (currentTurnCount >= (this.config.summarizationThresholdTurns || 20)) {
54
55
  await this._summarizeSession(session);
55
56
  }
56
57
  }
57
58
  else {
58
- const maxMessages = (this.config.maxTurnsPerSession || DEFAULT_MAX_TURNS_PER_SESSION) * MESSAGES_PER_TURN;
59
+ const maxMessages = (this.config.maxTurnsPerSession || DEFAULT_MAX_TURNS_PER_SESSION) *
60
+ MESSAGES_PER_TURN;
59
61
  if (session.messages.length > maxMessages) {
60
62
  session.messages = session.messages.slice(-maxMessages);
61
63
  }
@@ -96,13 +98,15 @@ export class ConversationMemoryManager {
96
98
  return;
97
99
  }
98
100
  const summarizationPrompt = this._createSummarizationPrompt(messagesToSummarize);
99
- const summarizer = new NeuroLink({ conversationMemory: { enabled: false } });
101
+ const summarizer = new NeuroLink({
102
+ conversationMemory: { enabled: false },
103
+ });
100
104
  try {
101
105
  const providerName = this.config.summarizationProvider;
102
106
  // Map provider names to correct format
103
107
  let mappedProvider = providerName;
104
- if (providerName === 'vertex') {
105
- mappedProvider = 'googlevertex';
108
+ if (providerName === "vertex") {
109
+ mappedProvider = "googlevertex";
106
110
  }
107
111
  if (!mappedProvider) {
108
112
  logger.error(`[ConversationMemory] Missing summarization provider`);
@@ -118,7 +122,7 @@ export class ConversationMemoryManager {
118
122
  if (summaryResult.content) {
119
123
  session.messages = [
120
124
  this.createSummarySystemMessage(summaryResult.content),
121
- ...recentMessages
125
+ ...recentMessages,
122
126
  ];
123
127
  logger.info(`[ConversationMemory] Summarization complete for session ${session.sessionId}.`);
124
128
  }
@@ -131,7 +135,9 @@ export class ConversationMemoryManager {
131
135
  }
132
136
  }
133
137
  _createSummarizationPrompt(history) {
134
- const formattedHistory = history.map(msg => `${msg.role}: ${msg.content}`).join('\n\n');
138
+ const formattedHistory = history
139
+ .map((msg) => `${msg.role}: ${msg.content}`)
140
+ .join("\n\n");
135
141
  return `
136
142
  You are a context summarization AI. Your task is to condense the following conversation history for another AI assistant.
137
143
  The summary must be a concise, third-person narrative that retains all critical information, including key entities, technical details, decisions made, and any specific dates or times mentioned.
@@ -41,7 +41,7 @@ export class ProviderRegistry {
41
41
  // Register Amazon Bedrock provider
42
42
  ProviderFactory.registerProvider(AIProviderName.BEDROCK, async (modelName, _providerName, sdk) => {
43
43
  const { AmazonBedrockProvider } = await import("../providers/amazonBedrock.js");
44
- return new AmazonBedrockProvider(modelName, undefined, sdk);
44
+ return new AmazonBedrockProvider(modelName, sdk);
45
45
  }, undefined, // Let provider read BEDROCK_MODEL from .env
46
46
  ["bedrock", "aws"]);
47
47
  // Register Azure OpenAI provider
package/dist/index.d.ts CHANGED
@@ -15,6 +15,8 @@ export { validateTool } from "./sdk/toolRegistration.js";
15
15
  export type { ToolResult, ToolDefinition } from "./types/tools.js";
16
16
  export { BedrockModels, OpenAIModels, VertexModels, DEFAULT_PROVIDER_CONFIGS, } from "./core/types.js";
17
17
  export { getBestProvider, getAvailableProviders, isValidProvider, } from "./utils/providerUtils.js";
18
+ export { dynamicModelProvider } from "./core/dynamicModels.js";
19
+ export type { ModelConfig, ModelRegistry } from "./core/dynamicModels.js";
18
20
  export { NeuroLink } from "./neurolink.js";
19
21
  export type { ProviderStatus, MCPStatus } from "./neurolink.js";
20
22
  export type { MCPServerInfo } from "./types/mcpTypes.js";
package/dist/index.js CHANGED
@@ -14,6 +14,8 @@ export { validateTool } from "./sdk/toolRegistration.js";
14
14
  export { BedrockModels, OpenAIModels, VertexModels, DEFAULT_PROVIDER_CONFIGS, } from "./core/types.js";
15
15
  // Utility exports
16
16
  export { getBestProvider, getAvailableProviders, isValidProvider, } from "./utils/providerUtils.js";
17
+ // Dynamic Models exports
18
+ export { dynamicModelProvider } from "./core/dynamicModels.js";
17
19
  // Main NeuroLink wrapper class and diagnostic types
18
20
  export { NeuroLink } from "./neurolink.js";
19
21
  export { MiddlewareFactory } from "./middleware/factory.js";
@@ -3,7 +3,7 @@
3
3
  * Handles in-memory conversation storage, session management, and context injection
4
4
  */
5
5
  import { ConversationMemoryError } from "../types/conversationTypes.js";
6
- import { DEFAULT_MAX_TURNS_PER_SESSION, DEFAULT_MAX_SESSIONS, MESSAGES_PER_TURN } from "../config/conversationMemoryConfig.js";
6
+ import { DEFAULT_MAX_TURNS_PER_SESSION, DEFAULT_MAX_SESSIONS, MESSAGES_PER_TURN, } from "../config/conversationMemoryConfig.js";
7
7
  import { logger } from "../utils/logger.js";
8
8
  import { NeuroLink } from "../neurolink.js";
9
9
  export class ConversationMemoryManager {
@@ -49,13 +49,15 @@ export class ConversationMemoryManager {
49
49
  session.messages.push({ role: "user", content: userMessage }, { role: "assistant", content: aiResponse });
50
50
  session.lastActivity = Date.now();
51
51
  if (this.config.enableSummarization) {
52
- const currentTurnCount = session.messages.length / MESSAGES_PER_TURN;
53
- if (currentTurnCount > (this.config.summarizationThresholdTurns || 20)) {
52
+ const userAssistantCount = session.messages.filter((msg) => msg.role === "user" || msg.role === "assistant").length;
53
+ const currentTurnCount = Math.floor(userAssistantCount / MESSAGES_PER_TURN);
54
+ if (currentTurnCount >= (this.config.summarizationThresholdTurns || 20)) {
54
55
  await this._summarizeSession(session);
55
56
  }
56
57
  }
57
58
  else {
58
- const maxMessages = (this.config.maxTurnsPerSession || DEFAULT_MAX_TURNS_PER_SESSION) * MESSAGES_PER_TURN;
59
+ const maxMessages = (this.config.maxTurnsPerSession || DEFAULT_MAX_TURNS_PER_SESSION) *
60
+ MESSAGES_PER_TURN;
59
61
  if (session.messages.length > maxMessages) {
60
62
  session.messages = session.messages.slice(-maxMessages);
61
63
  }
@@ -96,13 +98,15 @@ export class ConversationMemoryManager {
96
98
  return;
97
99
  }
98
100
  const summarizationPrompt = this._createSummarizationPrompt(messagesToSummarize);
99
- const summarizer = new NeuroLink({ conversationMemory: { enabled: false } });
101
+ const summarizer = new NeuroLink({
102
+ conversationMemory: { enabled: false },
103
+ });
100
104
  try {
101
105
  const providerName = this.config.summarizationProvider;
102
106
  // Map provider names to correct format
103
107
  let mappedProvider = providerName;
104
- if (providerName === 'vertex') {
105
- mappedProvider = 'googlevertex';
108
+ if (providerName === "vertex") {
109
+ mappedProvider = "googlevertex";
106
110
  }
107
111
  if (!mappedProvider) {
108
112
  logger.error(`[ConversationMemory] Missing summarization provider`);
@@ -118,7 +122,7 @@ export class ConversationMemoryManager {
118
122
  if (summaryResult.content) {
119
123
  session.messages = [
120
124
  this.createSummarySystemMessage(summaryResult.content),
121
- ...recentMessages
125
+ ...recentMessages,
122
126
  ];
123
127
  logger.info(`[ConversationMemory] Summarization complete for session ${session.sessionId}.`);
124
128
  }
@@ -131,7 +135,9 @@ export class ConversationMemoryManager {
131
135
  }
132
136
  }
133
137
  _createSummarizationPrompt(history) {
134
- const formattedHistory = history.map(msg => `${msg.role}: ${msg.content}`).join('\n\n');
138
+ const formattedHistory = history
139
+ .map((msg) => `${msg.role}: ${msg.content}`)
140
+ .join("\n\n");
135
141
  return `
136
142
  You are a context summarization AI. Your task is to condense the following conversation history for another AI assistant.
137
143
  The summary must be a concise, third-person narrative that retains all critical information, including key entities, technical details, decisions made, and any specific dates or times mentioned.
@@ -41,7 +41,7 @@ export class ProviderRegistry {
41
41
  // Register Amazon Bedrock provider
42
42
  ProviderFactory.registerProvider(AIProviderName.BEDROCK, async (modelName, _providerName, sdk) => {
43
43
  const { AmazonBedrockProvider } = await import("../providers/amazonBedrock.js");
44
- return new AmazonBedrockProvider(modelName, undefined, sdk);
44
+ return new AmazonBedrockProvider(modelName, sdk);
45
45
  }, undefined, // Let provider read BEDROCK_MODEL from .env
46
46
  ["bedrock", "aws"]);
47
47
  // Register Azure OpenAI provider
@@ -15,6 +15,8 @@ export { validateTool } from "./sdk/toolRegistration.js";
15
15
  export type { ToolResult, ToolDefinition } from "./types/tools.js";
16
16
  export { BedrockModels, OpenAIModels, VertexModels, DEFAULT_PROVIDER_CONFIGS, } from "./core/types.js";
17
17
  export { getBestProvider, getAvailableProviders, isValidProvider, } from "./utils/providerUtils.js";
18
+ export { dynamicModelProvider } from "./core/dynamicModels.js";
19
+ export type { ModelConfig, ModelRegistry } from "./core/dynamicModels.js";
18
20
  export { NeuroLink } from "./neurolink.js";
19
21
  export type { ProviderStatus, MCPStatus } from "./neurolink.js";
20
22
  export type { MCPServerInfo } from "./types/mcpTypes.js";
package/dist/lib/index.js CHANGED
@@ -14,6 +14,8 @@ export { validateTool } from "./sdk/toolRegistration.js";
14
14
  export { BedrockModels, OpenAIModels, VertexModels, DEFAULT_PROVIDER_CONFIGS, } from "./core/types.js";
15
15
  // Utility exports
16
16
  export { getBestProvider, getAvailableProviders, isValidProvider, } from "./utils/providerUtils.js";
17
+ // Dynamic Models exports
18
+ export { dynamicModelProvider } from "./core/dynamicModels.js";
17
19
  // Main NeuroLink wrapper class and diagnostic types
18
20
  export { NeuroLink } from "./neurolink.js";
19
21
  export { MiddlewareFactory } from "./middleware/factory.js";
@@ -1,72 +1,41 @@
1
- import type { ZodUnknownSchema } from "../types/typeAliases.js";
2
- import { type LanguageModelV1 } from "ai";
3
- import type { AIProviderName } from "../core/types.js";
4
- import type { StreamOptions, StreamResult } from "../types/streamTypes.js";
5
- import { BaseProvider } from "../core/baseProvider.js";
6
- import { AWSCredentialProvider } from "./aws/credentialProvider.js";
7
1
  import { BedrockRuntimeClient } from "@aws-sdk/client-bedrock-runtime";
8
- import type { AWSCredentialConfig } from "../types/providers.js";
2
+ import { BaseProvider } from "../core/baseProvider.js";
3
+ import type { AIProviderName, EnhancedGenerateResult } from "../core/types.js";
4
+ import type { StreamOptions, StreamResult } from "../types/streamTypes.js";
5
+ import type { TextGenerationOptions } from "../core/types.js";
9
6
  import type { NeuroLink } from "../neurolink.js";
10
- /**
11
- * Amazon Bedrock Provider v3 - Enhanced Authentication Implementation
12
- *
13
- * BEDROCK-MCP-CONNECTOR COMPATIBILITY: Complete AWS SDK credential chain support
14
- *
15
- * Features:
16
- * - Extends BaseProvider for shared functionality
17
- * - AWS SDK v3 defaultProvider credential chain (9 sources)
18
- * - Dual access: AI SDK + Direct AWS SDK BedrockRuntimeClient
19
- * - Full backward compatibility with existing configurations
20
- * - Enhanced error handling with setup guidance
21
- * - Bedrock-MCP-Connector compatible authentication patterns
22
- */
23
7
  export declare class AmazonBedrockProvider extends BaseProvider {
24
- private awsCredentialProvider;
25
8
  private bedrockClient;
26
- private bedrock;
27
- private model;
28
- constructor(modelName?: string, credentialConfig?: AWSCredentialConfig, neurolink?: NeuroLink);
9
+ private conversationHistory;
10
+ constructor(modelName?: string, neurolink?: NeuroLink);
29
11
  /**
30
- * Legacy AWS configuration for backward compatibility
12
+ * Perform initial health check to catch credential/connectivity issues early
13
+ * This prevents the health check failure we saw in production logs
31
14
  */
32
- private createLegacyAWSConfig;
15
+ private performInitialHealthCheck;
16
+ protected getAISDKModel(): never;
33
17
  protected getProviderName(): AIProviderName;
34
18
  protected getDefaultModel(): string;
35
- /**
36
- * Returns the Vercel AI SDK model instance for AWS Bedrock
37
- */
38
- protected getAISDKModel(): LanguageModelV1;
39
- /**
40
- * Get AWS SDK BedrockRuntimeClient for direct access (Bedrock-MCP-Connector compatibility)
41
- * This provides the same direct AWS SDK access that Bedrock-MCP-Connector uses
42
- */
19
+ generate(optionsOrPrompt: TextGenerationOptions | string): Promise<EnhancedGenerateResult | null>;
20
+ private conversationLoop;
21
+ private callBedrock;
22
+ private handleBedrockResponse;
23
+ private convertToAWSMessages;
24
+ private executeSingleTool;
25
+ private convertAISDKToolsToToolDefinitions;
26
+ private formatToolsForBedrock;
43
27
  getBedrockClient(): BedrockRuntimeClient;
28
+ protected executeStream(options: StreamOptions): Promise<StreamResult>;
29
+ private streamingConversationLoop;
30
+ private convertToAsyncIterable;
31
+ private prepareStreamCommand;
32
+ private processStreamResponse;
33
+ private handleStreamStopReason;
34
+ private executeStreamTools;
44
35
  /**
45
- * Get AWS SDK BedrockRuntimeClient with proxy support ensured
46
- * Use this method when proxy support is critical for the operation
47
- */
48
- getBedrockClientWithProxy(): Promise<BedrockRuntimeClient>;
49
- /**
50
- * Get AWS credential provider for advanced credential management
51
- */
52
- getCredentialProvider(): AWSCredentialProvider;
53
- /**
54
- * Ensure proxy support is configured for AWS SDK client if needed
55
- */
56
- private ensureProxySupport;
57
- /**
58
- * Test AWS credentials and Bedrock connectivity
59
- * Useful for debugging authentication issues
36
+ * Health check for Amazon Bedrock service
37
+ * Uses ListFoundationModels API to validate connectivity and permissions
60
38
  */
61
- testConnectivity(): Promise<{
62
- credentialsValid: boolean;
63
- bedrockAccessible: boolean;
64
- credentialSource: string;
65
- error?: string;
66
- responseTime?: number;
67
- }>;
68
- protected executeStream(options: StreamOptions, _analysisSchema?: ZodUnknownSchema): Promise<StreamResult>;
69
- protected handleStreamError(error: unknown): Error;
39
+ checkBedrockHealth(): Promise<void>;
70
40
  protected handleProviderError(error: unknown): Error;
71
41
  }
72
- export default AmazonBedrockProvider;