@juspay/neurolink 7.37.0 → 7.38.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 (93) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cli/commands/config.d.ts +18 -18
  3. package/dist/cli/factories/commandFactory.d.ts +24 -0
  4. package/dist/cli/factories/commandFactory.js +297 -245
  5. package/dist/core/baseProvider.d.ts +44 -3
  6. package/dist/core/baseProvider.js +729 -352
  7. package/dist/core/constants.d.ts +2 -30
  8. package/dist/core/constants.js +15 -43
  9. package/dist/core/redisConversationMemoryManager.d.ts +98 -15
  10. package/dist/core/redisConversationMemoryManager.js +665 -203
  11. package/dist/factories/providerFactory.js +23 -6
  12. package/dist/index.d.ts +3 -2
  13. package/dist/index.js +4 -3
  14. package/dist/lib/core/baseProvider.d.ts +44 -3
  15. package/dist/lib/core/baseProvider.js +729 -352
  16. package/dist/lib/core/constants.d.ts +2 -30
  17. package/dist/lib/core/constants.js +15 -43
  18. package/dist/lib/core/redisConversationMemoryManager.d.ts +98 -15
  19. package/dist/lib/core/redisConversationMemoryManager.js +665 -203
  20. package/dist/lib/factories/providerFactory.js +23 -6
  21. package/dist/lib/index.d.ts +3 -2
  22. package/dist/lib/index.js +4 -3
  23. package/dist/lib/mcp/externalServerManager.js +2 -2
  24. package/dist/lib/mcp/registry.js +2 -2
  25. package/dist/lib/mcp/servers/agent/directToolsServer.js +19 -10
  26. package/dist/lib/mcp/toolRegistry.js +4 -8
  27. package/dist/lib/neurolink.d.ts +95 -28
  28. package/dist/lib/neurolink.js +479 -719
  29. package/dist/lib/providers/amazonBedrock.js +2 -2
  30. package/dist/lib/providers/anthropic.js +8 -0
  31. package/dist/lib/providers/anthropicBaseProvider.js +8 -0
  32. package/dist/lib/providers/azureOpenai.js +8 -0
  33. package/dist/lib/providers/googleAiStudio.js +8 -0
  34. package/dist/lib/providers/googleVertex.d.ts +3 -23
  35. package/dist/lib/providers/googleVertex.js +24 -342
  36. package/dist/lib/providers/huggingFace.js +8 -0
  37. package/dist/lib/providers/litellm.js +8 -0
  38. package/dist/lib/providers/mistral.js +8 -0
  39. package/dist/lib/providers/openAI.d.ts +23 -0
  40. package/dist/lib/providers/openAI.js +323 -6
  41. package/dist/lib/providers/openaiCompatible.js +8 -0
  42. package/dist/lib/providers/sagemaker/language-model.d.ts +2 -2
  43. package/dist/lib/sdk/toolRegistration.js +18 -1
  44. package/dist/lib/types/common.d.ts +98 -0
  45. package/dist/lib/types/conversation.d.ts +52 -2
  46. package/dist/lib/types/streamTypes.d.ts +13 -6
  47. package/dist/lib/types/typeAliases.d.ts +3 -2
  48. package/dist/lib/utils/conversationMemory.js +3 -1
  49. package/dist/lib/utils/messageBuilder.d.ts +10 -2
  50. package/dist/lib/utils/messageBuilder.js +22 -1
  51. package/dist/lib/utils/parameterValidation.js +6 -25
  52. package/dist/lib/utils/promptRedaction.js +4 -4
  53. package/dist/lib/utils/redis.d.ts +10 -6
  54. package/dist/lib/utils/redis.js +71 -70
  55. package/dist/lib/utils/schemaConversion.d.ts +14 -0
  56. package/dist/lib/utils/schemaConversion.js +140 -0
  57. package/dist/lib/utils/transformationUtils.js +143 -5
  58. package/dist/mcp/externalServerManager.js +2 -2
  59. package/dist/mcp/registry.js +2 -2
  60. package/dist/mcp/servers/agent/directToolsServer.js +19 -10
  61. package/dist/mcp/toolRegistry.js +4 -8
  62. package/dist/neurolink.d.ts +95 -28
  63. package/dist/neurolink.js +479 -719
  64. package/dist/providers/amazonBedrock.js +2 -2
  65. package/dist/providers/anthropic.js +8 -0
  66. package/dist/providers/anthropicBaseProvider.js +8 -0
  67. package/dist/providers/azureOpenai.js +8 -0
  68. package/dist/providers/googleAiStudio.js +8 -0
  69. package/dist/providers/googleVertex.d.ts +3 -23
  70. package/dist/providers/googleVertex.js +24 -342
  71. package/dist/providers/huggingFace.js +8 -0
  72. package/dist/providers/litellm.js +8 -0
  73. package/dist/providers/mistral.js +8 -0
  74. package/dist/providers/openAI.d.ts +23 -0
  75. package/dist/providers/openAI.js +323 -6
  76. package/dist/providers/openaiCompatible.js +8 -0
  77. package/dist/providers/sagemaker/language-model.d.ts +2 -2
  78. package/dist/sdk/toolRegistration.js +18 -1
  79. package/dist/types/common.d.ts +98 -0
  80. package/dist/types/conversation.d.ts +52 -2
  81. package/dist/types/streamTypes.d.ts +13 -6
  82. package/dist/types/typeAliases.d.ts +3 -2
  83. package/dist/utils/conversationMemory.js +3 -1
  84. package/dist/utils/messageBuilder.d.ts +10 -2
  85. package/dist/utils/messageBuilder.js +22 -1
  86. package/dist/utils/parameterValidation.js +6 -25
  87. package/dist/utils/promptRedaction.js +4 -4
  88. package/dist/utils/redis.d.ts +10 -6
  89. package/dist/utils/redis.js +71 -70
  90. package/dist/utils/schemaConversion.d.ts +14 -0
  91. package/dist/utils/schemaConversion.js +140 -0
  92. package/dist/utils/transformationUtils.js +143 -5
  93. package/package.json +3 -2
@@ -4,8 +4,8 @@
4
4
  */
5
5
  export declare const DEFAULT_MAX_TOKENS: undefined;
6
6
  export declare const DEFAULT_TEMPERATURE = 0.7;
7
- export declare const DEFAULT_TIMEOUT = 30000;
8
- export declare const DEFAULT_MAX_STEPS = 5;
7
+ export declare const DEFAULT_TIMEOUT = 60000;
8
+ export declare const DEFAULT_MAX_STEPS = 200;
9
9
  export declare const STEP_LIMITS: {
10
10
  min: number;
11
11
  max: number;
@@ -31,49 +31,21 @@ export declare const PROVIDER_CONFIG: {
31
31
  };
32
32
  export declare const PROVIDER_MAX_TOKENS: {
33
33
  anthropic: {
34
- "claude-3-haiku-20240307": number;
35
- "claude-3-5-sonnet-20241022": number;
36
- "claude-3-opus-20240229": number;
37
- "claude-3-5-sonnet-20240620": number;
38
34
  default: number;
39
35
  };
40
36
  openai: {
41
- "gpt-4o": number;
42
- "gpt-4o-mini": number;
43
- "gpt-3.5-turbo": number;
44
- "gpt-4": number;
45
- "gpt-4-turbo": number;
46
37
  default: number;
47
38
  };
48
39
  "google-ai": {
49
- "gemini-1.5-pro": number;
50
- "gemini-1.5-flash": number;
51
- "gemini-2.5-pro": number;
52
- "gemini-2.5-flash": number;
53
- "gemini-pro": number;
54
40
  default: number;
55
41
  };
56
42
  vertex: {
57
- "gemini-1.5-pro": number;
58
- "gemini-1.5-flash": number;
59
- "gemini-2.5-pro": number;
60
- "gemini-2.5-flash": number;
61
- "claude-4.0-sonnet": number;
62
43
  default: number;
63
44
  };
64
45
  bedrock: {
65
- "anthropic.claude-3-sonnet-20240229-v1:0": number;
66
- "anthropic.claude-3-haiku-20240307-v1:0": number;
67
- "anthropic.claude-3-5-sonnet-20240620-v1:0": number;
68
46
  default: number;
69
47
  };
70
48
  azure: {
71
- "gpt-4o": number;
72
- "gpt-4o-mini": number;
73
- "gpt-4.1": number;
74
- "gpt-3.5-turbo": number;
75
- "gpt-4": number;
76
- "gpt-4-turbo": number;
77
49
  default: number;
78
50
  };
79
51
  ollama: {
@@ -5,12 +5,12 @@
5
5
  // Core AI Generation Defaults
6
6
  export const DEFAULT_MAX_TOKENS = undefined; // Unlimited by default - let providers decide their own limits
7
7
  export const DEFAULT_TEMPERATURE = 0.7;
8
- export const DEFAULT_TIMEOUT = 30000;
9
- export const DEFAULT_MAX_STEPS = 5; // Default multi-turn tool execution steps
8
+ export const DEFAULT_TIMEOUT = 60000;
9
+ export const DEFAULT_MAX_STEPS = 200;
10
10
  // Step execution limits
11
11
  export const STEP_LIMITS = {
12
12
  min: 1,
13
- max: 20,
13
+ max: 500,
14
14
  default: DEFAULT_MAX_STEPS,
15
15
  };
16
16
  // Specialized Use Case Defaults
@@ -33,68 +33,40 @@ export const PROVIDER_CONFIG = {
33
33
  temperature: 0.4,
34
34
  },
35
35
  };
36
- // Provider-specific maxTokens limits (discovered through testing)
36
+ // Provider-specific maxTokens limits
37
37
  export const PROVIDER_MAX_TOKENS = {
38
38
  anthropic: {
39
- "claude-3-haiku-20240307": 4096,
40
- "claude-3-5-sonnet-20241022": 4096,
41
- "claude-3-opus-20240229": 4096,
42
- "claude-3-5-sonnet-20240620": 4096,
43
- default: 4096, // Conservative default for Anthropic
39
+ default: 64000,
44
40
  },
45
41
  openai: {
46
- "gpt-4o": 16384,
47
- "gpt-4o-mini": 16384,
48
- "gpt-3.5-turbo": 4096,
49
- "gpt-4": 8192,
50
- "gpt-4-turbo": 4096,
51
- default: 8192, // OpenAI generally supports higher limits
42
+ default: 500000,
52
43
  },
53
44
  "google-ai": {
54
- "gemini-1.5-pro": 8192,
55
- "gemini-1.5-flash": 8192,
56
- "gemini-2.5-pro": 8192,
57
- "gemini-2.5-flash": 8192,
58
- "gemini-pro": 4096,
59
- default: 4096, // Conservative default due to 500 errors at high limits
45
+ default: 64000,
60
46
  },
61
47
  vertex: {
62
- "gemini-1.5-pro": 8192,
63
- "gemini-1.5-flash": 8192,
64
- "gemini-2.5-pro": 8192,
65
- "gemini-2.5-flash": 8192,
66
- "claude-4.0-sonnet": 4096,
67
- default: 4096,
48
+ default: 64000,
68
49
  },
69
50
  bedrock: {
70
- "anthropic.claude-3-sonnet-20240229-v1:0": 4096,
71
- "anthropic.claude-3-haiku-20240307-v1:0": 4096,
72
- "anthropic.claude-3-5-sonnet-20240620-v1:0": 4096,
73
- default: 4096,
51
+ default: 64000,
74
52
  },
75
53
  azure: {
76
- "gpt-4o": 16384,
77
- "gpt-4o-mini": 16384,
78
- "gpt-4.1": 16384,
79
- "gpt-3.5-turbo": 4096,
80
- "gpt-4": 8192,
81
- "gpt-4-turbo": 4096,
82
- default: 8192, // Azure OpenAI generally supports similar limits to OpenAI
54
+ default: 64000,
83
55
  },
84
56
  ollama: {
85
- default: 8192, // Ollama typically supports higher limits
57
+ default: 64000,
86
58
  },
87
59
  litellm: {
88
- default: 4096, // Conservative default
60
+ default: 500000,
89
61
  },
90
- default: 4096, // Safe default across all providers
62
+ default: 64000,
91
63
  };
92
64
  // CLI Validation Limits
93
65
  export const CLI_LIMITS = {
94
66
  maxTokens: {
95
67
  min: 1,
96
- max: 50000,
97
- default: undefined, // No default limit - unlimited by default
68
+ max: 64000,
69
+ default: DEFAULT_MAX_TOKENS,
98
70
  },
99
71
  temperature: {
100
72
  min: 0,
@@ -2,21 +2,65 @@
2
2
  * Redis Conversation Memory Manager for NeuroLink
3
3
  * Redis-based implementation of conversation storage with same interface as ConversationMemoryManager
4
4
  */
5
- import type { ConversationMemoryConfig, SessionMemory, ConversationMemoryStats, ChatMessage, RedisStorageConfig } from "../types/conversation.js";
6
- /**
7
- * Redis-based implementation of the ConversationMemoryManager
8
- * Uses the same interface but stores data in Redis
9
- */
5
+ import type { ConversationMemoryConfig, ConversationMemoryStats, ChatMessage, RedisStorageConfig, SessionMetadata, RedisConversationObject } from "../types/conversation.js";
10
6
  export declare class RedisConversationMemoryManager {
11
7
  config: ConversationMemoryConfig;
12
8
  private isInitialized;
13
9
  private redisConfig;
14
10
  private redisClient;
11
+ /**
12
+ * Temporary storage for tool execution data to prevent race conditions
13
+ * Key format: "${sessionId}:${userId}"
14
+ */
15
+ private pendingToolExecutions;
16
+ /**
17
+ * Track sessions currently generating titles to prevent race conditions
18
+ * Key format: "${sessionId}:${userId}"
19
+ */
20
+ private titleGenerationInProgress;
15
21
  constructor(config: ConversationMemoryConfig, redisConfig?: RedisStorageConfig);
16
22
  /**
17
23
  * Initialize the memory manager with Redis connection
18
24
  */
19
25
  initialize(): Promise<void>;
26
+ /**
27
+ * Get all sessions for a specific user
28
+ */
29
+ getUserSessions(userId: string): Promise<string[]>;
30
+ /**
31
+ * Add a session to user's session set (private method)
32
+ */
33
+ private addUserSession;
34
+ /**
35
+ * Remove a session from user's session set (private method)
36
+ */
37
+ private removeUserSession;
38
+ /**
39
+ * Generate next message ID for a conversation
40
+ */
41
+ private generateMessageId;
42
+ /**
43
+ * Generate current timestamp in ISO format
44
+ */
45
+ private generateTimestamp;
46
+ /**
47
+ * Generate a unique conversation ID using UUID v4
48
+ */
49
+ private generateUniqueId;
50
+ /**
51
+ * Store tool execution data for a session (temporarily to avoid race conditions)
52
+ */
53
+ storeToolExecution(sessionId: string, userId: string | undefined, toolCalls: Array<{
54
+ toolCallId?: string;
55
+ toolName?: string;
56
+ args?: Record<string, unknown>;
57
+ [key: string]: unknown;
58
+ }>, toolResults: Array<{
59
+ toolCallId?: string;
60
+ result?: unknown;
61
+ error?: string;
62
+ [key: string]: unknown;
63
+ }>): Promise<void>;
20
64
  /**
21
65
  * Store a conversation turn for a session
22
66
  */
@@ -24,11 +68,41 @@ export declare class RedisConversationMemoryManager {
24
68
  /**
25
69
  * Build context messages for AI prompt injection
26
70
  */
27
- buildContextMessages(sessionId: string): Promise<ChatMessage[]>;
71
+ buildContextMessages(sessionId: string, userId?: string): Promise<ChatMessage[]>;
72
+ /**
73
+ * Get session metadata for a specific user session (optimized for listing)
74
+ * Fetches only essential metadata without heavy message arrays
75
+ *
76
+ * @param userId The user identifier
77
+ * @param sessionId The session identifier
78
+ * @returns Session metadata or null if session doesn't exist
79
+ */
80
+ getUserSessionMetadata(userId: string, sessionId: string): Promise<SessionMetadata | null>;
81
+ /**
82
+ * Get conversation history for a specific user session
83
+ *
84
+ * @param userId The user identifier
85
+ * @param sessionId The session identifier
86
+ * @returns Array of chat messages or null if session doesn't exist
87
+ */
88
+ getUserSessionHistory(userId: string, sessionId: string): Promise<ChatMessage[] | null>;
89
+ /**
90
+ * Get the complete conversation object for a specific user session
91
+ *
92
+ * This method returns the full conversation object including title, metadata,
93
+ * timestamps, and all chat messages. Unlike getUserSessionHistory() which returns
94
+ * only the messages array, this method provides the complete conversation context.
95
+ *
96
+ * @param userId The user identifier who owns the session
97
+ * @param sessionId The unique session identifier
98
+ * @returns Complete conversation object with all data, or null if session doesn't exist
99
+ */
100
+ getUserSessionObject(userId: string, sessionId: string): Promise<RedisConversationObject | null>;
28
101
  /**
29
- * Get session data
102
+ * Generate a conversation title from the first user message
103
+ * Uses AI to create a concise, descriptive title (5-8 words)
30
104
  */
31
- getSession(sessionId: string): Promise<SessionMemory | undefined>;
105
+ generateConversationTitle(userMessage: string): Promise<string>;
32
106
  /**
33
107
  * Create summary system message
34
108
  */
@@ -44,23 +118,32 @@ export declare class RedisConversationMemoryManager {
44
118
  /**
45
119
  * Clear a specific session
46
120
  */
47
- clearSession(sessionId: string): Promise<boolean>;
121
+ clearSession(sessionId: string, userId?: string): Promise<boolean>;
48
122
  /**
49
123
  * Clear all sessions
50
124
  */
51
125
  clearAllSessions(): Promise<void>;
52
126
  /**
53
- * Summarize messages for a session
127
+ * Ensure Redis client is initialized
54
128
  */
55
- private _summarizeMessages;
129
+ private ensureInitialized;
56
130
  /**
57
- * Create summarization prompt
131
+ * Get session metadata for all sessions of a user (optimized for listing)
132
+ * Returns only essential metadata without heavy message arrays
133
+ *
134
+ * @param userId The user identifier
135
+ * @returns Array of session metadata objects
58
136
  */
59
- private _createSummarizationPrompt;
137
+ getUserAllSessionsHistory(userId: string): Promise<SessionMetadata[]>;
60
138
  /**
61
- * Ensure Redis client is initialized
139
+ * Clean up stale pending tool execution data
140
+ * Removes data older than 5 minutes to prevent memory leaks
62
141
  */
63
- private ensureInitialized;
142
+ private cleanupStalePendingData;
143
+ /**
144
+ * Flush pending tool execution data for a session and merge into conversation
145
+ */
146
+ private flushPendingToolData;
64
147
  /**
65
148
  * Enforce session limit
66
149
  *