@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/utils/logger.js
CHANGED
|
@@ -1,25 +1,190 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* NeuroLink Logger Utility
|
|
2
|
+
* NeuroLink Unified Logger Utility
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Centralized logging for the entire NeuroLink ecosystem
|
|
5
|
+
* Supports both CLI --debug flag and NEUROLINK_DEBUG environment variable
|
|
6
|
+
* Migrated from MCP logging with enhanced features
|
|
5
7
|
*/
|
|
8
|
+
// Pre-computed uppercase log levels for performance optimization
|
|
9
|
+
const UPPERCASE_LOG_LEVELS = {
|
|
10
|
+
debug: "DEBUG",
|
|
11
|
+
info: "INFO",
|
|
12
|
+
warn: "WARN",
|
|
13
|
+
error: "ERROR",
|
|
14
|
+
};
|
|
15
|
+
class NeuroLinkLogger {
|
|
16
|
+
logLevel = "info";
|
|
17
|
+
logs = [];
|
|
18
|
+
maxLogs = 1000;
|
|
19
|
+
isDebugMode;
|
|
20
|
+
constructor() {
|
|
21
|
+
// Cache debug mode check to avoid repeated array searches
|
|
22
|
+
this.isDebugMode =
|
|
23
|
+
process.argv.includes("--debug") ||
|
|
24
|
+
process.env.NEUROLINK_DEBUG === "true";
|
|
25
|
+
// Check NEUROLINK_LOG_LEVEL for consistency with the unified NeuroLink logger
|
|
26
|
+
let envLevel = process.env.NEUROLINK_LOG_LEVEL?.toLowerCase();
|
|
27
|
+
// Fallback to MCP_LOG_LEVEL for backward compatibility (if needed)
|
|
28
|
+
if (!envLevel) {
|
|
29
|
+
envLevel = process.env.MCP_LOG_LEVEL?.toLowerCase();
|
|
30
|
+
}
|
|
31
|
+
if (envLevel && ["debug", "info", "warn", "error"].includes(envLevel)) {
|
|
32
|
+
this.logLevel = envLevel;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
setLogLevel(level) {
|
|
36
|
+
this.logLevel = level;
|
|
37
|
+
}
|
|
38
|
+
shouldLog(level) {
|
|
39
|
+
// Hide all logs except errors unless debugging
|
|
40
|
+
if (!this.isDebugMode && level !== "error") {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
const levels = ["debug", "info", "warn", "error"];
|
|
44
|
+
return levels.indexOf(level) >= levels.indexOf(this.logLevel);
|
|
45
|
+
}
|
|
46
|
+
getLogPrefix(timestamp, level) {
|
|
47
|
+
return `[${timestamp}] [NEUROLINK:${UPPERCASE_LOG_LEVELS[level]}]`;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Outputs a log entry to the console based on the log level.
|
|
51
|
+
*
|
|
52
|
+
* @param level - The log level (debug, info, warn, error).
|
|
53
|
+
* @param prefix - The formatted log prefix.
|
|
54
|
+
* @param message - The log message.
|
|
55
|
+
* @param data - Optional additional data to log.
|
|
56
|
+
*/
|
|
57
|
+
outputToConsole(level, prefix, message, data) {
|
|
58
|
+
const logMethod = {
|
|
59
|
+
debug: console.debug,
|
|
60
|
+
info: console.info,
|
|
61
|
+
warn: console.warn,
|
|
62
|
+
error: console.error,
|
|
63
|
+
}[level];
|
|
64
|
+
if (data !== undefined && data !== null) {
|
|
65
|
+
logMethod(prefix, message, data);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
logMethod(prefix, message);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
log(level, message, data) {
|
|
72
|
+
if (!this.shouldLog(level)) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const entry = {
|
|
76
|
+
level,
|
|
77
|
+
message,
|
|
78
|
+
timestamp: new Date(),
|
|
79
|
+
data,
|
|
80
|
+
};
|
|
81
|
+
// Store log entry
|
|
82
|
+
this.logs.push(entry);
|
|
83
|
+
// Trim old logs
|
|
84
|
+
if (this.logs.length > this.maxLogs) {
|
|
85
|
+
this.logs = this.logs.slice(-this.maxLogs);
|
|
86
|
+
}
|
|
87
|
+
// Console output
|
|
88
|
+
const timestamp = entry.timestamp.toISOString();
|
|
89
|
+
const prefix = this.getLogPrefix(timestamp, level);
|
|
90
|
+
this.outputToConsole(level, prefix, message, data);
|
|
91
|
+
}
|
|
92
|
+
debug(message, data) {
|
|
93
|
+
this.log("debug", message, data);
|
|
94
|
+
}
|
|
95
|
+
info(message, data) {
|
|
96
|
+
this.log("info", message, data);
|
|
97
|
+
}
|
|
98
|
+
warn(message, data) {
|
|
99
|
+
this.log("warn", message, data);
|
|
100
|
+
}
|
|
101
|
+
error(message, data) {
|
|
102
|
+
this.log("error", message, data);
|
|
103
|
+
}
|
|
104
|
+
getLogs(level) {
|
|
105
|
+
if (level) {
|
|
106
|
+
return this.logs.filter((log) => log.level === level);
|
|
107
|
+
}
|
|
108
|
+
return [...this.logs];
|
|
109
|
+
}
|
|
110
|
+
clearLogs() {
|
|
111
|
+
this.logs = [];
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Logs messages unconditionally using `console.log`.
|
|
115
|
+
*
|
|
116
|
+
* This method is part of a legacy simple logger interface for backward compatibility.
|
|
117
|
+
* It bypasses the structured logging mechanism and should only be used when
|
|
118
|
+
* unstructured, unconditional logging is required.
|
|
119
|
+
*
|
|
120
|
+
* @param args - The arguments to log. These are passed directly to `console.log`.
|
|
121
|
+
*/
|
|
122
|
+
always(...args) {
|
|
123
|
+
console.log(...args);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
// Export singleton instance
|
|
127
|
+
const neuroLinkLogger = new NeuroLinkLogger();
|
|
128
|
+
// Helper function to process arguments with minimal overhead
|
|
129
|
+
function processLoggerArgs(args, logMethod) {
|
|
130
|
+
if (args.length === 0) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
// Serialize the first argument robustly to handle complex objects
|
|
134
|
+
const message = (() => {
|
|
135
|
+
try {
|
|
136
|
+
return typeof args[0] === "string" ? args[0] : JSON.stringify(args[0]);
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
return "[Unserializable Object]";
|
|
140
|
+
}
|
|
141
|
+
})();
|
|
142
|
+
const data = args.length === 2 ? args[1] : args.length > 2 ? args.slice(1) : undefined;
|
|
143
|
+
logMethod(message, data);
|
|
144
|
+
}
|
|
145
|
+
// Main unified logger export
|
|
6
146
|
export const logger = {
|
|
7
147
|
debug: (...args) => {
|
|
8
|
-
if (
|
|
9
|
-
|
|
148
|
+
if (neuroLinkLogger.shouldLog("debug")) {
|
|
149
|
+
processLoggerArgs(args, (message, data) => neuroLinkLogger.debug(message, data));
|
|
10
150
|
}
|
|
11
151
|
},
|
|
12
152
|
info: (...args) => {
|
|
13
|
-
|
|
153
|
+
if (neuroLinkLogger.shouldLog("info")) {
|
|
154
|
+
processLoggerArgs(args, (message, data) => neuroLinkLogger.info(message, data));
|
|
155
|
+
}
|
|
14
156
|
},
|
|
15
157
|
warn: (...args) => {
|
|
16
|
-
|
|
158
|
+
if (neuroLinkLogger.shouldLog("warn")) {
|
|
159
|
+
processLoggerArgs(args, (message, data) => neuroLinkLogger.warn(message, data));
|
|
160
|
+
}
|
|
17
161
|
},
|
|
18
162
|
error: (...args) => {
|
|
19
|
-
|
|
20
|
-
|
|
163
|
+
if (neuroLinkLogger.shouldLog("error")) {
|
|
164
|
+
processLoggerArgs(args, (message, data) => neuroLinkLogger.error(message, data));
|
|
165
|
+
}
|
|
21
166
|
},
|
|
22
167
|
always: (...args) => {
|
|
23
|
-
|
|
168
|
+
neuroLinkLogger.always(...args);
|
|
24
169
|
},
|
|
170
|
+
// Expose structured logging methods
|
|
171
|
+
setLogLevel: (level) => neuroLinkLogger.setLogLevel(level),
|
|
172
|
+
getLogs: (level) => neuroLinkLogger.getLogs(level),
|
|
173
|
+
clearLogs: () => neuroLinkLogger.clearLogs(),
|
|
174
|
+
};
|
|
175
|
+
// MCP compatibility exports - all use the same unified logger
|
|
176
|
+
export const mcpLogger = neuroLinkLogger;
|
|
177
|
+
export const autoDiscoveryLogger = neuroLinkLogger;
|
|
178
|
+
export const registryLogger = neuroLinkLogger;
|
|
179
|
+
export const unifiedRegistryLogger = neuroLinkLogger;
|
|
180
|
+
// Global log level setter
|
|
181
|
+
export function setGlobalMCPLogLevel(level) {
|
|
182
|
+
neuroLinkLogger.setLogLevel(level);
|
|
183
|
+
}
|
|
184
|
+
// Export LogLevel enum for runtime use
|
|
185
|
+
export const LogLevels = {
|
|
186
|
+
debug: "debug",
|
|
187
|
+
info: "info",
|
|
188
|
+
warn: "warn",
|
|
189
|
+
error: "error",
|
|
25
190
|
};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider Configuration Utility
|
|
3
|
+
* Consolidated configuration helpers for all AI providers
|
|
4
|
+
* Eliminates duplicate error messages and configuration logic
|
|
5
|
+
* Enhanced with format validation and advanced error classification
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Configuration options for provider validation
|
|
9
|
+
*/
|
|
10
|
+
export interface ProviderConfigOptions {
|
|
11
|
+
providerName: string;
|
|
12
|
+
envVarName: string;
|
|
13
|
+
setupUrl: string;
|
|
14
|
+
description: string;
|
|
15
|
+
instructions: string[];
|
|
16
|
+
fallbackEnvVars?: string[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Enhanced validation result with format checking
|
|
20
|
+
*/
|
|
21
|
+
export interface ValidationResult {
|
|
22
|
+
isValid: boolean;
|
|
23
|
+
apiKey: string;
|
|
24
|
+
formatValid?: boolean;
|
|
25
|
+
errorType?: "missing" | "format" | "config";
|
|
26
|
+
error?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Validates API key format for a specific provider
|
|
30
|
+
* @param providerKey Provider identifier (e.g., 'openai', 'anthropic')
|
|
31
|
+
* @param apiKey The API key to validate
|
|
32
|
+
* @returns True if format is valid
|
|
33
|
+
*/
|
|
34
|
+
export declare function validateApiKeyFormat(providerKey: string, apiKey: string): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Enhanced validation with format checking
|
|
37
|
+
* @param config Provider configuration options
|
|
38
|
+
* @param enableFormatValidation Whether to validate API key format
|
|
39
|
+
* @returns Validation result with detailed information
|
|
40
|
+
*/
|
|
41
|
+
export declare function validateApiKeyEnhanced(config: ProviderConfigOptions, enableFormatValidation?: boolean): ValidationResult;
|
|
42
|
+
/**
|
|
43
|
+
* Validates an API key for a provider and returns it (BACKWARD COMPATIBLE)
|
|
44
|
+
* Throws detailed error message if validation fails
|
|
45
|
+
* @param config Provider configuration options
|
|
46
|
+
* @returns The validated API key
|
|
47
|
+
*/
|
|
48
|
+
export declare function validateApiKey(config: ProviderConfigOptions): string;
|
|
49
|
+
/**
|
|
50
|
+
* Gets a provider model with fallback to default
|
|
51
|
+
* @param envVar Environment variable name for the model
|
|
52
|
+
* @param defaultModel Default model to use if env var not set
|
|
53
|
+
* @returns The model name to use
|
|
54
|
+
*/
|
|
55
|
+
export declare function getProviderModel(envVar: string, defaultModel: string): string;
|
|
56
|
+
/**
|
|
57
|
+
* Checks if provider credentials are available
|
|
58
|
+
* @param envVars Array of environment variable names to check
|
|
59
|
+
* @returns True if any of the credentials are available
|
|
60
|
+
*/
|
|
61
|
+
export declare function hasProviderCredentials(envVars: string[]): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Creates Anthropic provider configuration
|
|
64
|
+
*/
|
|
65
|
+
export declare function createAnthropicConfig(): ProviderConfigOptions;
|
|
66
|
+
/**
|
|
67
|
+
* Creates OpenAI provider configuration
|
|
68
|
+
*/
|
|
69
|
+
export declare function createOpenAIConfig(): ProviderConfigOptions;
|
|
70
|
+
/**
|
|
71
|
+
* Creates HuggingFace provider configuration
|
|
72
|
+
*/
|
|
73
|
+
export declare function createHuggingFaceConfig(): ProviderConfigOptions;
|
|
74
|
+
/**
|
|
75
|
+
* Creates Mistral provider configuration
|
|
76
|
+
*/
|
|
77
|
+
export declare function createMistralConfig(): ProviderConfigOptions;
|
|
78
|
+
/**
|
|
79
|
+
* Creates AWS Access Key configuration for Bedrock
|
|
80
|
+
*/
|
|
81
|
+
export declare function createAWSAccessKeyConfig(): ProviderConfigOptions;
|
|
82
|
+
/**
|
|
83
|
+
* Creates AWS Secret Key configuration for Bedrock
|
|
84
|
+
*/
|
|
85
|
+
export declare function createAWSSecretConfig(): ProviderConfigOptions;
|
|
86
|
+
/**
|
|
87
|
+
* Creates Azure OpenAI API Key configuration
|
|
88
|
+
*/
|
|
89
|
+
export declare function createAzureAPIKeyConfig(): ProviderConfigOptions;
|
|
90
|
+
/**
|
|
91
|
+
* Creates Azure OpenAI Endpoint configuration
|
|
92
|
+
*/
|
|
93
|
+
export declare function createAzureEndpointConfig(): ProviderConfigOptions;
|
|
94
|
+
/**
|
|
95
|
+
* Creates Google Vertex Project ID configuration
|
|
96
|
+
*/
|
|
97
|
+
export declare function createVertexProjectConfig(): ProviderConfigOptions;
|
|
98
|
+
/**
|
|
99
|
+
* Creates Google Cloud Authentication configuration
|
|
100
|
+
*/
|
|
101
|
+
export declare function createGoogleAuthConfig(): ProviderConfigOptions;
|
|
102
|
+
/**
|
|
103
|
+
* Creates Anthropic Base Provider configuration
|
|
104
|
+
*/
|
|
105
|
+
export declare function createAnthropicBaseConfig(): ProviderConfigOptions;
|
|
106
|
+
/**
|
|
107
|
+
* Gets AWS Region with default fallback
|
|
108
|
+
*/
|
|
109
|
+
export declare function getAWSRegion(): string;
|
|
110
|
+
/**
|
|
111
|
+
* Gets AWS Session Token if available
|
|
112
|
+
*/
|
|
113
|
+
export declare function getAWSSessionToken(): string | undefined;
|
|
114
|
+
/**
|
|
115
|
+
* Checks if HuggingFace credentials are available
|
|
116
|
+
*/
|
|
117
|
+
export declare function hasHuggingFaceCredentials(): boolean;
|
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider Configuration Utility
|
|
3
|
+
* Consolidated configuration helpers for all AI providers
|
|
4
|
+
* Eliminates duplicate error messages and configuration logic
|
|
5
|
+
* Enhanced with format validation and advanced error classification
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* API key format validation patterns (extracted from advanced validation system)
|
|
9
|
+
*/
|
|
10
|
+
const API_KEY_FORMATS = {
|
|
11
|
+
openai: /^sk-[A-Za-z0-9]{48,}$/,
|
|
12
|
+
anthropic: /^sk-ant-[A-Za-z0-9\-_]{95,}$/,
|
|
13
|
+
"google-ai": /^AIza[A-Za-z0-9\-_]{35}$/,
|
|
14
|
+
huggingface: /^hf_[A-Za-z0-9]{37}$/,
|
|
15
|
+
mistral: /^[A-Za-z0-9]{32}$/,
|
|
16
|
+
azure: /^[A-Za-z0-9]{32,}$/,
|
|
17
|
+
aws: /^[A-Z0-9]{20}$/, // Access Key ID format
|
|
18
|
+
"google-vertex": /^[A-Za-z0-9\-_]{1,}$/, // Project ID format
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Validates API key format for a specific provider
|
|
22
|
+
* @param providerKey Provider identifier (e.g., 'openai', 'anthropic')
|
|
23
|
+
* @param apiKey The API key to validate
|
|
24
|
+
* @returns True if format is valid
|
|
25
|
+
*/
|
|
26
|
+
export function validateApiKeyFormat(providerKey, apiKey) {
|
|
27
|
+
const format = API_KEY_FORMATS[providerKey.toLowerCase()];
|
|
28
|
+
if (!format) {
|
|
29
|
+
// No format validation available, assume valid if not empty
|
|
30
|
+
return apiKey.length > 0;
|
|
31
|
+
}
|
|
32
|
+
return format.test(apiKey);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Enhanced validation with format checking
|
|
36
|
+
* @param config Provider configuration options
|
|
37
|
+
* @param enableFormatValidation Whether to validate API key format
|
|
38
|
+
* @returns Validation result with detailed information
|
|
39
|
+
*/
|
|
40
|
+
export function validateApiKeyEnhanced(config, enableFormatValidation = false) {
|
|
41
|
+
// Check primary environment variable
|
|
42
|
+
let apiKey = process.env[config.envVarName];
|
|
43
|
+
// Check fallback environment variables if provided
|
|
44
|
+
if (!apiKey && config.fallbackEnvVars) {
|
|
45
|
+
for (const fallbackVar of config.fallbackEnvVars) {
|
|
46
|
+
apiKey = process.env[fallbackVar];
|
|
47
|
+
if (apiKey) {
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (!apiKey) {
|
|
53
|
+
return {
|
|
54
|
+
isValid: false,
|
|
55
|
+
apiKey: "",
|
|
56
|
+
errorType: "missing",
|
|
57
|
+
error: createConfigErrorMessage(config),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
// Optional format validation
|
|
61
|
+
if (enableFormatValidation) {
|
|
62
|
+
const providerKey = config.providerName.toLowerCase().replace(/\s/g, "-");
|
|
63
|
+
const formatValid = validateApiKeyFormat(providerKey, apiKey);
|
|
64
|
+
if (!formatValid) {
|
|
65
|
+
return {
|
|
66
|
+
isValid: false,
|
|
67
|
+
apiKey,
|
|
68
|
+
formatValid: false,
|
|
69
|
+
errorType: "format",
|
|
70
|
+
error: `Invalid ${config.providerName} API key format. Please check your API key.`,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
isValid: true,
|
|
76
|
+
apiKey,
|
|
77
|
+
formatValid: enableFormatValidation ? true : undefined,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Validates an API key for a provider and returns it (BACKWARD COMPATIBLE)
|
|
82
|
+
* Throws detailed error message if validation fails
|
|
83
|
+
* @param config Provider configuration options
|
|
84
|
+
* @returns The validated API key
|
|
85
|
+
*/
|
|
86
|
+
export function validateApiKey(config) {
|
|
87
|
+
// Check primary environment variable
|
|
88
|
+
let apiKey = process.env[config.envVarName];
|
|
89
|
+
// Check fallback environment variables if provided
|
|
90
|
+
if (!apiKey && config.fallbackEnvVars) {
|
|
91
|
+
for (const fallbackVar of config.fallbackEnvVars) {
|
|
92
|
+
apiKey = process.env[fallbackVar];
|
|
93
|
+
if (apiKey) {
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (!apiKey) {
|
|
99
|
+
throw new Error(createConfigErrorMessage(config));
|
|
100
|
+
}
|
|
101
|
+
return apiKey;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Creates a standardized configuration error message
|
|
105
|
+
* @param config Provider configuration options
|
|
106
|
+
* @returns Formatted error message with setup instructions
|
|
107
|
+
*/
|
|
108
|
+
function createConfigErrorMessage(config) {
|
|
109
|
+
const envVarsList = config.fallbackEnvVars
|
|
110
|
+
? [config.envVarName, ...config.fallbackEnvVars].join(" or ")
|
|
111
|
+
: config.envVarName;
|
|
112
|
+
return `❌ ${config.providerName} Provider Configuration Error
|
|
113
|
+
|
|
114
|
+
Missing required environment variable: ${envVarsList}
|
|
115
|
+
|
|
116
|
+
🔧 Step 1: Get ${config.description}
|
|
117
|
+
${config.instructions.join("\n")}
|
|
118
|
+
|
|
119
|
+
🔧 Step 2: Set Environment Variable
|
|
120
|
+
Add to your .env file:
|
|
121
|
+
${config.envVarName}=your_key_here
|
|
122
|
+
|
|
123
|
+
🔧 Step 3: Restart Application
|
|
124
|
+
Restart your application to load the new environment variables.`;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Gets a provider model with fallback to default
|
|
128
|
+
* @param envVar Environment variable name for the model
|
|
129
|
+
* @param defaultModel Default model to use if env var not set
|
|
130
|
+
* @returns The model name to use
|
|
131
|
+
*/
|
|
132
|
+
export function getProviderModel(envVar, defaultModel) {
|
|
133
|
+
return process.env[envVar] || defaultModel;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Checks if provider credentials are available
|
|
137
|
+
* @param envVars Array of environment variable names to check
|
|
138
|
+
* @returns True if any of the credentials are available
|
|
139
|
+
*/
|
|
140
|
+
export function hasProviderCredentials(envVars) {
|
|
141
|
+
return envVars.some((envVar) => !!process.env[envVar]);
|
|
142
|
+
}
|
|
143
|
+
// =============================================================================
|
|
144
|
+
// PROVIDER-SPECIFIC CONFIGURATION CREATORS
|
|
145
|
+
// =============================================================================
|
|
146
|
+
/**
|
|
147
|
+
* Creates Anthropic provider configuration
|
|
148
|
+
*/
|
|
149
|
+
export function createAnthropicConfig() {
|
|
150
|
+
return {
|
|
151
|
+
providerName: "Anthropic",
|
|
152
|
+
envVarName: "ANTHROPIC_API_KEY",
|
|
153
|
+
setupUrl: "https://console.anthropic.com/",
|
|
154
|
+
description: "Anthropic API Key",
|
|
155
|
+
instructions: [
|
|
156
|
+
"1. Visit: https://console.anthropic.com/",
|
|
157
|
+
"2. Sign in or create an account",
|
|
158
|
+
"3. Go to API Keys section",
|
|
159
|
+
"4. Create a new API key",
|
|
160
|
+
],
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Creates OpenAI provider configuration
|
|
165
|
+
*/
|
|
166
|
+
export function createOpenAIConfig() {
|
|
167
|
+
return {
|
|
168
|
+
providerName: "OPENAI",
|
|
169
|
+
envVarName: "OPENAI_API_KEY",
|
|
170
|
+
setupUrl: "https://platform.openai.com/api-keys",
|
|
171
|
+
description: "Credentials",
|
|
172
|
+
instructions: [
|
|
173
|
+
"1. Visit: https://platform.openai.com/api-keys",
|
|
174
|
+
"2. Create new API key",
|
|
175
|
+
"3. Copy the key",
|
|
176
|
+
],
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Creates HuggingFace provider configuration
|
|
181
|
+
*/
|
|
182
|
+
export function createHuggingFaceConfig() {
|
|
183
|
+
return {
|
|
184
|
+
providerName: "HuggingFace",
|
|
185
|
+
envVarName: "HUGGINGFACE_API_KEY",
|
|
186
|
+
setupUrl: "https://huggingface.co/settings/tokens",
|
|
187
|
+
description: "Credentials",
|
|
188
|
+
instructions: [
|
|
189
|
+
"1. Visit: https://huggingface.co/settings/tokens",
|
|
190
|
+
"2. Create new API token",
|
|
191
|
+
"3. Copy the token",
|
|
192
|
+
],
|
|
193
|
+
fallbackEnvVars: ["HF_TOKEN"],
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Creates Mistral provider configuration
|
|
198
|
+
*/
|
|
199
|
+
export function createMistralConfig() {
|
|
200
|
+
return {
|
|
201
|
+
providerName: "Mistral",
|
|
202
|
+
envVarName: "MISTRAL_API_KEY",
|
|
203
|
+
setupUrl: "https://console.mistral.ai/",
|
|
204
|
+
description: "API key",
|
|
205
|
+
instructions: [
|
|
206
|
+
"1. Visit: https://console.mistral.ai/",
|
|
207
|
+
"2. Create or sign in to your account",
|
|
208
|
+
"3. Generate a new API key",
|
|
209
|
+
],
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Creates AWS Access Key configuration for Bedrock
|
|
214
|
+
*/
|
|
215
|
+
export function createAWSAccessKeyConfig() {
|
|
216
|
+
return {
|
|
217
|
+
providerName: "AWS Bedrock",
|
|
218
|
+
envVarName: "AWS_ACCESS_KEY_ID",
|
|
219
|
+
setupUrl: "https://console.aws.amazon.com/iam/",
|
|
220
|
+
description: "AWS Credentials",
|
|
221
|
+
instructions: [
|
|
222
|
+
"1. Visit: https://console.aws.amazon.com/iam/",
|
|
223
|
+
"2. Create IAM user with Bedrock permissions",
|
|
224
|
+
"3. Generate access key",
|
|
225
|
+
],
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Creates AWS Secret Key configuration for Bedrock
|
|
230
|
+
*/
|
|
231
|
+
export function createAWSSecretConfig() {
|
|
232
|
+
return {
|
|
233
|
+
providerName: "AWS Bedrock",
|
|
234
|
+
envVarName: "AWS_SECRET_ACCESS_KEY",
|
|
235
|
+
setupUrl: "https://console.aws.amazon.com/iam/",
|
|
236
|
+
description: "AWS Credentials",
|
|
237
|
+
instructions: [
|
|
238
|
+
"1. Visit: https://console.aws.amazon.com/iam/",
|
|
239
|
+
"2. Create IAM user with Bedrock permissions",
|
|
240
|
+
"3. Generate access key",
|
|
241
|
+
],
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Creates Azure OpenAI API Key configuration
|
|
246
|
+
*/
|
|
247
|
+
export function createAzureAPIKeyConfig() {
|
|
248
|
+
return {
|
|
249
|
+
providerName: "Azure OpenAI",
|
|
250
|
+
envVarName: "AZURE_OPENAI_API_KEY",
|
|
251
|
+
setupUrl: "https://portal.azure.com/",
|
|
252
|
+
description: "Azure OpenAI API Key",
|
|
253
|
+
instructions: [
|
|
254
|
+
"1. Visit: https://portal.azure.com/",
|
|
255
|
+
"2. Create or access Azure OpenAI resource",
|
|
256
|
+
"3. Get API key from Keys and Endpoint section",
|
|
257
|
+
],
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Creates Azure OpenAI Endpoint configuration
|
|
262
|
+
*/
|
|
263
|
+
export function createAzureEndpointConfig() {
|
|
264
|
+
return {
|
|
265
|
+
providerName: "Azure OpenAI",
|
|
266
|
+
envVarName: "AZURE_OPENAI_ENDPOINT",
|
|
267
|
+
setupUrl: "https://portal.azure.com/",
|
|
268
|
+
description: "Azure OpenAI Endpoint",
|
|
269
|
+
instructions: [
|
|
270
|
+
"1. Visit: https://portal.azure.com/",
|
|
271
|
+
"2. Access your Azure OpenAI resource",
|
|
272
|
+
"3. Copy endpoint URL from Keys and Endpoint section",
|
|
273
|
+
],
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Creates Google Vertex Project ID configuration
|
|
278
|
+
*/
|
|
279
|
+
export function createVertexProjectConfig() {
|
|
280
|
+
return {
|
|
281
|
+
providerName: "Google Vertex AI",
|
|
282
|
+
envVarName: "GOOGLE_CLOUD_PROJECT_ID",
|
|
283
|
+
setupUrl: "https://console.cloud.google.com/",
|
|
284
|
+
description: "Google Cloud Credentials",
|
|
285
|
+
instructions: [
|
|
286
|
+
"1. Visit: https://console.cloud.google.com/",
|
|
287
|
+
"2. Create or select a project",
|
|
288
|
+
"3. Enable Vertex AI API",
|
|
289
|
+
"4. Set up authentication",
|
|
290
|
+
],
|
|
291
|
+
fallbackEnvVars: ["VERTEX_PROJECT_ID"],
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Creates Google Cloud Authentication configuration
|
|
296
|
+
*/
|
|
297
|
+
export function createGoogleAuthConfig() {
|
|
298
|
+
return {
|
|
299
|
+
providerName: "Google Vertex AI",
|
|
300
|
+
envVarName: "GOOGLE_APPLICATION_CREDENTIALS",
|
|
301
|
+
setupUrl: "https://console.cloud.google.com/",
|
|
302
|
+
description: "Google Cloud authentication",
|
|
303
|
+
instructions: [
|
|
304
|
+
"🔧 Option 1: Service Account Key File",
|
|
305
|
+
"GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json",
|
|
306
|
+
"",
|
|
307
|
+
"🔧 Option 2: Service Account Key (Base64)",
|
|
308
|
+
"GOOGLE_SERVICE_ACCOUNT_KEY=base64_encoded_key",
|
|
309
|
+
"",
|
|
310
|
+
"🔧 Option 3: Individual Credentials",
|
|
311
|
+
"GOOGLE_AUTH_CLIENT_EMAIL=your-service-account@project.iam.gserviceaccount.com",
|
|
312
|
+
"GOOGLE_AUTH_PRIVATE_KEY=-----BEGIN PRIVATE KEY-----...",
|
|
313
|
+
],
|
|
314
|
+
fallbackEnvVars: ["GOOGLE_SERVICE_ACCOUNT_KEY", "GOOGLE_AUTH_CLIENT_EMAIL"],
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Creates Anthropic Base Provider configuration
|
|
319
|
+
*/
|
|
320
|
+
export function createAnthropicBaseConfig() {
|
|
321
|
+
return {
|
|
322
|
+
providerName: "ANTHROPIC",
|
|
323
|
+
envVarName: "ANTHROPIC_API_KEY",
|
|
324
|
+
setupUrl: "https://console.anthropic.com/",
|
|
325
|
+
description: "Credentials",
|
|
326
|
+
instructions: [
|
|
327
|
+
"Get your API key from https://console.anthropic.com/",
|
|
328
|
+
"",
|
|
329
|
+
"💡 Step 2: Add to your .env file (or export in CLI):",
|
|
330
|
+
],
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
// =============================================================================
|
|
334
|
+
// HELPER FUNCTIONS FOR SPECIFIC PROVIDER NEEDS
|
|
335
|
+
// =============================================================================
|
|
336
|
+
/**
|
|
337
|
+
* Gets AWS Region with default fallback
|
|
338
|
+
*/
|
|
339
|
+
export function getAWSRegion() {
|
|
340
|
+
return process.env.AWS_REGION || "us-east-1";
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Gets AWS Session Token if available
|
|
344
|
+
*/
|
|
345
|
+
export function getAWSSessionToken() {
|
|
346
|
+
return process.env.AWS_SESSION_TOKEN;
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Checks if HuggingFace credentials are available
|
|
350
|
+
*/
|
|
351
|
+
export function hasHuggingFaceCredentials() {
|
|
352
|
+
return hasProviderCredentials(["HUGGINGFACE_API_KEY", "HF_TOKEN"]);
|
|
353
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Get the best available provider based on
|
|
2
|
+
* Get the best available provider based on real-time availability checks
|
|
3
|
+
* Enhanced version consolidated from providerUtils-fixed.ts
|
|
3
4
|
* @param requestedProvider - Optional preferred provider name
|
|
4
5
|
* @returns The best provider name to use
|
|
5
6
|
*/
|