@juspay/neurolink 6.1.0 → 6.2.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 +16 -6
- package/dist/agent/direct-tools.js +6 -5
- package/dist/cli/commands/config.d.ts +13 -13
- package/dist/cli/index.js +3 -9
- package/dist/config/configManager.js +11 -10
- package/dist/core/analytics.d.ts +11 -1
- package/dist/core/analytics.js +2 -2
- package/dist/core/base-provider.js +4 -18
- package/dist/core/dynamic-models.d.ts +8 -8
- package/dist/core/factory.js +3 -11
- package/dist/index.d.ts +2 -4
- package/dist/index.js +2 -11
- package/dist/lib/agent/direct-tools.js +6 -5
- package/dist/lib/config/configManager.js +11 -10
- package/dist/lib/core/analytics.d.ts +11 -1
- package/dist/lib/core/analytics.js +2 -2
- package/dist/lib/core/base-provider.js +4 -18
- package/dist/lib/core/dynamic-models.d.ts +8 -8
- package/dist/lib/core/factory.js +3 -11
- package/dist/lib/index.d.ts +2 -4
- package/dist/lib/index.js +2 -11
- package/dist/lib/mcp/factory.d.ts +1 -1
- package/dist/lib/mcp/index.d.ts +9 -21
- package/dist/lib/mcp/index.js +16 -57
- package/dist/lib/mcp/registry.js +1 -1
- package/dist/lib/mcp/servers/ai-providers/ai-analysis-tools.js +2 -1
- package/dist/lib/mcp/tool-registry.js +1 -1
- package/dist/lib/neurolink.d.ts +1 -9
- package/dist/lib/neurolink.js +22 -71
- package/dist/lib/providers/amazon-bedrock.js +5 -16
- package/dist/lib/providers/anthropic-baseprovider.js +3 -21
- package/dist/lib/providers/anthropic.js +4 -7
- package/dist/lib/providers/azure-openai.js +6 -3
- package/dist/lib/providers/google-vertex.js +5 -9
- package/dist/lib/providers/huggingFace.js +5 -10
- package/dist/lib/providers/mistral.js +5 -8
- package/dist/lib/providers/openAI.js +4 -7
- package/dist/lib/telemetry/index.js +2 -1
- package/dist/lib/utils/logger.d.ts +62 -2
- package/dist/lib/utils/logger.js +174 -9
- package/dist/lib/utils/providerConfig.d.ts +117 -0
- package/dist/lib/utils/providerConfig.js +353 -0
- package/dist/lib/utils/providerUtils.d.ts +2 -1
- package/dist/lib/utils/providerUtils.js +53 -36
- package/dist/lib/utils/timeout.d.ts +72 -1
- package/dist/lib/utils/timeout.js +203 -2
- package/dist/mcp/factory.d.ts +1 -1
- package/dist/mcp/index.d.ts +9 -21
- package/dist/mcp/index.js +16 -57
- package/dist/mcp/registry.js +1 -1
- package/dist/mcp/servers/ai-providers/ai-analysis-tools.js +2 -1
- package/dist/mcp/tool-registry.js +1 -1
- package/dist/neurolink.d.ts +1 -9
- package/dist/neurolink.js +22 -71
- package/dist/providers/amazon-bedrock.js +5 -16
- package/dist/providers/anthropic-baseprovider.js +3 -21
- package/dist/providers/anthropic.js +4 -7
- package/dist/providers/azure-openai.js +6 -3
- package/dist/providers/google-vertex.js +5 -9
- package/dist/providers/huggingFace.js +5 -10
- package/dist/providers/mistral.js +5 -8
- package/dist/providers/openAI.js +4 -7
- package/dist/telemetry/index.js +2 -1
- package/dist/utils/logger.d.ts +62 -2
- package/dist/utils/logger.js +174 -9
- package/dist/utils/providerConfig.d.ts +117 -0
- package/dist/utils/providerConfig.js +353 -0
- package/dist/utils/providerUtils.d.ts +2 -1
- package/dist/utils/providerUtils.js +53 -36
- package/dist/utils/timeout.d.ts +72 -1
- package/dist/utils/timeout.js +203 -2
- package/package.json +1 -1
- package/dist/chat/client-utils.d.ts +0 -95
- package/dist/chat/client-utils.js +0 -315
- package/dist/chat/index.d.ts +0 -24
- package/dist/chat/index.js +0 -33
- package/dist/chat/session-storage.d.ts +0 -77
- package/dist/chat/session-storage.js +0 -233
- package/dist/chat/session.d.ts +0 -96
- package/dist/chat/session.js +0 -257
- package/dist/chat/sse-handler.d.ts +0 -49
- package/dist/chat/sse-handler.js +0 -259
- package/dist/chat/types.d.ts +0 -74
- package/dist/chat/types.js +0 -5
- package/dist/chat/websocket-chat-handler.d.ts +0 -37
- package/dist/chat/websocket-chat-handler.js +0 -262
- package/dist/cli/commands/mcp.d.ts +0 -20
- package/dist/cli/commands/mcp.js +0 -1272
- package/dist/core/defaults.d.ts +0 -19
- package/dist/core/defaults.js +0 -29
- package/dist/core/evaluation-config.d.ts +0 -29
- package/dist/core/evaluation-config.js +0 -144
- package/dist/factories/compatibility-factory.d.ts +0 -35
- package/dist/factories/compatibility-factory.js +0 -71
- package/dist/factories/provider-generate-factory.d.ts +0 -20
- package/dist/factories/provider-generate-factory.js +0 -93
- package/dist/lib/chat/client-utils.d.ts +0 -95
- package/dist/lib/chat/client-utils.js +0 -315
- package/dist/lib/chat/index.d.ts +0 -24
- package/dist/lib/chat/index.js +0 -33
- package/dist/lib/chat/session-storage.d.ts +0 -77
- package/dist/lib/chat/session-storage.js +0 -233
- package/dist/lib/chat/session.d.ts +0 -96
- package/dist/lib/chat/session.js +0 -257
- package/dist/lib/chat/sse-handler.d.ts +0 -49
- package/dist/lib/chat/sse-handler.js +0 -259
- package/dist/lib/chat/types.d.ts +0 -74
- package/dist/lib/chat/types.js +0 -5
- package/dist/lib/chat/websocket-chat-handler.d.ts +0 -37
- package/dist/lib/chat/websocket-chat-handler.js +0 -262
- package/dist/lib/core/defaults.d.ts +0 -19
- package/dist/lib/core/defaults.js +0 -29
- package/dist/lib/core/evaluation-config.d.ts +0 -29
- package/dist/lib/core/evaluation-config.js +0 -144
- package/dist/lib/factories/compatibility-factory.d.ts +0 -35
- package/dist/lib/factories/compatibility-factory.js +0 -71
- package/dist/lib/factories/provider-generate-factory.d.ts +0 -20
- package/dist/lib/factories/provider-generate-factory.js +0 -93
- package/dist/lib/mcp/adapters/plugin-bridge.d.ts +0 -40
- package/dist/lib/mcp/adapters/plugin-bridge.js +0 -89
- package/dist/lib/mcp/auto-discovery.d.ts +0 -62
- package/dist/lib/mcp/auto-discovery.js +0 -149
- package/dist/lib/mcp/client.d.ts +0 -68
- package/dist/lib/mcp/client.js +0 -248
- package/dist/lib/mcp/config.d.ts +0 -31
- package/dist/lib/mcp/config.js +0 -99
- package/dist/lib/mcp/context-manager.d.ts +0 -171
- package/dist/lib/mcp/context-manager.js +0 -362
- package/dist/lib/mcp/contracts/mcp-contract.d.ts +0 -169
- package/dist/lib/mcp/contracts/mcp-contract.js +0 -58
- package/dist/lib/mcp/core/plugin-manager.d.ts +0 -46
- package/dist/lib/mcp/core/plugin-manager.js +0 -110
- package/dist/lib/mcp/demo/plugin-demo.d.ts +0 -20
- package/dist/lib/mcp/demo/plugin-demo.js +0 -118
- package/dist/lib/mcp/dynamic-chain-executor.d.ts +0 -225
- package/dist/lib/mcp/dynamic-chain-executor.js +0 -489
- package/dist/lib/mcp/dynamic-orchestrator.d.ts +0 -115
- package/dist/lib/mcp/dynamic-orchestrator.js +0 -351
- package/dist/lib/mcp/ecosystem.d.ts +0 -75
- package/dist/lib/mcp/ecosystem.js +0 -161
- package/dist/lib/mcp/error-manager.d.ts +0 -254
- package/dist/lib/mcp/error-manager.js +0 -501
- package/dist/lib/mcp/error-recovery.d.ts +0 -159
- package/dist/lib/mcp/error-recovery.js +0 -405
- package/dist/lib/mcp/external-client.d.ts +0 -88
- package/dist/lib/mcp/external-client.js +0 -331
- package/dist/lib/mcp/external-manager.d.ts +0 -112
- package/dist/lib/mcp/external-manager.js +0 -308
- package/dist/lib/mcp/function-calling.d.ts +0 -65
- package/dist/lib/mcp/function-calling.js +0 -642
- package/dist/lib/mcp/health-monitor.d.ts +0 -257
- package/dist/lib/mcp/health-monitor.js +0 -630
- package/dist/lib/mcp/initialize-tools.d.ts +0 -29
- package/dist/lib/mcp/initialize-tools.js +0 -261
- package/dist/lib/mcp/initialize.d.ts +0 -18
- package/dist/lib/mcp/initialize.js +0 -62
- package/dist/lib/mcp/logging.d.ts +0 -38
- package/dist/lib/mcp/logging.js +0 -100
- package/dist/lib/mcp/manager.d.ts +0 -68
- package/dist/lib/mcp/manager.js +0 -176
- package/dist/lib/mcp/neurolink-mcp-client.d.ts +0 -97
- package/dist/lib/mcp/neurolink-mcp-client.js +0 -462
- package/dist/lib/mcp/orchestrator.d.ts +0 -302
- package/dist/lib/mcp/orchestrator.js +0 -703
- package/dist/lib/mcp/plugin-manager.d.ts +0 -98
- package/dist/lib/mcp/plugin-manager.js +0 -296
- package/dist/lib/mcp/plugins/core/filesystem-mcp.d.ts +0 -36
- package/dist/lib/mcp/plugins/core/filesystem-mcp.js +0 -142
- package/dist/lib/mcp/plugins/filesystem-mcp.d.ts +0 -37
- package/dist/lib/mcp/plugins/filesystem-mcp.js +0 -54
- package/dist/lib/mcp/security-manager.d.ts +0 -87
- package/dist/lib/mcp/security-manager.js +0 -344
- package/dist/lib/mcp/semaphore-manager.d.ts +0 -137
- package/dist/lib/mcp/semaphore-manager.js +0 -329
- package/dist/lib/mcp/session-manager.d.ts +0 -187
- package/dist/lib/mcp/session-manager.js +0 -400
- package/dist/lib/mcp/session-persistence.d.ts +0 -93
- package/dist/lib/mcp/session-persistence.js +0 -301
- package/dist/lib/mcp/tool-integration.d.ts +0 -58
- package/dist/lib/mcp/tool-integration.js +0 -203
- package/dist/lib/mcp/transport-manager.d.ts +0 -154
- package/dist/lib/mcp/transport-manager.js +0 -334
- package/dist/lib/mcp/unified-mcp.d.ts +0 -133
- package/dist/lib/mcp/unified-mcp.js +0 -251
- package/dist/lib/mcp/unified-registry.d.ts +0 -165
- package/dist/lib/mcp/unified-registry.js +0 -538
- package/dist/lib/providers/analytics-helper.d.ts +0 -38
- package/dist/lib/providers/analytics-helper.js +0 -216
- package/dist/lib/providers/function-calling-provider.d.ts +0 -142
- package/dist/lib/providers/function-calling-provider.js +0 -630
- package/dist/lib/providers/mcp-provider.d.ts +0 -75
- package/dist/lib/providers/mcp-provider.js +0 -283
- package/dist/lib/providers/timeout-wrapper.d.ts +0 -40
- package/dist/lib/providers/timeout-wrapper.js +0 -100
- package/dist/lib/sdk/tool-extension.d.ts +0 -181
- package/dist/lib/sdk/tool-extension.js +0 -284
- package/dist/lib/services/streaming/streaming-manager.d.ts +0 -29
- package/dist/lib/services/streaming/streaming-manager.js +0 -245
- package/dist/lib/services/types.d.ts +0 -156
- package/dist/lib/services/types.js +0 -2
- package/dist/lib/services/websocket/websocket-server.d.ts +0 -34
- package/dist/lib/services/websocket/websocket-server.js +0 -305
- package/dist/lib/utils/provider-validation.d.ts +0 -36
- package/dist/lib/utils/provider-validation.js +0 -625
- package/dist/lib/utils/providerUtils-fixed.d.ts +0 -8
- package/dist/lib/utils/providerUtils-fixed.js +0 -94
- package/dist/lib/utils/streaming-utils.d.ts +0 -79
- package/dist/lib/utils/streaming-utils.js +0 -198
- package/dist/lib/utils/timeout-manager.d.ts +0 -75
- package/dist/lib/utils/timeout-manager.js +0 -244
- package/dist/mcp/adapters/plugin-bridge.d.ts +0 -40
- package/dist/mcp/adapters/plugin-bridge.js +0 -89
- package/dist/mcp/auto-discovery.d.ts +0 -62
- package/dist/mcp/auto-discovery.js +0 -149
- package/dist/mcp/client.d.ts +0 -68
- package/dist/mcp/client.js +0 -248
- package/dist/mcp/config.d.ts +0 -31
- package/dist/mcp/config.js +0 -99
- package/dist/mcp/context-manager.d.ts +0 -171
- package/dist/mcp/context-manager.js +0 -362
- package/dist/mcp/contracts/mcp-contract.d.ts +0 -169
- package/dist/mcp/contracts/mcp-contract.js +0 -58
- package/dist/mcp/core/plugin-manager.d.ts +0 -46
- package/dist/mcp/core/plugin-manager.js +0 -110
- package/dist/mcp/demo/plugin-demo.d.ts +0 -20
- package/dist/mcp/demo/plugin-demo.js +0 -118
- package/dist/mcp/dynamic-chain-executor.d.ts +0 -225
- package/dist/mcp/dynamic-chain-executor.js +0 -489
- package/dist/mcp/dynamic-orchestrator.d.ts +0 -115
- package/dist/mcp/dynamic-orchestrator.js +0 -351
- package/dist/mcp/ecosystem.d.ts +0 -75
- package/dist/mcp/ecosystem.js +0 -162
- package/dist/mcp/error-manager.d.ts +0 -254
- package/dist/mcp/error-manager.js +0 -501
- package/dist/mcp/error-recovery.d.ts +0 -159
- package/dist/mcp/error-recovery.js +0 -405
- package/dist/mcp/external-client.d.ts +0 -88
- package/dist/mcp/external-client.js +0 -331
- package/dist/mcp/external-manager.d.ts +0 -112
- package/dist/mcp/external-manager.js +0 -308
- package/dist/mcp/function-calling.d.ts +0 -65
- package/dist/mcp/function-calling.js +0 -642
- package/dist/mcp/health-monitor.d.ts +0 -257
- package/dist/mcp/health-monitor.js +0 -630
- package/dist/mcp/initialize-tools.d.ts +0 -29
- package/dist/mcp/initialize-tools.js +0 -262
- package/dist/mcp/initialize.d.ts +0 -18
- package/dist/mcp/initialize.js +0 -62
- package/dist/mcp/logging.d.ts +0 -38
- package/dist/mcp/logging.js +0 -100
- package/dist/mcp/manager.d.ts +0 -68
- package/dist/mcp/manager.js +0 -176
- package/dist/mcp/neurolink-mcp-client.d.ts +0 -97
- package/dist/mcp/neurolink-mcp-client.js +0 -462
- package/dist/mcp/orchestrator.d.ts +0 -302
- package/dist/mcp/orchestrator.js +0 -703
- package/dist/mcp/plugin-manager.d.ts +0 -98
- package/dist/mcp/plugin-manager.js +0 -297
- package/dist/mcp/plugins/core/filesystem-mcp.d.ts +0 -36
- package/dist/mcp/plugins/core/filesystem-mcp.js +0 -142
- package/dist/mcp/plugins/core/neurolink-mcp.json +0 -17
- package/dist/mcp/plugins/filesystem-mcp.d.ts +0 -37
- package/dist/mcp/plugins/filesystem-mcp.js +0 -54
- package/dist/mcp/security-manager.d.ts +0 -87
- package/dist/mcp/security-manager.js +0 -344
- package/dist/mcp/semaphore-manager.d.ts +0 -137
- package/dist/mcp/semaphore-manager.js +0 -329
- package/dist/mcp/session-manager.d.ts +0 -187
- package/dist/mcp/session-manager.js +0 -400
- package/dist/mcp/session-persistence.d.ts +0 -93
- package/dist/mcp/session-persistence.js +0 -302
- package/dist/mcp/tool-integration.d.ts +0 -58
- package/dist/mcp/tool-integration.js +0 -203
- package/dist/mcp/transport-manager.d.ts +0 -154
- package/dist/mcp/transport-manager.js +0 -335
- package/dist/mcp/unified-mcp.d.ts +0 -133
- package/dist/mcp/unified-mcp.js +0 -251
- package/dist/mcp/unified-registry.d.ts +0 -165
- package/dist/mcp/unified-registry.js +0 -539
- package/dist/providers/analytics-helper.d.ts +0 -38
- package/dist/providers/analytics-helper.js +0 -216
- package/dist/providers/function-calling-provider.d.ts +0 -142
- package/dist/providers/function-calling-provider.js +0 -630
- package/dist/providers/mcp-provider.d.ts +0 -75
- package/dist/providers/mcp-provider.js +0 -283
- package/dist/providers/timeout-wrapper.d.ts +0 -40
- package/dist/providers/timeout-wrapper.js +0 -100
- package/dist/sdk/tool-extension.d.ts +0 -181
- package/dist/sdk/tool-extension.js +0 -284
- package/dist/services/streaming/streaming-manager.d.ts +0 -29
- package/dist/services/streaming/streaming-manager.js +0 -245
- package/dist/services/types.d.ts +0 -156
- package/dist/services/types.js +0 -2
- package/dist/services/websocket/websocket-server.d.ts +0 -34
- package/dist/services/websocket/websocket-server.js +0 -306
- package/dist/utils/provider-validation.d.ts +0 -36
- package/dist/utils/provider-validation.js +0 -625
- package/dist/utils/providerUtils-fixed.d.ts +0 -8
- package/dist/utils/providerUtils-fixed.js +0 -94
- package/dist/utils/streaming-utils.d.ts +0 -79
- package/dist/utils/streaming-utils.js +0 -198
- package/dist/utils/timeout-manager.d.ts +0 -75
- package/dist/utils/timeout-manager.js +0 -244
package/dist/core/defaults.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Default value helper functions for NeuroLink
|
|
3
|
-
* Centralized logic for applying defaults across the system
|
|
4
|
-
*/
|
|
5
|
-
import type { UnknownRecord } from "../types/common.js";
|
|
6
|
-
/**
|
|
7
|
-
* Apply default values to options object
|
|
8
|
-
* User-provided values take precedence over defaults
|
|
9
|
-
*/
|
|
10
|
-
export declare function applyDefaults(options: UnknownRecord): UnknownRecord;
|
|
11
|
-
/**
|
|
12
|
-
* Get default max tokens for a specific provider
|
|
13
|
-
* Can be extended for provider-specific overrides in the future
|
|
14
|
-
*/
|
|
15
|
-
export declare function getDefaultMaxTokens(provider?: string): number;
|
|
16
|
-
/**
|
|
17
|
-
* Get default temperature for a specific use case
|
|
18
|
-
*/
|
|
19
|
-
export declare function getDefaultTemperature(useCase?: string): number;
|
package/dist/core/defaults.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Default value helper functions for NeuroLink
|
|
3
|
-
* Centralized logic for applying defaults across the system
|
|
4
|
-
*/
|
|
5
|
-
import { DEFAULT_MAX_TOKENS, DEFAULT_TEMPERATURE, ENV_DEFAULTS, } from "./constants.js";
|
|
6
|
-
/**
|
|
7
|
-
* Apply default values to options object
|
|
8
|
-
* User-provided values take precedence over defaults
|
|
9
|
-
*/
|
|
10
|
-
export function applyDefaults(options) {
|
|
11
|
-
return {
|
|
12
|
-
maxTokens: ENV_DEFAULTS.maxTokens,
|
|
13
|
-
temperature: ENV_DEFAULTS.temperature,
|
|
14
|
-
...options, // User overrides take precedence
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Get default max tokens for a specific provider
|
|
19
|
-
* Can be extended for provider-specific overrides in the future
|
|
20
|
-
*/
|
|
21
|
-
export function getDefaultMaxTokens(provider) {
|
|
22
|
-
return ENV_DEFAULTS.maxTokens;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Get default temperature for a specific use case
|
|
26
|
-
*/
|
|
27
|
-
export function getDefaultTemperature(useCase) {
|
|
28
|
-
return ENV_DEFAULTS.temperature;
|
|
29
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { EvaluationConfig } from "./types.js";
|
|
2
|
-
/**
|
|
3
|
-
* Parse evaluation configuration from environment variables
|
|
4
|
-
*/
|
|
5
|
-
export declare function parseEvaluationConfig(): EvaluationConfig;
|
|
6
|
-
/**
|
|
7
|
-
* Get intelligent provider fallback order
|
|
8
|
-
*/
|
|
9
|
-
export declare function getProviderFallbackOrder(config: EvaluationConfig): string[];
|
|
10
|
-
/**
|
|
11
|
-
* Estimate evaluation cost
|
|
12
|
-
*/
|
|
13
|
-
export declare function estimateEvaluationCost(providerName: string, mode: string, promptLength: number, expectedResponseLength?: number): number;
|
|
14
|
-
/**
|
|
15
|
-
* Validate evaluation configuration
|
|
16
|
-
*/
|
|
17
|
-
export declare function validateEvaluationConfig(config: EvaluationConfig): string[];
|
|
18
|
-
/**
|
|
19
|
-
* Get configuration with validation and defaults
|
|
20
|
-
*/
|
|
21
|
-
export declare function getValidatedEvaluationConfig(): EvaluationConfig;
|
|
22
|
-
/**
|
|
23
|
-
* Check if evaluation is enabled for the current configuration
|
|
24
|
-
*/
|
|
25
|
-
export declare function isEvaluationEnabled(): boolean;
|
|
26
|
-
/**
|
|
27
|
-
* Get cost-optimized provider based on configuration
|
|
28
|
-
*/
|
|
29
|
-
export declare function getCostOptimizedProvider(config: EvaluationConfig): string | null;
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import { getAvailableProviders, sortProvidersByPreference, getProviderConfig, } from "./evaluation-providers.js";
|
|
2
|
-
import { logger } from "../utils/logger.js";
|
|
3
|
-
/**
|
|
4
|
-
* Parse evaluation configuration from environment variables
|
|
5
|
-
*/
|
|
6
|
-
export function parseEvaluationConfig() {
|
|
7
|
-
return {
|
|
8
|
-
provider: process.env.NEUROLINK_EVALUATION_PROVIDER || "google-ai",
|
|
9
|
-
model: process.env.NEUROLINK_EVALUATION_MODEL || "gemini-2.5-flash",
|
|
10
|
-
mode: process.env.NEUROLINK_EVALUATION_MODE || "fast",
|
|
11
|
-
fallbackEnabled: process.env.NEUROLINK_EVALUATION_FALLBACK_ENABLED !== "false",
|
|
12
|
-
fallbackProviders: (process.env.NEUROLINK_EVALUATION_FALLBACK_PROVIDERS ||
|
|
13
|
-
"openai,anthropic,vertex,bedrock").split(","),
|
|
14
|
-
timeout: parseInt(process.env.NEUROLINK_EVALUATION_TIMEOUT || "10000"),
|
|
15
|
-
maxTokens: parseInt(process.env.NEUROLINK_EVALUATION_MAX_TOKENS || "500"),
|
|
16
|
-
temperature: parseFloat(process.env.NEUROLINK_EVALUATION_TEMPERATURE || "0.1"),
|
|
17
|
-
preferCheap: process.env.NEUROLINK_EVALUATION_PREFER_CHEAP !== "false",
|
|
18
|
-
maxCostPerEval: parseFloat(process.env.NEUROLINK_EVALUATION_MAX_COST_PER_EVAL || "0.01"),
|
|
19
|
-
retryAttempts: parseInt(process.env.NEUROLINK_EVALUATION_RETRY_ATTEMPTS || "2"),
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Get intelligent provider fallback order
|
|
24
|
-
*/
|
|
25
|
-
export function getProviderFallbackOrder(config) {
|
|
26
|
-
const available = getAvailableProviders();
|
|
27
|
-
const sorted = sortProvidersByPreference(available, config.preferCheap);
|
|
28
|
-
// Start with user's preferred provider
|
|
29
|
-
const fallbackOrder = [config.provider];
|
|
30
|
-
// Add configured fallbacks
|
|
31
|
-
config.fallbackProviders.forEach((provider) => {
|
|
32
|
-
if (!fallbackOrder.includes(provider)) {
|
|
33
|
-
fallbackOrder.push(provider);
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
// Add remaining available providers
|
|
37
|
-
sorted.forEach((providerConfig) => {
|
|
38
|
-
if (!fallbackOrder.includes(providerConfig.provider)) {
|
|
39
|
-
fallbackOrder.push(providerConfig.provider);
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
logger.debug("[EvaluationConfig] Provider fallback order:", fallbackOrder);
|
|
43
|
-
return fallbackOrder;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Estimate evaluation cost
|
|
47
|
-
*/
|
|
48
|
-
export function estimateEvaluationCost(providerName, mode, promptLength, expectedResponseLength = 200) {
|
|
49
|
-
const config = getProviderConfig(providerName);
|
|
50
|
-
if (!config || !config.costPerToken) {
|
|
51
|
-
return 0;
|
|
52
|
-
}
|
|
53
|
-
const inputTokens = Math.ceil(promptLength / 4); // Rough token estimation
|
|
54
|
-
const outputTokens = expectedResponseLength / 4;
|
|
55
|
-
return (inputTokens * config.costPerToken.input +
|
|
56
|
-
outputTokens * config.costPerToken.output);
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Validate evaluation configuration
|
|
60
|
-
*/
|
|
61
|
-
export function validateEvaluationConfig(config) {
|
|
62
|
-
const errors = [];
|
|
63
|
-
// Validate provider
|
|
64
|
-
if (!getProviderConfig(config.provider)) {
|
|
65
|
-
errors.push(`Invalid provider: ${config.provider}`);
|
|
66
|
-
}
|
|
67
|
-
// Validate mode
|
|
68
|
-
if (!["fast", "balanced", "quality"].includes(config.mode)) {
|
|
69
|
-
errors.push(`Invalid mode: ${config.mode}. Must be 'fast', 'balanced', or 'quality'`);
|
|
70
|
-
}
|
|
71
|
-
// Validate timeout
|
|
72
|
-
if (config.timeout <= 0 || config.timeout > 60000) {
|
|
73
|
-
errors.push(`Invalid timeout: ${config.timeout}. Must be between 1 and 60000ms`);
|
|
74
|
-
}
|
|
75
|
-
// Validate max tokens
|
|
76
|
-
if (config.maxTokens <= 0 || config.maxTokens > 4000) {
|
|
77
|
-
errors.push(`Invalid maxTokens: ${config.maxTokens}. Must be between 1 and 4000`);
|
|
78
|
-
}
|
|
79
|
-
// Validate temperature
|
|
80
|
-
if (config.temperature < 0 || config.temperature > 2) {
|
|
81
|
-
errors.push(`Invalid temperature: ${config.temperature}. Must be between 0 and 2`);
|
|
82
|
-
}
|
|
83
|
-
// Validate max cost
|
|
84
|
-
if (config.maxCostPerEval <= 0) {
|
|
85
|
-
errors.push(`Invalid maxCostPerEval: ${config.maxCostPerEval}. Must be greater than 0`);
|
|
86
|
-
}
|
|
87
|
-
// Validate retry attempts
|
|
88
|
-
if (config.retryAttempts < 0 || config.retryAttempts > 5) {
|
|
89
|
-
errors.push(`Invalid retryAttempts: ${config.retryAttempts}. Must be between 0 and 5`);
|
|
90
|
-
}
|
|
91
|
-
return errors;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Get configuration with validation and defaults
|
|
95
|
-
*/
|
|
96
|
-
export function getValidatedEvaluationConfig() {
|
|
97
|
-
const config = parseEvaluationConfig();
|
|
98
|
-
const errors = validateEvaluationConfig(config);
|
|
99
|
-
if (errors.length > 0) {
|
|
100
|
-
logger.warn("[EvaluationConfig] Configuration validation errors:", errors);
|
|
101
|
-
// Return default configuration if validation fails
|
|
102
|
-
return {
|
|
103
|
-
provider: "google-ai",
|
|
104
|
-
model: "gemini-2.5-flash",
|
|
105
|
-
mode: "fast",
|
|
106
|
-
fallbackEnabled: true,
|
|
107
|
-
fallbackProviders: ["openai", "anthropic"],
|
|
108
|
-
timeout: 10000,
|
|
109
|
-
maxTokens: 500,
|
|
110
|
-
temperature: 0.1,
|
|
111
|
-
preferCheap: true,
|
|
112
|
-
maxCostPerEval: 0.01,
|
|
113
|
-
retryAttempts: 2,
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
return config;
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Check if evaluation is enabled for the current configuration
|
|
120
|
-
*/
|
|
121
|
-
export function isEvaluationEnabled() {
|
|
122
|
-
// Check if at least one provider is available
|
|
123
|
-
const available = getAvailableProviders();
|
|
124
|
-
return available.length > 0;
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Get cost-optimized provider based on configuration
|
|
128
|
-
*/
|
|
129
|
-
export function getCostOptimizedProvider(config) {
|
|
130
|
-
const available = getAvailableProviders();
|
|
131
|
-
if (available.length === 0) {
|
|
132
|
-
return null;
|
|
133
|
-
}
|
|
134
|
-
const sorted = sortProvidersByPreference(available, true); // Always prefer cheap for cost optimization
|
|
135
|
-
// Find the cheapest provider that meets cost requirements
|
|
136
|
-
for (const providerConfig of sorted) {
|
|
137
|
-
const estimatedCost = estimateEvaluationCost(providerConfig.provider, config.mode, 1000);
|
|
138
|
-
if (estimatedCost <= config.maxCostPerEval) {
|
|
139
|
-
return providerConfig.provider;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
// If no provider meets cost requirements, return the cheapest one
|
|
143
|
-
return sorted[0].provider;
|
|
144
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { GenerateOptions, GenerateResult } from "../types/generate-types.js";
|
|
2
|
-
import type { TextGenerationOptions } from "../core/types.js";
|
|
3
|
-
/**
|
|
4
|
-
* Compatibility conversion factory for seamless migration
|
|
5
|
-
* between generateText and generate functions
|
|
6
|
-
*/
|
|
7
|
-
export declare class CompatibilityConversionFactory {
|
|
8
|
-
/**
|
|
9
|
-
* Convert TextGenerationOptions to GenerateOptions
|
|
10
|
-
*/
|
|
11
|
-
static convertTextToGenerate(options: TextGenerationOptions): GenerateOptions;
|
|
12
|
-
/**
|
|
13
|
-
* Convert GenerateResult to legacy TextGenerationResult format
|
|
14
|
-
*/
|
|
15
|
-
static convertGenerateToText(result: GenerateResult): {
|
|
16
|
-
content: string;
|
|
17
|
-
provider?: string;
|
|
18
|
-
model?: string;
|
|
19
|
-
usage?: {
|
|
20
|
-
inputTokens: number;
|
|
21
|
-
outputTokens: number;
|
|
22
|
-
totalTokens: number;
|
|
23
|
-
};
|
|
24
|
-
responseTime?: number;
|
|
25
|
-
toolsUsed?: number;
|
|
26
|
-
toolExecutions?: unknown[];
|
|
27
|
-
analytics?: unknown;
|
|
28
|
-
evaluation?: unknown;
|
|
29
|
-
[key: string]: unknown;
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* Convert GenerateOptions to TextGenerationOptions
|
|
33
|
-
*/
|
|
34
|
-
static convertGenerateToText_Options(options: GenerateOptions): TextGenerationOptions;
|
|
35
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Compatibility conversion factory for seamless migration
|
|
3
|
-
* between generateText and generate functions
|
|
4
|
-
*/
|
|
5
|
-
export class CompatibilityConversionFactory {
|
|
6
|
-
/**
|
|
7
|
-
* Convert TextGenerationOptions to GenerateOptions
|
|
8
|
-
*/
|
|
9
|
-
static convertTextToGenerate(options) {
|
|
10
|
-
const { prompt, ...rest } = options;
|
|
11
|
-
return {
|
|
12
|
-
input: { text: prompt || "" },
|
|
13
|
-
output: { format: "text" },
|
|
14
|
-
provider: rest.provider,
|
|
15
|
-
model: rest.model,
|
|
16
|
-
temperature: rest.temperature,
|
|
17
|
-
maxTokens: rest.maxTokens,
|
|
18
|
-
systemPrompt: rest.systemPrompt,
|
|
19
|
-
schema: rest.schema,
|
|
20
|
-
tools: rest.tools,
|
|
21
|
-
timeout: rest.timeout,
|
|
22
|
-
enableEvaluation: rest.enableEvaluation,
|
|
23
|
-
enableAnalytics: rest.enableAnalytics,
|
|
24
|
-
context: rest.context,
|
|
25
|
-
evaluationDomain: rest.evaluationDomain,
|
|
26
|
-
toolUsageContext: rest.toolUsageContext,
|
|
27
|
-
conversationHistory: rest.conversationHistory,
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Convert GenerateResult to legacy TextGenerationResult format
|
|
32
|
-
*/
|
|
33
|
-
static convertGenerateToText(result) {
|
|
34
|
-
return {
|
|
35
|
-
content: result.content,
|
|
36
|
-
provider: result.provider,
|
|
37
|
-
model: result.model,
|
|
38
|
-
usage: result.usage,
|
|
39
|
-
responseTime: result.responseTime,
|
|
40
|
-
toolsUsed: Array.isArray(result.toolsUsed)
|
|
41
|
-
? result.toolsUsed.length
|
|
42
|
-
: result.toolsUsed,
|
|
43
|
-
toolExecutions: result.toolExecutions,
|
|
44
|
-
enhancedWithTools: result.enhancedWithTools,
|
|
45
|
-
availableTools: result.availableTools,
|
|
46
|
-
analytics: result.analytics,
|
|
47
|
-
evaluation: result.evaluation,
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Convert GenerateOptions to TextGenerationOptions
|
|
52
|
-
*/
|
|
53
|
-
static convertGenerateToText_Options(options) {
|
|
54
|
-
return {
|
|
55
|
-
prompt: options.input.text,
|
|
56
|
-
model: options.model,
|
|
57
|
-
temperature: options.temperature,
|
|
58
|
-
maxTokens: options.maxTokens,
|
|
59
|
-
systemPrompt: options.systemPrompt,
|
|
60
|
-
schema: options.schema,
|
|
61
|
-
tools: options.tools,
|
|
62
|
-
timeout: options.timeout,
|
|
63
|
-
enableEvaluation: options.enableEvaluation,
|
|
64
|
-
enableAnalytics: options.enableAnalytics,
|
|
65
|
-
context: options.context,
|
|
66
|
-
evaluationDomain: options.evaluationDomain,
|
|
67
|
-
toolUsageContext: options.toolUsageContext,
|
|
68
|
-
conversationHistory: options.conversationHistory,
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { EnhancedProvider } from "../types/generate-types.js";
|
|
2
|
-
import type { AIProvider } from "../core/types.js";
|
|
3
|
-
/**
|
|
4
|
-
* Factory for enhancing providers with generate() capability using Proxy pattern
|
|
5
|
-
* Maintains 100% backward compatibility while adding new generate method
|
|
6
|
-
*/
|
|
7
|
-
export declare class ProviderGenerateFactory {
|
|
8
|
-
/**
|
|
9
|
-
* Enhance any provider with generate() method using TypeScript Proxy
|
|
10
|
-
*/
|
|
11
|
-
static enhanceProvider<T extends AIProvider>(provider: T): T & EnhancedProvider;
|
|
12
|
-
/**
|
|
13
|
-
* Create the generate() method that internally uses generateText for performance parity
|
|
14
|
-
*/
|
|
15
|
-
private static createGenerateMethod;
|
|
16
|
-
/**
|
|
17
|
-
* Enhance all providers from a registry
|
|
18
|
-
*/
|
|
19
|
-
static enhanceAllProviders(providers: Map<string, AIProvider>): Map<string, AIProvider & EnhancedProvider>;
|
|
20
|
-
}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { CompatibilityConversionFactory } from "./compatibility-factory.js";
|
|
2
|
-
/**
|
|
3
|
-
* Factory for enhancing providers with generate() capability using Proxy pattern
|
|
4
|
-
* Maintains 100% backward compatibility while adding new generate method
|
|
5
|
-
*/
|
|
6
|
-
export class ProviderGenerateFactory {
|
|
7
|
-
/**
|
|
8
|
-
* Enhance any provider with generate() method using TypeScript Proxy
|
|
9
|
-
*/
|
|
10
|
-
static enhanceProvider(provider) {
|
|
11
|
-
return new Proxy(provider, {
|
|
12
|
-
get(target, prop, receiver) {
|
|
13
|
-
if (prop === "generate") {
|
|
14
|
-
return ProviderGenerateFactory.createGenerateMethod(target);
|
|
15
|
-
}
|
|
16
|
-
return Reflect.get(target, prop, receiver);
|
|
17
|
-
},
|
|
18
|
-
has(target, prop) {
|
|
19
|
-
if (prop === "generate") {
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
|
-
return Reflect.has(target, prop);
|
|
23
|
-
},
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Create the generate() method that internally uses generateText for performance parity
|
|
28
|
-
*/
|
|
29
|
-
static createGenerateMethod(provider) {
|
|
30
|
-
return async (options) => {
|
|
31
|
-
// Validate input
|
|
32
|
-
if (!options.input?.text) {
|
|
33
|
-
throw new Error("Generate options must include input.text");
|
|
34
|
-
}
|
|
35
|
-
// Convert GenerateOptions to TextGenerationOptions
|
|
36
|
-
const textOptions = CompatibilityConversionFactory.convertGenerateToText_Options(options);
|
|
37
|
-
try {
|
|
38
|
-
// Use existing generate method for identical performance
|
|
39
|
-
const textResult = await provider.generate(textOptions);
|
|
40
|
-
if (!textResult) {
|
|
41
|
-
throw new Error("Generate method returned null result");
|
|
42
|
-
}
|
|
43
|
-
// Convert back to GenerateResult format with type safety
|
|
44
|
-
const generateResult = {
|
|
45
|
-
content: textResult.content || "",
|
|
46
|
-
outputs: { text: textResult.content || "" },
|
|
47
|
-
provider: textResult.provider,
|
|
48
|
-
model: textResult.model,
|
|
49
|
-
usage: textResult.usage
|
|
50
|
-
? {
|
|
51
|
-
inputTokens: textResult.usage.inputTokens || 0,
|
|
52
|
-
outputTokens: textResult.usage.outputTokens || 0,
|
|
53
|
-
totalTokens: textResult.usage.totalTokens || 0,
|
|
54
|
-
}
|
|
55
|
-
: undefined,
|
|
56
|
-
responseTime: textResult.responseTime,
|
|
57
|
-
toolsUsed: textResult.toolsUsed,
|
|
58
|
-
toolExecutions: textResult.toolExecutions?.map((te) => {
|
|
59
|
-
const toolExecution = te;
|
|
60
|
-
return {
|
|
61
|
-
name: toolExecution.toolName || toolExecution.name || "",
|
|
62
|
-
input: toolExecution.input || {},
|
|
63
|
-
output: toolExecution.output || toolExecution.result,
|
|
64
|
-
duration: toolExecution.executionTime || toolExecution.duration || 0,
|
|
65
|
-
};
|
|
66
|
-
}),
|
|
67
|
-
enhancedWithTools: textResult.enhancedWithTools,
|
|
68
|
-
availableTools: textResult.availableTools?.map((at) => ({
|
|
69
|
-
name: at.name || "",
|
|
70
|
-
description: at.description || "",
|
|
71
|
-
parameters: at.parameters || {},
|
|
72
|
-
})),
|
|
73
|
-
analytics: textResult.analytics,
|
|
74
|
-
evaluation: textResult.evaluation,
|
|
75
|
-
};
|
|
76
|
-
return generateResult;
|
|
77
|
-
}
|
|
78
|
-
catch (error) {
|
|
79
|
-
throw new Error(`Generate method failed: ${error}`);
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Enhance all providers from a registry
|
|
85
|
-
*/
|
|
86
|
-
static enhanceAllProviders(providers) {
|
|
87
|
-
const enhancedProviders = new Map();
|
|
88
|
-
for (const [name, provider] of providers) {
|
|
89
|
-
enhancedProviders.set(name, this.enhanceProvider(provider));
|
|
90
|
-
}
|
|
91
|
-
return enhancedProviders;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Phase 3: SSE Chat Utilities
|
|
3
|
-
* Client-side utilities for SSE chat integration
|
|
4
|
-
*/
|
|
5
|
-
import type { ChatMessage } from "./types.js";
|
|
6
|
-
export interface ChatClientOptions {
|
|
7
|
-
endpoint: string;
|
|
8
|
-
sessionId: string;
|
|
9
|
-
onMessage?: (message: ChatMessage) => void;
|
|
10
|
-
onError?: (error: Error) => void;
|
|
11
|
-
onConnect?: () => void;
|
|
12
|
-
onDisconnect?: () => void;
|
|
13
|
-
reconnectAttempts?: number;
|
|
14
|
-
reconnectDelay?: number;
|
|
15
|
-
}
|
|
16
|
-
export interface ChatStreamHook {
|
|
17
|
-
messages: ChatMessage[];
|
|
18
|
-
isConnected: boolean;
|
|
19
|
-
isReconnecting: boolean;
|
|
20
|
-
sendMessage: (content: string) => Promise<void>;
|
|
21
|
-
disconnect: () => void;
|
|
22
|
-
reconnect: () => void;
|
|
23
|
-
clearHistory: () => void;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Client for SSE chat communication
|
|
27
|
-
*/
|
|
28
|
-
export declare class ChatClient {
|
|
29
|
-
private eventSource?;
|
|
30
|
-
private options;
|
|
31
|
-
private messages;
|
|
32
|
-
private reconnectCount;
|
|
33
|
-
private isConnected;
|
|
34
|
-
private isReconnecting;
|
|
35
|
-
private reconnectTimeout?;
|
|
36
|
-
constructor(options: ChatClientOptions);
|
|
37
|
-
/**
|
|
38
|
-
* Connect to SSE endpoint
|
|
39
|
-
*/
|
|
40
|
-
connect(): void;
|
|
41
|
-
/**
|
|
42
|
-
* Send message to chat
|
|
43
|
-
*/
|
|
44
|
-
sendMessage(content: string): Promise<void>;
|
|
45
|
-
/**
|
|
46
|
-
* Disconnect from SSE endpoint
|
|
47
|
-
*/
|
|
48
|
-
disconnect(): void;
|
|
49
|
-
/**
|
|
50
|
-
* Get message history
|
|
51
|
-
*/
|
|
52
|
-
getMessages(): ChatMessage[];
|
|
53
|
-
/**
|
|
54
|
-
* Clear message history
|
|
55
|
-
*/
|
|
56
|
-
clearMessages(): void;
|
|
57
|
-
/**
|
|
58
|
-
* Check connection status
|
|
59
|
-
*/
|
|
60
|
-
getConnectionStatus(): {
|
|
61
|
-
connected: boolean;
|
|
62
|
-
reconnecting: boolean;
|
|
63
|
-
reconnectCount: number;
|
|
64
|
-
};
|
|
65
|
-
private handleSSEEvent;
|
|
66
|
-
private isDataEventData;
|
|
67
|
-
private isErrorEventData;
|
|
68
|
-
private isCompleteEventData;
|
|
69
|
-
private handleDataEvent;
|
|
70
|
-
private handleErrorEvent;
|
|
71
|
-
private handleCompleteEvent;
|
|
72
|
-
private scheduleReconnect;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Create chat client instance
|
|
76
|
-
*/
|
|
77
|
-
export declare function createChatClient(options: ChatClientOptions): ChatClient;
|
|
78
|
-
/**
|
|
79
|
-
* React-style hook for chat streaming (can be adapted for other frameworks)
|
|
80
|
-
*/
|
|
81
|
-
export declare function useChatStream(options: ChatClientOptions): ChatStreamHook;
|
|
82
|
-
/**
|
|
83
|
-
* Utility for creating SSE EventSource with automatic reconnection
|
|
84
|
-
*/
|
|
85
|
-
export declare function createSSEConnection(url: string, options?: {
|
|
86
|
-
onMessage?: (event: MessageEvent) => void;
|
|
87
|
-
onError?: (error: Error) => void;
|
|
88
|
-
onOpen?: () => void;
|
|
89
|
-
reconnect?: boolean;
|
|
90
|
-
maxReconnectAttempts?: number;
|
|
91
|
-
}): {
|
|
92
|
-
connect: () => void;
|
|
93
|
-
disconnect: () => void;
|
|
94
|
-
isConnected: () => boolean;
|
|
95
|
-
};
|