@juspay/neurolink 9.94.6 → 9.95.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.
Files changed (34) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/analytics/index.d.ts +7 -0
  3. package/dist/analytics/index.js +7 -0
  4. package/dist/analytics/parseQualityScore.d.ts +9 -0
  5. package/dist/analytics/parseQualityScore.js +29 -0
  6. package/dist/analytics/pricing.d.ts +24 -0
  7. package/dist/analytics/pricing.js +37 -0
  8. package/dist/analytics/service.d.ts +36 -0
  9. package/dist/analytics/service.js +393 -0
  10. package/dist/analytics/storage.d.ts +19 -0
  11. package/dist/analytics/storage.js +32 -0
  12. package/dist/browser/neurolink.min.js +389 -389
  13. package/dist/cli/factories/commandFactory.d.ts +0 -2
  14. package/dist/cli/factories/commandFactory.js +36 -45
  15. package/dist/cli/loop/session.js +21 -0
  16. package/dist/cli/utils/inputValidation.d.ts +38 -0
  17. package/dist/cli/utils/inputValidation.js +143 -0
  18. package/dist/lib/analytics/index.d.ts +7 -0
  19. package/dist/lib/analytics/index.js +8 -0
  20. package/dist/lib/analytics/parseQualityScore.d.ts +9 -0
  21. package/dist/lib/analytics/parseQualityScore.js +30 -0
  22. package/dist/lib/analytics/pricing.d.ts +24 -0
  23. package/dist/lib/analytics/pricing.js +38 -0
  24. package/dist/lib/analytics/service.d.ts +36 -0
  25. package/dist/lib/analytics/service.js +394 -0
  26. package/dist/lib/analytics/storage.d.ts +19 -0
  27. package/dist/lib/analytics/storage.js +33 -0
  28. package/dist/lib/neurolink.d.ts +54 -0
  29. package/dist/lib/neurolink.js +302 -204
  30. package/dist/lib/types/analytics.d.ts +127 -0
  31. package/dist/neurolink.d.ts +54 -0
  32. package/dist/neurolink.js +302 -204
  33. package/dist/types/analytics.d.ts +127 -0
  34. package/package.json +2 -1
@@ -78,3 +78,130 @@ export type PerformanceMetrics = {
78
78
  external: number;
79
79
  };
80
80
  };
81
+ export type TimeRangeOption = {
82
+ start: Date;
83
+ end: Date;
84
+ };
85
+ /**
86
+ * Quality score subset captured on an analytics telemetry record.
87
+ */
88
+ export type AnalyticsQualityScore = {
89
+ overall: number;
90
+ relevance: number;
91
+ accuracy: number;
92
+ completeness: number;
93
+ reasoning?: string;
94
+ };
95
+ /**
96
+ * Single request lifecycle record for advanced analytics aggregation.
97
+ */
98
+ export type TelemetryRecord = {
99
+ id: string;
100
+ provider: string;
101
+ model: string;
102
+ userId?: string;
103
+ teamId?: string;
104
+ department?: string;
105
+ timestamp: number;
106
+ latency: number;
107
+ inputTokens: number;
108
+ outputTokens: number;
109
+ totalTokens: number;
110
+ cost: number;
111
+ isError: boolean;
112
+ errorMessage?: string;
113
+ qualityScore?: AnalyticsQualityScore;
114
+ };
115
+ /**
116
+ * Pluggable storage backend for analytics telemetry records.
117
+ */
118
+ export type AnalyticsStorage = {
119
+ /** Save a telemetry record */
120
+ saveRecord(record: TelemetryRecord): Promise<void>;
121
+ /** Retrieve all records */
122
+ getRecords(): Promise<TelemetryRecord[]>;
123
+ /** Clear storage */
124
+ clear(): Promise<void>;
125
+ };
126
+ /**
127
+ * Options for the bounded in-memory analytics storage backend.
128
+ */
129
+ export type InMemoryAnalyticsStorageOptions = {
130
+ /** Maximum records to retain. Oldest records are evicted when exceeded. */
131
+ maxRecords?: number;
132
+ };
133
+ export type ProviderMetricsOptions = {
134
+ providers?: string[];
135
+ timeRange?: TimeRangeOption | string;
136
+ metrics?: string[];
137
+ };
138
+ export type ProviderMetricItem = {
139
+ name: string;
140
+ averageLatency: number;
141
+ averageResponseTime: number;
142
+ totalTokens: number;
143
+ inputTokens: number;
144
+ outputTokens: number;
145
+ errorRate: number;
146
+ successRate: number;
147
+ costPerToken: number;
148
+ totalCost: number;
149
+ requestCount: number;
150
+ };
151
+ export type ProviderMetricsResult = {
152
+ averageLatency: number;
153
+ averageResponseTime: number;
154
+ totalTokens: number;
155
+ inputTokens: number;
156
+ outputTokens: number;
157
+ errorRate: number;
158
+ successRate: number;
159
+ costPerToken: number;
160
+ totalCost: number;
161
+ requestCount: number;
162
+ providers: ProviderMetricItem[];
163
+ };
164
+ export type CostAnalysisOptions = {
165
+ timeRange?: TimeRangeOption | string;
166
+ groupBy?: string | string[];
167
+ includeProjections?: boolean;
168
+ };
169
+ export type CostGroupItem = {
170
+ groupKey: string;
171
+ provider?: string;
172
+ model?: string;
173
+ userId?: string;
174
+ totalCost: number;
175
+ costPerToken: number;
176
+ inputTokens: number;
177
+ outputTokens: number;
178
+ totalTokens: number;
179
+ requestCount: number;
180
+ };
181
+ export type CostAnalysisResult = {
182
+ totalCost: number;
183
+ totalTokens: number;
184
+ inputTokens: number;
185
+ outputTokens: number;
186
+ requestCount: number;
187
+ groups: Record<string, CostGroupItem>;
188
+ providers: CostGroupItem[];
189
+ projections?: {
190
+ nextMonth: number;
191
+ nextQuarter: number;
192
+ };
193
+ };
194
+ export type TeamAnalyticsOptions = {
195
+ teamId?: string;
196
+ departments?: string[];
197
+ metrics?: string[];
198
+ timeRange?: TimeRangeOption | string;
199
+ };
200
+ export type TeamAnalyticsResult = {
201
+ totalRequests: number;
202
+ uniqueUsers: number;
203
+ providersUsed: string[];
204
+ costBreakdownByProvider: Record<string, number>;
205
+ costBreakdownByUser: Record<string, number>;
206
+ qualityScores?: AnalyticsQualityScore;
207
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juspay/neurolink",
3
- "version": "9.94.6",
3
+ "version": "9.95.0",
4
4
  "packageManager": "pnpm@10.15.1",
5
5
  "description": "TypeScript AI SDK with 24+ LLM providers behind one consistent API. MCP-native (connect any MCP server), voice TTS/STT/realtime, RAG, agents, memory, context compaction. OpenAI · Anthropic · Gemini · Bedrock · Azure · Ollama · DeepSeek · NVIDIA NIM and more.",
6
6
  "author": {
@@ -123,6 +123,7 @@
123
123
  "test:json-e2e": "npx tsx test/continuous-test-suite-json-e2e.ts",
124
124
  "test:workflow": "npx tsx test/continuous-test-suite-workflow.ts",
125
125
  "test:hitl": "npx tsx test/continuous-test-suite-hitl.ts",
126
+ "test:analytics": "npx tsx test/continuous-test-suite-analytics.ts",
126
127
  "test:tasks": "npx tsx test/continuous-test-suite-tasks.ts",
127
128
  "test:auth": "npx tsx test/continuous-test-suite-auth.ts",
128
129
  "test:autoresearch": "npx tsx test/continuous-test-suite-autoresearch.ts",