@juspay/neurolink 9.14.0 → 9.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +15 -15
- package/dist/adapters/video/videoAnalyzer.d.ts +1 -1
- package/dist/adapters/video/videoAnalyzer.js +10 -8
- package/dist/auth/anthropicOAuth.d.ts +377 -0
- package/dist/auth/anthropicOAuth.js +914 -0
- package/dist/auth/index.d.ts +20 -0
- package/dist/auth/index.js +29 -0
- package/dist/auth/tokenStore.d.ts +225 -0
- package/dist/auth/tokenStore.js +521 -0
- package/dist/cli/commands/auth.d.ts +50 -0
- package/dist/cli/commands/auth.js +1115 -0
- package/dist/cli/commands/setup-anthropic.js +1 -14
- package/dist/cli/commands/setup-azure.js +1 -12
- package/dist/cli/commands/setup-bedrock.js +1 -9
- package/dist/cli/commands/setup-google-ai.js +1 -12
- package/dist/cli/commands/setup-openai.js +1 -14
- package/dist/cli/commands/workflow.d.ts +27 -0
- package/dist/cli/commands/workflow.js +216 -0
- package/dist/cli/factories/authCommandFactory.d.ts +52 -0
- package/dist/cli/factories/authCommandFactory.js +146 -0
- package/dist/cli/factories/commandFactory.d.ts +6 -0
- package/dist/cli/factories/commandFactory.js +171 -22
- package/dist/cli/index.js +0 -1
- package/dist/cli/parser.js +14 -2
- package/dist/cli/utils/maskCredential.d.ts +11 -0
- package/dist/cli/utils/maskCredential.js +23 -0
- package/dist/constants/contextWindows.js +107 -16
- package/dist/constants/enums.d.ts +119 -15
- package/dist/constants/enums.js +182 -22
- package/dist/constants/index.d.ts +3 -1
- package/dist/constants/index.js +11 -1
- package/dist/context/budgetChecker.js +1 -1
- package/dist/context/contextCompactor.js +31 -4
- package/dist/context/emergencyTruncation.d.ts +21 -0
- package/dist/context/emergencyTruncation.js +88 -0
- package/dist/context/errorDetection.d.ts +16 -0
- package/dist/context/errorDetection.js +48 -1
- package/dist/context/errors.d.ts +19 -0
- package/dist/context/errors.js +21 -0
- package/dist/context/stages/slidingWindowTruncator.d.ts +6 -0
- package/dist/context/stages/slidingWindowTruncator.js +159 -24
- package/dist/core/baseProvider.js +306 -200
- package/dist/core/conversationMemoryManager.js +104 -61
- package/dist/core/evaluationProviders.js +16 -33
- package/dist/core/factory.js +237 -164
- package/dist/core/modules/GenerationHandler.js +175 -116
- package/dist/core/modules/MessageBuilder.js +222 -170
- package/dist/core/modules/StreamHandler.d.ts +1 -0
- package/dist/core/modules/StreamHandler.js +95 -27
- package/dist/core/modules/TelemetryHandler.d.ts +10 -1
- package/dist/core/modules/TelemetryHandler.js +25 -7
- package/dist/core/modules/ToolsManager.js +115 -191
- package/dist/core/redisConversationMemoryManager.js +418 -282
- package/dist/factories/providerRegistry.d.ts +5 -0
- package/dist/factories/providerRegistry.js +20 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.js +4 -2
- package/dist/lib/adapters/video/videoAnalyzer.d.ts +1 -1
- package/dist/lib/adapters/video/videoAnalyzer.js +10 -8
- package/dist/lib/auth/anthropicOAuth.d.ts +377 -0
- package/dist/lib/auth/anthropicOAuth.js +915 -0
- package/dist/lib/auth/index.d.ts +20 -0
- package/dist/lib/auth/index.js +30 -0
- package/dist/lib/auth/tokenStore.d.ts +225 -0
- package/dist/lib/auth/tokenStore.js +522 -0
- package/dist/lib/constants/contextWindows.js +107 -16
- package/dist/lib/constants/enums.d.ts +119 -15
- package/dist/lib/constants/enums.js +182 -22
- package/dist/lib/constants/index.d.ts +3 -1
- package/dist/lib/constants/index.js +11 -1
- package/dist/lib/context/budgetChecker.js +1 -1
- package/dist/lib/context/contextCompactor.js +31 -4
- package/dist/lib/context/emergencyTruncation.d.ts +21 -0
- package/dist/lib/context/emergencyTruncation.js +89 -0
- package/dist/lib/context/errorDetection.d.ts +16 -0
- package/dist/lib/context/errorDetection.js +48 -1
- package/dist/lib/context/errors.d.ts +19 -0
- package/dist/lib/context/errors.js +22 -0
- package/dist/lib/context/stages/slidingWindowTruncator.d.ts +6 -0
- package/dist/lib/context/stages/slidingWindowTruncator.js +159 -24
- package/dist/lib/core/baseProvider.js +306 -200
- package/dist/lib/core/conversationMemoryManager.js +104 -61
- package/dist/lib/core/evaluationProviders.js +16 -33
- package/dist/lib/core/factory.js +237 -164
- package/dist/lib/core/modules/GenerationHandler.js +175 -116
- package/dist/lib/core/modules/MessageBuilder.js +222 -170
- package/dist/lib/core/modules/StreamHandler.d.ts +1 -0
- package/dist/lib/core/modules/StreamHandler.js +95 -27
- package/dist/lib/core/modules/TelemetryHandler.d.ts +10 -1
- package/dist/lib/core/modules/TelemetryHandler.js +25 -7
- package/dist/lib/core/modules/ToolsManager.js +115 -191
- package/dist/lib/core/redisConversationMemoryManager.js +418 -282
- package/dist/lib/factories/providerRegistry.d.ts +5 -0
- package/dist/lib/factories/providerRegistry.js +20 -2
- package/dist/lib/index.d.ts +3 -3
- package/dist/lib/index.js +4 -2
- package/dist/lib/mcp/externalServerManager.js +66 -0
- package/dist/lib/mcp/mcpCircuitBreaker.js +24 -0
- package/dist/lib/mcp/mcpClientFactory.js +16 -0
- package/dist/lib/mcp/toolDiscoveryService.js +32 -6
- package/dist/lib/mcp/toolRegistry.js +193 -123
- package/dist/lib/models/anthropicModels.d.ts +267 -0
- package/dist/lib/models/anthropicModels.js +528 -0
- package/dist/lib/neurolink.d.ts +6 -0
- package/dist/lib/neurolink.js +1162 -646
- package/dist/lib/providers/amazonBedrock.d.ts +1 -1
- package/dist/lib/providers/amazonBedrock.js +521 -319
- package/dist/lib/providers/anthropic.d.ts +123 -2
- package/dist/lib/providers/anthropic.js +873 -27
- package/dist/lib/providers/anthropicBaseProvider.js +77 -17
- package/dist/lib/providers/googleAiStudio.d.ts +1 -1
- package/dist/lib/providers/googleAiStudio.js +292 -227
- package/dist/lib/providers/googleVertex.d.ts +36 -1
- package/dist/lib/providers/googleVertex.js +553 -260
- package/dist/lib/providers/ollama.js +329 -278
- package/dist/lib/providers/openAI.js +77 -19
- package/dist/lib/providers/sagemaker/parsers.js +3 -3
- package/dist/lib/providers/sagemaker/streaming.js +3 -3
- package/dist/lib/proxy/proxyFetch.js +81 -48
- package/dist/lib/rag/ChunkerFactory.js +1 -1
- package/dist/lib/rag/chunkers/MarkdownChunker.d.ts +22 -0
- package/dist/lib/rag/chunkers/MarkdownChunker.js +213 -9
- package/dist/lib/rag/chunking/markdownChunker.d.ts +16 -0
- package/dist/lib/rag/chunking/markdownChunker.js +174 -2
- package/dist/lib/rag/pipeline/contextAssembly.js +2 -1
- package/dist/lib/rag/ragIntegration.d.ts +18 -1
- package/dist/lib/rag/ragIntegration.js +94 -14
- package/dist/lib/rag/retrieval/vectorQueryTool.js +21 -4
- package/dist/lib/server/abstract/baseServerAdapter.js +4 -1
- package/dist/lib/server/adapters/fastifyAdapter.js +35 -30
- package/dist/lib/services/server/ai/observability/instrumentation.d.ts +32 -0
- package/dist/lib/services/server/ai/observability/instrumentation.js +39 -0
- package/dist/lib/telemetry/attributes.d.ts +52 -0
- package/dist/lib/telemetry/attributes.js +61 -0
- package/dist/lib/telemetry/index.d.ts +3 -0
- package/dist/lib/telemetry/index.js +3 -0
- package/dist/lib/telemetry/telemetryService.d.ts +6 -0
- package/dist/lib/telemetry/telemetryService.js +6 -0
- package/dist/lib/telemetry/tracers.d.ts +15 -0
- package/dist/lib/telemetry/tracers.js +17 -0
- package/dist/lib/telemetry/withSpan.d.ts +9 -0
- package/dist/lib/telemetry/withSpan.js +35 -0
- package/dist/lib/types/contextTypes.d.ts +10 -0
- package/dist/lib/types/errors.d.ts +62 -0
- package/dist/lib/types/errors.js +107 -0
- package/dist/lib/types/index.d.ts +2 -1
- package/dist/lib/types/index.js +2 -0
- package/dist/lib/types/providers.d.ts +107 -0
- package/dist/lib/types/providers.js +69 -0
- package/dist/lib/types/streamTypes.d.ts +14 -0
- package/dist/lib/types/subscriptionTypes.d.ts +893 -0
- package/dist/lib/types/subscriptionTypes.js +8 -0
- package/dist/lib/utils/conversationMemory.js +121 -82
- package/dist/lib/utils/logger.d.ts +5 -0
- package/dist/lib/utils/logger.js +50 -2
- package/dist/lib/utils/messageBuilder.js +22 -42
- package/dist/lib/utils/modelDetection.js +3 -3
- package/dist/lib/utils/providerConfig.d.ts +167 -0
- package/dist/lib/utils/providerConfig.js +619 -9
- package/dist/lib/utils/providerRetry.d.ts +41 -0
- package/dist/lib/utils/providerRetry.js +114 -0
- package/dist/lib/utils/retryability.d.ts +14 -0
- package/dist/lib/utils/retryability.js +23 -0
- package/dist/lib/utils/sanitizers/svg.js +4 -5
- package/dist/lib/utils/tokenEstimation.d.ts +11 -1
- package/dist/lib/utils/tokenEstimation.js +19 -4
- package/dist/lib/utils/videoAnalysisProcessor.js +7 -3
- package/dist/mcp/externalServerManager.js +66 -0
- package/dist/mcp/mcpCircuitBreaker.js +24 -0
- package/dist/mcp/mcpClientFactory.js +16 -0
- package/dist/mcp/toolDiscoveryService.js +32 -6
- package/dist/mcp/toolRegistry.js +193 -123
- package/dist/models/anthropicModels.d.ts +267 -0
- package/dist/models/anthropicModels.js +527 -0
- package/dist/neurolink.d.ts +6 -0
- package/dist/neurolink.js +1162 -646
- package/dist/providers/amazonBedrock.d.ts +1 -1
- package/dist/providers/amazonBedrock.js +521 -319
- package/dist/providers/anthropic.d.ts +123 -2
- package/dist/providers/anthropic.js +873 -27
- package/dist/providers/anthropicBaseProvider.js +77 -17
- package/dist/providers/googleAiStudio.d.ts +1 -1
- package/dist/providers/googleAiStudio.js +292 -227
- package/dist/providers/googleVertex.d.ts +36 -1
- package/dist/providers/googleVertex.js +553 -260
- package/dist/providers/ollama.js +329 -278
- package/dist/providers/openAI.js +77 -19
- package/dist/providers/sagemaker/parsers.js +3 -3
- package/dist/providers/sagemaker/streaming.js +3 -3
- package/dist/proxy/proxyFetch.js +81 -48
- package/dist/rag/ChunkerFactory.js +1 -1
- package/dist/rag/chunkers/MarkdownChunker.d.ts +22 -0
- package/dist/rag/chunkers/MarkdownChunker.js +213 -9
- package/dist/rag/chunking/markdownChunker.d.ts +16 -0
- package/dist/rag/chunking/markdownChunker.js +174 -2
- package/dist/rag/pipeline/contextAssembly.js +2 -1
- package/dist/rag/ragIntegration.d.ts +18 -1
- package/dist/rag/ragIntegration.js +94 -14
- package/dist/rag/retrieval/vectorQueryTool.js +21 -4
- package/dist/server/abstract/baseServerAdapter.js +4 -1
- package/dist/server/adapters/fastifyAdapter.js +35 -30
- package/dist/services/server/ai/observability/instrumentation.d.ts +32 -0
- package/dist/services/server/ai/observability/instrumentation.js +39 -0
- package/dist/telemetry/attributes.d.ts +52 -0
- package/dist/telemetry/attributes.js +60 -0
- package/dist/telemetry/index.d.ts +3 -0
- package/dist/telemetry/index.js +3 -0
- package/dist/telemetry/telemetryService.d.ts +6 -0
- package/dist/telemetry/telemetryService.js +6 -0
- package/dist/telemetry/tracers.d.ts +15 -0
- package/dist/telemetry/tracers.js +16 -0
- package/dist/telemetry/withSpan.d.ts +9 -0
- package/dist/telemetry/withSpan.js +34 -0
- package/dist/types/contextTypes.d.ts +10 -0
- package/dist/types/errors.d.ts +62 -0
- package/dist/types/errors.js +107 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.js +2 -0
- package/dist/types/providers.d.ts +107 -0
- package/dist/types/providers.js +69 -0
- package/dist/types/streamTypes.d.ts +14 -0
- package/dist/types/subscriptionTypes.d.ts +893 -0
- package/dist/types/subscriptionTypes.js +7 -0
- package/dist/utils/conversationMemory.js +121 -82
- package/dist/utils/logger.d.ts +5 -0
- package/dist/utils/logger.js +50 -2
- package/dist/utils/messageBuilder.js +22 -42
- package/dist/utils/modelDetection.js +3 -3
- package/dist/utils/providerConfig.d.ts +167 -0
- package/dist/utils/providerConfig.js +619 -9
- package/dist/utils/providerRetry.d.ts +41 -0
- package/dist/utils/providerRetry.js +113 -0
- package/dist/utils/retryability.d.ts +14 -0
- package/dist/utils/retryability.js +22 -0
- package/dist/utils/sanitizers/svg.js +4 -5
- package/dist/utils/tokenEstimation.d.ts +11 -1
- package/dist/utils/tokenEstimation.js +19 -4
- package/dist/utils/videoAnalysisProcessor.js +7 -3
- package/dist/workflow/config.d.ts +26 -26
- package/package.json +2 -1
|
@@ -1,15 +1,129 @@
|
|
|
1
1
|
import { type LanguageModelV1 } from "ai";
|
|
2
2
|
import { type AIProviderName } from "../constants/enums.js";
|
|
3
3
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
4
|
+
import type { TextGenerationOptions, EnhancedGenerateResult } from "../types/generateTypes.js";
|
|
4
5
|
import type { StreamOptions, StreamResult } from "../types/streamTypes.js";
|
|
5
6
|
import type { ValidationSchema } from "../types/typeAliases.js";
|
|
7
|
+
import type { ClaudeSubscriptionTier, AnthropicAuthMethod, AnthropicResponseMetadata, ClaudeUsageInfo } from "../types/subscriptionTypes.js";
|
|
8
|
+
import type { AnthropicProviderConfig } from "../types/providers.js";
|
|
9
|
+
/**
|
|
10
|
+
* Beta headers for Claude Code integration.
|
|
11
|
+
* These enable experimental features:
|
|
12
|
+
* - claude-code-20250219: Claude Code specific features
|
|
13
|
+
* - interleaved-thinking-2025-05-14: Interleaved thinking mode
|
|
14
|
+
* - fine-grained-tool-streaming-2025-05-14: Fine-grained tool streaming
|
|
15
|
+
*/
|
|
16
|
+
declare const ANTHROPIC_BETA_HEADERS: {
|
|
17
|
+
"anthropic-beta": string;
|
|
18
|
+
};
|
|
19
|
+
export type { AnthropicProviderConfig } from "../types/providers.js";
|
|
6
20
|
/**
|
|
7
21
|
* Anthropic Provider v2 - BaseProvider Implementation
|
|
8
|
-
*
|
|
22
|
+
* Enhanced with OAuth support, subscription tiers, and beta headers for Claude Code integration.
|
|
9
23
|
*/
|
|
10
24
|
export declare class AnthropicProvider extends BaseProvider {
|
|
11
25
|
private model;
|
|
12
|
-
|
|
26
|
+
private readonly authMethod;
|
|
27
|
+
private readonly subscriptionTier;
|
|
28
|
+
private readonly enableBetaFeatures;
|
|
29
|
+
private oauthToken;
|
|
30
|
+
private lastResponseMetadata;
|
|
31
|
+
private usageInfo;
|
|
32
|
+
private refreshPromise?;
|
|
33
|
+
/**
|
|
34
|
+
* Create a new Anthropic provider instance.
|
|
35
|
+
*
|
|
36
|
+
* @param modelName - Optional model name to use (defaults to CLAUDE_3_5_SONNET)
|
|
37
|
+
* @param sdk - Optional NeuroLink SDK instance
|
|
38
|
+
* @param config - Optional configuration options for auth, subscription tier, and beta features
|
|
39
|
+
*/
|
|
40
|
+
constructor(modelName?: string, sdk?: unknown, config?: AnthropicProviderConfig);
|
|
41
|
+
/**
|
|
42
|
+
* Get authentication headers based on current auth method and configuration.
|
|
43
|
+
*
|
|
44
|
+
* @returns Headers object containing auth and beta feature headers
|
|
45
|
+
*/
|
|
46
|
+
getAuthHeaders(): Record<string, string>;
|
|
47
|
+
/**
|
|
48
|
+
* Validate if a model is accessible with the current subscription tier.
|
|
49
|
+
*
|
|
50
|
+
* @param model - The model ID to validate
|
|
51
|
+
* @returns true if the model is accessible, false otherwise
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```typescript
|
|
55
|
+
* const provider = new AnthropicProvider();
|
|
56
|
+
* if (provider.validateModelAccess("claude-opus-4-5-20251101")) {
|
|
57
|
+
* // Use the model
|
|
58
|
+
* } else {
|
|
59
|
+
* // Fall back to a different model or show upgrade prompt
|
|
60
|
+
* }
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
validateModelAccess(model: string): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Get current usage information.
|
|
66
|
+
*
|
|
67
|
+
* Returns usage tracking data including messages sent, tokens consumed,
|
|
68
|
+
* and remaining quotas. This information is updated after each API request.
|
|
69
|
+
*
|
|
70
|
+
* @returns Current usage info or null if no requests have been made
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```typescript
|
|
74
|
+
* const usage = provider.getUsageInfo();
|
|
75
|
+
* if (usage && usage.tokenQuotaPercent > 80) {
|
|
76
|
+
* console.warn("Approaching token quota limit");
|
|
77
|
+
* }
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
getUsageInfo(): ClaudeUsageInfo | null;
|
|
81
|
+
/**
|
|
82
|
+
* Check if beta features are enabled for this provider instance.
|
|
83
|
+
*
|
|
84
|
+
* @returns true if beta features are enabled
|
|
85
|
+
*/
|
|
86
|
+
areBetaFeaturesEnabled(): boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Get model capabilities for the current model.
|
|
89
|
+
*
|
|
90
|
+
* @returns The model capabilities or undefined if not found
|
|
91
|
+
*/
|
|
92
|
+
getModelCapabilities(): import("../types/subscriptionTypes.js").AnthropicModelMetadata | undefined;
|
|
93
|
+
/**
|
|
94
|
+
* Get the current subscription tier.
|
|
95
|
+
* @returns The detected or configured subscription tier
|
|
96
|
+
*/
|
|
97
|
+
getSubscriptionTier(): ClaudeSubscriptionTier;
|
|
98
|
+
/**
|
|
99
|
+
* Get the authentication method being used.
|
|
100
|
+
* @returns The current authentication method
|
|
101
|
+
*/
|
|
102
|
+
getAuthMethod(): AnthropicAuthMethod;
|
|
103
|
+
/**
|
|
104
|
+
* Refresh OAuth token if needed and possible.
|
|
105
|
+
* This method checks if the token is expired or about to expire,
|
|
106
|
+
* and attempts to refresh it using the refresh token if available.
|
|
107
|
+
*
|
|
108
|
+
* @returns Promise that resolves when refresh is complete (or not needed)
|
|
109
|
+
* @throws Error if refresh is needed but fails
|
|
110
|
+
*/
|
|
111
|
+
refreshAuthIfNeeded(): Promise<void>;
|
|
112
|
+
/**
|
|
113
|
+
* Get the last response metadata including rate limit information.
|
|
114
|
+
* @returns The last response metadata or null if no request has been made
|
|
115
|
+
*/
|
|
116
|
+
getLastResponseMetadata(): AnthropicResponseMetadata | null;
|
|
117
|
+
/**
|
|
118
|
+
* Update response metadata from API response headers.
|
|
119
|
+
* This should be called after each API request to track rate limits.
|
|
120
|
+
* @param headers - Response headers from the API
|
|
121
|
+
* @param requestId - Optional request ID
|
|
122
|
+
*/
|
|
123
|
+
protected updateResponseMetadata(headers: Headers | Record<string, string>, requestId?: string, usageUpdate?: {
|
|
124
|
+
inputTokens?: number;
|
|
125
|
+
outputTokens?: number;
|
|
126
|
+
}): void;
|
|
13
127
|
getProviderName(): AIProviderName;
|
|
14
128
|
getDefaultModel(): string;
|
|
15
129
|
/**
|
|
@@ -17,8 +131,15 @@ export declare class AnthropicProvider extends BaseProvider {
|
|
|
17
131
|
*/
|
|
18
132
|
getAISDKModel(): LanguageModelV1;
|
|
19
133
|
protected formatProviderError(error: unknown): Error;
|
|
134
|
+
/**
|
|
135
|
+
* Override generate to refresh the OAuth token before delegating to
|
|
136
|
+
* BaseProvider so that expired tokens are renewed automatically.
|
|
137
|
+
*/
|
|
138
|
+
generate(optionsOrPrompt: TextGenerationOptions | string, analysisSchema?: ValidationSchema): Promise<EnhancedGenerateResult | null>;
|
|
20
139
|
protected executeStream(options: StreamOptions, _analysisSchema?: ValidationSchema): Promise<StreamResult>;
|
|
21
140
|
isAvailable(): Promise<boolean>;
|
|
22
141
|
getModel(): LanguageModelV1;
|
|
23
142
|
}
|
|
143
|
+
export { ModelAccessError, isModelAvailableForTier, getRecommendedModelForTier, getModelCapabilities, } from "../models/anthropicModels.js";
|
|
144
|
+
export { ANTHROPIC_BETA_HEADERS };
|
|
24
145
|
export default AnthropicProvider;
|