@juspay/neurolink 7.29.3 → 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 +12 -0
- package/dist/config/conversationMemoryConfig.js +5 -0
- package/dist/core/conversationMemoryManager.d.ts +9 -15
- package/dist/core/conversationMemoryManager.js +103 -56
- package/dist/core/types.d.ts +3 -1
- package/dist/factories/providerRegistry.js +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/lib/config/conversationMemoryConfig.js +5 -0
- package/dist/lib/core/conversationMemoryManager.d.ts +9 -15
- package/dist/lib/core/conversationMemoryManager.js +103 -56
- package/dist/lib/core/types.d.ts +3 -1
- package/dist/lib/factories/providerRegistry.js +1 -1
- package/dist/lib/index.d.ts +2 -0
- package/dist/lib/index.js +2 -0
- package/dist/lib/neurolink.d.ts +0 -9
- package/dist/lib/neurolink.js +7 -39
- package/dist/lib/providers/amazonBedrock.d.ts +28 -59
- package/dist/lib/providers/amazonBedrock.js +913 -330
- package/dist/lib/types/conversationTypes.d.ts +10 -0
- package/dist/lib/types/generateTypes.d.ts +1 -2
- package/dist/lib/utils/conversationMemoryUtils.d.ts +1 -2
- package/dist/lib/utils/conversationMemoryUtils.js +5 -6
- package/dist/lib/utils/logger.d.ts +164 -4
- package/dist/lib/utils/logger.js +163 -10
- package/dist/lib/utils/providerUtils.js +9 -6
- package/dist/neurolink.d.ts +0 -9
- package/dist/neurolink.js +7 -39
- package/dist/providers/amazonBedrock.d.ts +28 -59
- package/dist/providers/amazonBedrock.js +913 -330
- package/dist/types/conversationTypes.d.ts +10 -0
- package/dist/types/generateTypes.d.ts +1 -2
- package/dist/utils/conversationMemoryUtils.d.ts +1 -2
- package/dist/utils/conversationMemoryUtils.js +5 -6
- package/dist/utils/logger.d.ts +164 -4
- package/dist/utils/logger.js +163 -10
- package/dist/utils/providerUtils.js +9 -6
- package/package.json +2 -3
- package/dist/context/ContextManager.d.ts +0 -28
- package/dist/context/ContextManager.js +0 -113
- package/dist/context/config.d.ts +0 -5
- package/dist/context/config.js +0 -42
- package/dist/context/types.d.ts +0 -20
- package/dist/context/types.js +0 -1
- package/dist/context/utils.d.ts +0 -7
- package/dist/context/utils.js +0 -8
- package/dist/lib/context/ContextManager.d.ts +0 -28
- package/dist/lib/context/ContextManager.js +0 -113
- package/dist/lib/context/config.d.ts +0 -5
- package/dist/lib/context/config.js +0 -42
- package/dist/lib/context/types.d.ts +0 -20
- package/dist/lib/context/types.js +0 -1
- package/dist/lib/context/utils.d.ts +0 -7
- package/dist/lib/context/utils.js +0 -8
- package/dist/lib/providers/aws/credentialProvider.d.ts +0 -58
- package/dist/lib/providers/aws/credentialProvider.js +0 -267
- package/dist/lib/providers/aws/credentialTester.d.ts +0 -49
- package/dist/lib/providers/aws/credentialTester.js +0 -394
- package/dist/providers/aws/credentialProvider.d.ts +0 -58
- package/dist/providers/aws/credentialProvider.js +0 -267
- package/dist/providers/aws/credentialTester.d.ts +0 -49
- package/dist/providers/aws/credentialTester.js +0 -394
package/dist/lib/neurolink.d.ts
CHANGED
|
@@ -39,11 +39,9 @@ export interface MCPStatus {
|
|
|
39
39
|
error?: string;
|
|
40
40
|
[key: string]: unknown;
|
|
41
41
|
}
|
|
42
|
-
import type { ContextManagerConfig } from "./context/types.js";
|
|
43
42
|
export declare class NeuroLink {
|
|
44
43
|
private mcpInitialized;
|
|
45
44
|
private emitter;
|
|
46
|
-
private contextManager;
|
|
47
45
|
private autoDiscoveredServerInfos;
|
|
48
46
|
private externalServerManager;
|
|
49
47
|
private toolCircuitBreakers;
|
|
@@ -167,13 +165,6 @@ export declare class NeuroLink {
|
|
|
167
165
|
* @returns The original prompt text as a string.
|
|
168
166
|
*/
|
|
169
167
|
private _extractOriginalPrompt;
|
|
170
|
-
/**
|
|
171
|
-
* Enables automatic context summarization for the NeuroLink instance.
|
|
172
|
-
* Once enabled, the instance will maintain conversation history and
|
|
173
|
-
* automatically summarize it when it exceeds token limits.
|
|
174
|
-
* @param config Optional configuration to override default summarization settings.
|
|
175
|
-
*/
|
|
176
|
-
enableContextSummarization(config?: Partial<ContextManagerConfig>): void;
|
|
177
168
|
/**
|
|
178
169
|
* Generate AI content using the best available provider with MCP tool integration.
|
|
179
170
|
* This is the primary method for text generation with full feature support.
|
package/dist/lib/neurolink.js
CHANGED
|
@@ -35,14 +35,11 @@ import { applyConversationMemoryDefaults, getConversationMessages, storeConversa
|
|
|
35
35
|
import { ExternalServerManager } from "./mcp/externalServerManager.js";
|
|
36
36
|
// Import direct tools server for automatic registration
|
|
37
37
|
import { directToolsServer } from "./mcp/servers/agent/directToolsServer.js";
|
|
38
|
-
import { ContextManager } from "./context/ContextManager.js";
|
|
39
|
-
import { defaultContextConfig } from "./context/config.js";
|
|
40
38
|
import { isNonNullObject } from "./utils/typeUtils.js";
|
|
41
39
|
// Core types imported from core/types.js
|
|
42
40
|
export class NeuroLink {
|
|
43
41
|
mcpInitialized = false;
|
|
44
42
|
emitter = new EventEmitter();
|
|
45
|
-
contextManager = null;
|
|
46
43
|
autoDiscoveredServerInfos = [];
|
|
47
44
|
// External MCP server management
|
|
48
45
|
externalServerManager;
|
|
@@ -796,21 +793,6 @@ export class NeuroLink {
|
|
|
796
793
|
? optionsOrPrompt
|
|
797
794
|
: optionsOrPrompt.input.text;
|
|
798
795
|
}
|
|
799
|
-
/**
|
|
800
|
-
* Enables automatic context summarization for the NeuroLink instance.
|
|
801
|
-
* Once enabled, the instance will maintain conversation history and
|
|
802
|
-
* automatically summarize it when it exceeds token limits.
|
|
803
|
-
* @param config Optional configuration to override default summarization settings.
|
|
804
|
-
*/
|
|
805
|
-
enableContextSummarization(config) {
|
|
806
|
-
const contextConfig = {
|
|
807
|
-
...defaultContextConfig,
|
|
808
|
-
...config,
|
|
809
|
-
};
|
|
810
|
-
// Pass the internal generator function directly, bound to the correct `this` context.
|
|
811
|
-
this.contextManager = new ContextManager(this.generateTextInternal.bind(this), contextConfig);
|
|
812
|
-
logger.info("[NeuroLink] Automatic context summarization enabled.");
|
|
813
|
-
}
|
|
814
796
|
/**
|
|
815
797
|
* Generate AI content using the best available provider with MCP tool integration.
|
|
816
798
|
* This is the primary method for text generation with full feature support.
|
|
@@ -869,11 +851,6 @@ export class NeuroLink {
|
|
|
869
851
|
if (!options.input?.text || typeof options.input.text !== "string") {
|
|
870
852
|
throw new Error("Input text is required and must be a non-empty string");
|
|
871
853
|
}
|
|
872
|
-
// Handle Context Management if enabled
|
|
873
|
-
if (this.contextManager) {
|
|
874
|
-
// Get the full context for the prompt without permanently adding the user's turn yet
|
|
875
|
-
options.input.text = this.contextManager.getContextForPrompt("user", options.input.text);
|
|
876
|
-
}
|
|
877
854
|
const startTime = Date.now();
|
|
878
855
|
// Emit generation start event (NeuroLink format - keep existing)
|
|
879
856
|
this.emitter.emit("generation:start", {
|
|
@@ -913,6 +890,12 @@ export class NeuroLink {
|
|
|
913
890
|
};
|
|
914
891
|
// Apply factory enhancement using centralized utilities
|
|
915
892
|
const textOptions = enhanceTextGenerationOptions(baseOptions, factoryResult);
|
|
893
|
+
// Pass conversation memory config if available
|
|
894
|
+
if (this.conversationMemory) {
|
|
895
|
+
textOptions.conversationMemoryConfig = this.conversationMemory.config;
|
|
896
|
+
// Include original prompt for context summarization
|
|
897
|
+
textOptions.originalPrompt = originalPrompt;
|
|
898
|
+
}
|
|
916
899
|
// Detect and execute domain-specific tools
|
|
917
900
|
const { toolResults, enhancedPrompt } = await this.detectAndExecuteTools(textOptions.prompt || options.input.text, factoryResult.domainType);
|
|
918
901
|
// Update prompt with tool results if available
|
|
@@ -978,11 +961,6 @@ export class NeuroLink {
|
|
|
978
961
|
}
|
|
979
962
|
: undefined,
|
|
980
963
|
};
|
|
981
|
-
// Add both the user's turn and the AI's response to the permanent history
|
|
982
|
-
if (this.contextManager) {
|
|
983
|
-
await this.contextManager.addTurn("user", originalPrompt);
|
|
984
|
-
await this.contextManager.addTurn("assistant", generateResult.content);
|
|
985
|
-
}
|
|
986
964
|
return generateResult;
|
|
987
965
|
}
|
|
988
966
|
/**
|
|
@@ -1081,7 +1059,6 @@ export class NeuroLink {
|
|
|
1081
1059
|
hasToolRegistry: !!toolRegistry,
|
|
1082
1060
|
toolRegistrySize: 0,
|
|
1083
1061
|
hasExternalServerManager: !!this.externalServerManager,
|
|
1084
|
-
hasContextManager: !!this.contextManager,
|
|
1085
1062
|
},
|
|
1086
1063
|
environmentContext: {
|
|
1087
1064
|
nodeVersion: process.version,
|
|
@@ -1669,10 +1646,7 @@ export class NeuroLink {
|
|
|
1669
1646
|
let factoryResult;
|
|
1670
1647
|
try {
|
|
1671
1648
|
await this.initializeMCP();
|
|
1672
|
-
const
|
|
1673
|
-
if (this.contextManager) {
|
|
1674
|
-
options.input.text = this.contextManager.getContextForPrompt("user", options.input.text);
|
|
1675
|
-
}
|
|
1649
|
+
const _originalPrompt = options.input.text;
|
|
1676
1650
|
factoryResult = processStreamingFactoryOptions(options);
|
|
1677
1651
|
enhancedOptions = createCleanStreamOptions(options);
|
|
1678
1652
|
const { toolResults: _toolResults, enhancedPrompt } = await this.detectAndExecuteTools(options.input.text, undefined);
|
|
@@ -1682,12 +1656,6 @@ export class NeuroLink {
|
|
|
1682
1656
|
const { stream: mcpStream, provider: providerName } = await this.createMCPStream(enhancedOptions);
|
|
1683
1657
|
const streamResult = await this.processStreamResult(mcpStream, enhancedOptions, factoryResult);
|
|
1684
1658
|
const responseTime = Date.now() - startTime;
|
|
1685
|
-
if (this.contextManager) {
|
|
1686
|
-
await this.contextManager.addTurn("user", originalPrompt);
|
|
1687
|
-
if (streamResult.content) {
|
|
1688
|
-
await this.contextManager.addTurn("assistant", streamResult.content);
|
|
1689
|
-
}
|
|
1690
|
-
}
|
|
1691
1659
|
this.emitStreamEndEvents(streamResult);
|
|
1692
1660
|
return this.createStreamResponse(streamResult, mcpStream, {
|
|
1693
1661
|
providerName,
|
|
@@ -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
|
|
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
|
|
27
|
-
|
|
28
|
-
constructor(modelName?: string, credentialConfig?: AWSCredentialConfig, neurolink?: NeuroLink);
|
|
9
|
+
private conversationHistory;
|
|
10
|
+
constructor(modelName?: string, neurolink?: NeuroLink);
|
|
29
11
|
/**
|
|
30
|
-
*
|
|
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
|
|
15
|
+
private performInitialHealthCheck;
|
|
16
|
+
protected getAISDKModel(): never;
|
|
33
17
|
protected getProviderName(): AIProviderName;
|
|
34
18
|
protected getDefaultModel(): string;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
*
|
|
46
|
-
*
|
|
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
|
-
|
|
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;
|