@juspay/neurolink 9.24.0 → 9.25.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/adapters/tts/googleTTSHandler.js +26 -1
- package/dist/adapters/video/vertexVideoHandler.js +23 -17
- package/dist/cli/commands/config.d.ts +3 -3
- package/dist/cli/commands/observability.d.ts +53 -0
- package/dist/cli/commands/observability.js +453 -0
- package/dist/cli/commands/telemetry.d.ts +63 -0
- package/dist/cli/commands/telemetry.js +689 -0
- package/dist/cli/factories/commandFactory.js +29 -15
- package/dist/cli/parser.js +6 -9
- package/dist/cli/utils/formatters.d.ts +13 -0
- package/dist/cli/utils/formatters.js +23 -0
- package/dist/constants/contextWindows.js +6 -0
- package/dist/constants/enums.d.ts +6 -0
- package/dist/constants/enums.js +8 -2
- package/dist/context/budgetChecker.js +75 -48
- package/dist/context/contextCompactor.js +135 -127
- package/dist/core/baseProvider.d.ts +5 -0
- package/dist/core/baseProvider.js +117 -110
- package/dist/core/conversationMemoryInitializer.js +7 -4
- package/dist/core/conversationMemoryManager.d.ts +2 -0
- package/dist/core/conversationMemoryManager.js +6 -2
- package/dist/core/modules/GenerationHandler.d.ts +2 -2
- package/dist/core/modules/GenerationHandler.js +12 -12
- package/dist/evaluation/ragasEvaluator.js +39 -19
- package/dist/evaluation/scoring.js +46 -20
- package/dist/features/ppt/presentationOrchestrator.js +23 -0
- package/dist/features/ppt/slideGenerator.js +13 -0
- package/dist/features/ppt/slideRenderers.d.ts +1 -1
- package/dist/features/ppt/slideRenderers.js +6 -4
- package/dist/features/ppt/slideTypeInference.d.ts +1 -1
- package/dist/features/ppt/slideTypeInference.js +75 -73
- package/dist/files/fileTools.d.ts +6 -6
- package/dist/index.d.ts +46 -12
- package/dist/index.js +79 -17
- package/dist/lib/adapters/tts/googleTTSHandler.js +26 -1
- package/dist/lib/adapters/video/vertexVideoHandler.js +23 -17
- package/dist/lib/constants/contextWindows.js +6 -0
- package/dist/lib/constants/enums.d.ts +6 -0
- package/dist/lib/constants/enums.js +8 -2
- package/dist/lib/context/budgetChecker.js +75 -48
- package/dist/lib/context/contextCompactor.js +135 -127
- package/dist/lib/core/baseProvider.d.ts +5 -0
- package/dist/lib/core/baseProvider.js +117 -110
- package/dist/lib/core/conversationMemoryInitializer.js +7 -4
- package/dist/lib/core/conversationMemoryManager.d.ts +2 -0
- package/dist/lib/core/conversationMemoryManager.js +6 -2
- package/dist/lib/core/modules/GenerationHandler.d.ts +2 -2
- package/dist/lib/core/modules/GenerationHandler.js +12 -12
- package/dist/lib/evaluation/ragasEvaluator.js +39 -19
- package/dist/lib/evaluation/scoring.js +46 -20
- package/dist/lib/features/ppt/presentationOrchestrator.js +23 -0
- package/dist/lib/features/ppt/slideGenerator.js +13 -0
- package/dist/lib/features/ppt/slideRenderers.d.ts +1 -1
- package/dist/lib/features/ppt/slideRenderers.js +6 -4
- package/dist/lib/features/ppt/slideTypeInference.d.ts +1 -1
- package/dist/lib/features/ppt/slideTypeInference.js +75 -73
- package/dist/lib/files/fileTools.d.ts +6 -6
- package/dist/lib/index.d.ts +46 -12
- package/dist/lib/index.js +79 -17
- package/dist/lib/mcp/httpRateLimiter.js +39 -12
- package/dist/lib/mcp/httpRetryHandler.js +22 -1
- package/dist/lib/mcp/mcpClientFactory.js +13 -15
- package/dist/lib/memory/memoryRetrievalTools.js +22 -0
- package/dist/lib/neurolink.d.ts +64 -72
- package/dist/lib/neurolink.js +1007 -564
- package/dist/lib/observability/exporterRegistry.d.ts +152 -0
- package/dist/lib/observability/exporterRegistry.js +414 -0
- package/dist/lib/observability/exporters/arizeExporter.d.ts +32 -0
- package/dist/lib/observability/exporters/arizeExporter.js +139 -0
- package/dist/lib/observability/exporters/baseExporter.d.ts +117 -0
- package/dist/lib/observability/exporters/baseExporter.js +191 -0
- package/dist/lib/observability/exporters/braintrustExporter.d.ts +30 -0
- package/dist/lib/observability/exporters/braintrustExporter.js +155 -0
- package/dist/lib/observability/exporters/datadogExporter.d.ts +37 -0
- package/dist/lib/observability/exporters/datadogExporter.js +197 -0
- package/dist/lib/observability/exporters/index.d.ts +13 -0
- package/dist/lib/observability/exporters/index.js +14 -0
- package/dist/lib/observability/exporters/laminarExporter.d.ts +48 -0
- package/dist/lib/observability/exporters/laminarExporter.js +303 -0
- package/dist/lib/observability/exporters/langfuseExporter.d.ts +47 -0
- package/dist/lib/observability/exporters/langfuseExporter.js +204 -0
- package/dist/lib/observability/exporters/langsmithExporter.d.ts +26 -0
- package/dist/lib/observability/exporters/langsmithExporter.js +124 -0
- package/dist/lib/observability/exporters/otelExporter.d.ts +39 -0
- package/dist/lib/observability/exporters/otelExporter.js +165 -0
- package/dist/lib/observability/exporters/posthogExporter.d.ts +48 -0
- package/dist/lib/observability/exporters/posthogExporter.js +288 -0
- package/dist/lib/observability/exporters/sentryExporter.d.ts +32 -0
- package/dist/lib/observability/exporters/sentryExporter.js +166 -0
- package/dist/lib/observability/index.d.ts +25 -0
- package/dist/lib/observability/index.js +32 -0
- package/dist/lib/observability/metricsAggregator.d.ts +260 -0
- package/dist/lib/observability/metricsAggregator.js +557 -0
- package/dist/lib/observability/otelBridge.d.ts +49 -0
- package/dist/lib/observability/otelBridge.js +132 -0
- package/dist/lib/observability/retryPolicy.d.ts +192 -0
- package/dist/lib/observability/retryPolicy.js +384 -0
- package/dist/lib/observability/sampling/index.d.ts +4 -0
- package/dist/lib/observability/sampling/index.js +5 -0
- package/dist/lib/observability/sampling/samplers.d.ts +116 -0
- package/dist/lib/observability/sampling/samplers.js +217 -0
- package/dist/lib/observability/spanProcessor.d.ts +129 -0
- package/dist/lib/observability/spanProcessor.js +304 -0
- package/dist/lib/observability/tokenTracker.d.ts +156 -0
- package/dist/lib/observability/tokenTracker.js +414 -0
- package/dist/lib/observability/types/exporterTypes.d.ts +250 -0
- package/dist/lib/observability/types/exporterTypes.js +6 -0
- package/dist/lib/observability/types/index.d.ts +6 -0
- package/dist/lib/observability/types/index.js +5 -0
- package/dist/lib/observability/types/spanTypes.d.ts +244 -0
- package/dist/lib/observability/types/spanTypes.js +93 -0
- package/dist/lib/observability/utils/index.d.ts +4 -0
- package/dist/lib/observability/utils/index.js +5 -0
- package/dist/lib/observability/utils/safeMetadata.d.ts +10 -0
- package/dist/lib/observability/utils/safeMetadata.js +26 -0
- package/dist/lib/observability/utils/spanSerializer.d.ts +115 -0
- package/dist/lib/observability/utils/spanSerializer.js +291 -0
- package/dist/lib/providers/amazonSagemaker.d.ts +5 -4
- package/dist/lib/providers/amazonSagemaker.js +3 -4
- package/dist/lib/providers/googleVertex.d.ts +7 -0
- package/dist/lib/providers/googleVertex.js +76 -2
- package/dist/lib/rag/pipeline/RAGPipeline.d.ts +0 -5
- package/dist/lib/rag/pipeline/RAGPipeline.js +122 -87
- package/dist/lib/rag/ragIntegration.js +30 -0
- package/dist/lib/rag/retrieval/hybridSearch.js +22 -0
- package/dist/lib/server/abstract/baseServerAdapter.js +51 -19
- package/dist/lib/server/middleware/common.js +44 -12
- package/dist/lib/services/server/ai/observability/instrumentation.d.ts +2 -2
- package/dist/lib/services/server/ai/observability/instrumentation.js +10 -5
- package/dist/lib/types/conversationMemoryInterface.d.ts +2 -0
- package/dist/lib/types/modelTypes.d.ts +18 -18
- package/dist/lib/types/providers.d.ts +5 -0
- package/dist/lib/utils/pricing.js +25 -1
- package/dist/lib/utils/ttsProcessor.js +74 -59
- package/dist/lib/workflow/config.d.ts +36 -36
- package/dist/lib/workflow/core/ensembleExecutor.js +10 -0
- package/dist/lib/workflow/core/judgeScorer.js +20 -2
- package/dist/lib/workflow/core/workflowRunner.js +34 -1
- package/dist/mcp/httpRateLimiter.js +39 -12
- package/dist/mcp/httpRetryHandler.js +22 -1
- package/dist/mcp/mcpClientFactory.js +13 -15
- package/dist/memory/memoryRetrievalTools.js +22 -0
- package/dist/neurolink.d.ts +64 -72
- package/dist/neurolink.js +1007 -564
- package/dist/observability/FEATURE-STATUS.md +269 -0
- package/dist/observability/exporterRegistry.d.ts +152 -0
- package/dist/observability/exporterRegistry.js +413 -0
- package/dist/observability/exporters/arizeExporter.d.ts +32 -0
- package/dist/observability/exporters/arizeExporter.js +138 -0
- package/dist/observability/exporters/baseExporter.d.ts +117 -0
- package/dist/observability/exporters/baseExporter.js +190 -0
- package/dist/observability/exporters/braintrustExporter.d.ts +30 -0
- package/dist/observability/exporters/braintrustExporter.js +154 -0
- package/dist/observability/exporters/datadogExporter.d.ts +37 -0
- package/dist/observability/exporters/datadogExporter.js +196 -0
- package/dist/observability/exporters/index.d.ts +13 -0
- package/dist/observability/exporters/index.js +13 -0
- package/dist/observability/exporters/laminarExporter.d.ts +48 -0
- package/dist/observability/exporters/laminarExporter.js +302 -0
- package/dist/observability/exporters/langfuseExporter.d.ts +47 -0
- package/dist/observability/exporters/langfuseExporter.js +203 -0
- package/dist/observability/exporters/langsmithExporter.d.ts +26 -0
- package/dist/observability/exporters/langsmithExporter.js +123 -0
- package/dist/observability/exporters/otelExporter.d.ts +39 -0
- package/dist/observability/exporters/otelExporter.js +164 -0
- package/dist/observability/exporters/posthogExporter.d.ts +48 -0
- package/dist/observability/exporters/posthogExporter.js +287 -0
- package/dist/observability/exporters/sentryExporter.d.ts +32 -0
- package/dist/observability/exporters/sentryExporter.js +165 -0
- package/dist/observability/index.d.ts +25 -0
- package/dist/observability/index.js +31 -0
- package/dist/observability/metricsAggregator.d.ts +260 -0
- package/dist/observability/metricsAggregator.js +556 -0
- package/dist/observability/otelBridge.d.ts +49 -0
- package/dist/observability/otelBridge.js +131 -0
- package/dist/observability/retryPolicy.d.ts +192 -0
- package/dist/observability/retryPolicy.js +383 -0
- package/dist/observability/sampling/index.d.ts +4 -0
- package/dist/observability/sampling/index.js +4 -0
- package/dist/observability/sampling/samplers.d.ts +116 -0
- package/dist/observability/sampling/samplers.js +216 -0
- package/dist/observability/spanProcessor.d.ts +129 -0
- package/dist/observability/spanProcessor.js +303 -0
- package/dist/observability/tokenTracker.d.ts +156 -0
- package/dist/observability/tokenTracker.js +413 -0
- package/dist/observability/types/exporterTypes.d.ts +250 -0
- package/dist/observability/types/exporterTypes.js +5 -0
- package/dist/observability/types/index.d.ts +6 -0
- package/dist/observability/types/index.js +4 -0
- package/dist/observability/types/spanTypes.d.ts +244 -0
- package/dist/observability/types/spanTypes.js +92 -0
- package/dist/observability/utils/index.d.ts +4 -0
- package/dist/observability/utils/index.js +4 -0
- package/dist/observability/utils/safeMetadata.d.ts +10 -0
- package/dist/observability/utils/safeMetadata.js +25 -0
- package/dist/observability/utils/spanSerializer.d.ts +115 -0
- package/dist/observability/utils/spanSerializer.js +290 -0
- package/dist/providers/amazonSagemaker.d.ts +5 -4
- package/dist/providers/amazonSagemaker.js +3 -4
- package/dist/providers/googleVertex.d.ts +7 -0
- package/dist/providers/googleVertex.js +76 -2
- package/dist/rag/pipeline/RAGPipeline.d.ts +0 -5
- package/dist/rag/pipeline/RAGPipeline.js +122 -87
- package/dist/rag/ragIntegration.js +30 -0
- package/dist/rag/retrieval/hybridSearch.js +22 -0
- package/dist/server/abstract/baseServerAdapter.js +51 -19
- package/dist/server/middleware/common.js +44 -12
- package/dist/services/server/ai/observability/instrumentation.d.ts +2 -2
- package/dist/services/server/ai/observability/instrumentation.js +10 -5
- package/dist/types/conversationMemoryInterface.d.ts +2 -0
- package/dist/types/providers.d.ts +5 -0
- package/dist/utils/pricing.js +25 -1
- package/dist/utils/ttsProcessor.js +74 -59
- package/dist/workflow/config.d.ts +52 -52
- package/dist/workflow/core/ensembleExecutor.js +10 -0
- package/dist/workflow/core/judgeScorer.js +20 -2
- package/dist/workflow/core/workflowRunner.js +34 -1
- package/package.json +1 -1
package/dist/lib/neurolink.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ import { ConversationMemoryManager } from "./core/conversationMemoryManager.js";
|
|
|
10
10
|
import type { RedisConversationMemoryManager } from "./core/redisConversationMemoryManager.js";
|
|
11
11
|
import { ExternalServerManager } from "./mcp/externalServerManager.js";
|
|
12
12
|
import { MCPToolRegistry } from "./mcp/toolRegistry.js";
|
|
13
|
+
import type { MetricsSummary, TraceView } from "./observability/metricsAggregator.js";
|
|
14
|
+
import type { SpanData } from "./observability/types/spanTypes.js";
|
|
13
15
|
import type { JsonObject, NeuroLinkEvents, TypedEventEmitter } from "./types/common.js";
|
|
14
16
|
import type { NeurolinkConstructorConfig } from "./types/configTypes.js";
|
|
15
17
|
import type { ChatMessage } from "./types/conversation.js";
|
|
@@ -21,78 +23,6 @@ import type { ObservabilityConfig } from "./types/observability.js";
|
|
|
21
23
|
import type { StreamOptions, StreamResult } from "./types/streamTypes.js";
|
|
22
24
|
import type { ToolExecutionContext, ToolExecutionSummary, ToolInfo } from "./types/tools.js";
|
|
23
25
|
import type { BatchOperationResult } from "./types/typeAliases.js";
|
|
24
|
-
/**
|
|
25
|
-
* NeuroLink - Universal AI Development Platform
|
|
26
|
-
*
|
|
27
|
-
* Main SDK class providing unified access to 14+ AI providers with enterprise features:
|
|
28
|
-
* - Multi-provider support (OpenAI, Anthropic, Google AI Studio, Google Vertex, AWS Bedrock, etc.)
|
|
29
|
-
* - MCP (Model Context Protocol) tool integration with 58+ external servers
|
|
30
|
-
* - Human-in-the-Loop (HITL) security workflows for regulated industries
|
|
31
|
-
* - Redis-based conversation memory and persistence
|
|
32
|
-
* - Enterprise middleware system for monitoring and control
|
|
33
|
-
* - Automatic provider fallback and retry logic
|
|
34
|
-
* - Streaming with real-time token delivery
|
|
35
|
-
* - Multimodal support (text, images, PDFs, CSV)
|
|
36
|
-
*
|
|
37
|
-
* @category Core
|
|
38
|
-
*
|
|
39
|
-
* @example Basic usage
|
|
40
|
-
* ```typescript
|
|
41
|
-
* import { NeuroLink } from '@juspay/neurolink';
|
|
42
|
-
*
|
|
43
|
-
* const neurolink = new NeuroLink();
|
|
44
|
-
*
|
|
45
|
-
* const result = await neurolink.generate({
|
|
46
|
-
* input: { text: 'Explain quantum computing' },
|
|
47
|
-
* provider: 'vertex',
|
|
48
|
-
* model: 'gemini-3-flash'
|
|
49
|
-
* });
|
|
50
|
-
*
|
|
51
|
-
* console.log(result.content);
|
|
52
|
-
* ```
|
|
53
|
-
*
|
|
54
|
-
* @example With HITL security
|
|
55
|
-
* ```typescript
|
|
56
|
-
* const neurolink = new NeuroLink({
|
|
57
|
-
* hitl: {
|
|
58
|
-
* enabled: true,
|
|
59
|
-
* requireApproval: ['writeFile', 'executeCode'],
|
|
60
|
-
* confidenceThreshold: 0.85
|
|
61
|
-
* }
|
|
62
|
-
* });
|
|
63
|
-
* ```
|
|
64
|
-
*
|
|
65
|
-
* @example With Redis memory
|
|
66
|
-
* ```typescript
|
|
67
|
-
* const neurolink = new NeuroLink({
|
|
68
|
-
* conversationMemory: {
|
|
69
|
-
* enabled: true,
|
|
70
|
-
* redis: {
|
|
71
|
-
* url: 'redis://localhost:6379'
|
|
72
|
-
* }
|
|
73
|
-
* }
|
|
74
|
-
* });
|
|
75
|
-
* ```
|
|
76
|
-
*
|
|
77
|
-
* @example With MCP tools
|
|
78
|
-
* ```typescript
|
|
79
|
-
* const neurolink = new NeuroLink();
|
|
80
|
-
*
|
|
81
|
-
* // Discover available tools
|
|
82
|
-
* const tools = await neurolink.getAvailableTools();
|
|
83
|
-
*
|
|
84
|
-
* // Use tools in generation
|
|
85
|
-
* const result = await neurolink.generate({
|
|
86
|
-
* input: { text: 'Read the README.md file' },
|
|
87
|
-
* tools: ['readFile']
|
|
88
|
-
* });
|
|
89
|
-
* ```
|
|
90
|
-
*
|
|
91
|
-
* @see {@link GenerateOptions} for generation options
|
|
92
|
-
* @see {@link StreamOptions} for streaming options
|
|
93
|
-
* @see {@link NeurolinkConstructorConfig} for configuration options
|
|
94
|
-
* @since 1.0.0
|
|
95
|
-
*/
|
|
96
26
|
export declare class NeuroLink {
|
|
97
27
|
private mcpInitialized;
|
|
98
28
|
private mcpInitPromise;
|
|
@@ -203,6 +133,13 @@ export declare class NeuroLink {
|
|
|
203
133
|
* @throws {Error} When HITL configuration is invalid (if enabled)
|
|
204
134
|
*/
|
|
205
135
|
private observabilityConfig?;
|
|
136
|
+
private metricsAggregator;
|
|
137
|
+
/**
|
|
138
|
+
* Per-request metrics trace context backed by AsyncLocalStorage.
|
|
139
|
+
* Safe for concurrent requests on the same SDK instance.
|
|
140
|
+
* Context is set via metricsTraceContextStorage.run() in generate/stream.
|
|
141
|
+
*/
|
|
142
|
+
private get _metricsTraceContext();
|
|
206
143
|
constructor(config?: NeurolinkConstructorConfig);
|
|
207
144
|
/**
|
|
208
145
|
* Initialize provider registry with security settings
|
|
@@ -385,6 +322,56 @@ export declare class NeuroLink {
|
|
|
385
322
|
* Centralized utility to avoid duplication across providers
|
|
386
323
|
*/
|
|
387
324
|
isTelemetryEnabled(): boolean;
|
|
325
|
+
/**
|
|
326
|
+
* Get comprehensive telemetry status including Langfuse, OTel, and exporter health
|
|
327
|
+
*/
|
|
328
|
+
getTelemetryStatus(): {
|
|
329
|
+
enabled: boolean;
|
|
330
|
+
langfuse?: {
|
|
331
|
+
enabled: boolean;
|
|
332
|
+
baseUrl?: string;
|
|
333
|
+
environment?: string;
|
|
334
|
+
};
|
|
335
|
+
openTelemetry?: {
|
|
336
|
+
enabled: boolean;
|
|
337
|
+
endpoint?: string;
|
|
338
|
+
serviceName?: string;
|
|
339
|
+
};
|
|
340
|
+
exporters?: Array<{
|
|
341
|
+
name: string;
|
|
342
|
+
enabled: boolean;
|
|
343
|
+
healthy: boolean;
|
|
344
|
+
pendingSpans: number;
|
|
345
|
+
lastExportTime?: string;
|
|
346
|
+
latencyMs?: number;
|
|
347
|
+
errors?: string[];
|
|
348
|
+
}>;
|
|
349
|
+
};
|
|
350
|
+
/**
|
|
351
|
+
* Get aggregated observability metrics (latency, tokens, cost, success rate)
|
|
352
|
+
*/
|
|
353
|
+
getMetrics(): MetricsSummary;
|
|
354
|
+
/**
|
|
355
|
+
* Get all recorded spans
|
|
356
|
+
*/
|
|
357
|
+
getSpans(): SpanData[];
|
|
358
|
+
/**
|
|
359
|
+
* Get traces (spans grouped by traceId with parent-child hierarchy)
|
|
360
|
+
*/
|
|
361
|
+
getTraces(): TraceView[];
|
|
362
|
+
/**
|
|
363
|
+
* Reset all collected metrics and spans
|
|
364
|
+
*/
|
|
365
|
+
resetMetrics(): void;
|
|
366
|
+
/**
|
|
367
|
+
* Record a span for metrics tracking
|
|
368
|
+
*/
|
|
369
|
+
recordMetricsSpan(span: SpanData): void;
|
|
370
|
+
/**
|
|
371
|
+
* Record a memory operation span to both instance and global metrics aggregators.
|
|
372
|
+
* This ensures memory spans are visible via sdk.getSpans() and getMetricsAggregator().getSpans().
|
|
373
|
+
*/
|
|
374
|
+
private recordMemorySpan;
|
|
388
375
|
/**
|
|
389
376
|
* Public method to initialize Langfuse observability
|
|
390
377
|
* This method can be called externally to ensure Langfuse is properly initialized
|
|
@@ -394,6 +381,11 @@ export declare class NeuroLink {
|
|
|
394
381
|
* Gracefully shutdown NeuroLink and all MCP connections
|
|
395
382
|
*/
|
|
396
383
|
shutdown(): Promise<void>;
|
|
384
|
+
/**
|
|
385
|
+
* Initialize event listeners that feed span data to MetricsAggregator.
|
|
386
|
+
* Listens to generation:end, stream:complete, and tool:end events.
|
|
387
|
+
*/
|
|
388
|
+
private initializeMetricsListeners;
|
|
397
389
|
/**
|
|
398
390
|
* Generate AI response with comprehensive feature support.
|
|
399
391
|
*
|