@juspay/neurolink 9.94.7 → 9.95.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.
Files changed (38) 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.js +88 -13
  14. package/dist/cli/utils/inputValidation.d.ts +22 -9
  15. package/dist/cli/utils/inputValidation.js +147 -61
  16. package/dist/lib/analytics/index.d.ts +7 -0
  17. package/dist/lib/analytics/index.js +8 -0
  18. package/dist/lib/analytics/parseQualityScore.d.ts +9 -0
  19. package/dist/lib/analytics/parseQualityScore.js +30 -0
  20. package/dist/lib/analytics/pricing.d.ts +24 -0
  21. package/dist/lib/analytics/pricing.js +38 -0
  22. package/dist/lib/analytics/service.d.ts +36 -0
  23. package/dist/lib/analytics/service.js +394 -0
  24. package/dist/lib/analytics/storage.d.ts +19 -0
  25. package/dist/lib/analytics/storage.js +33 -0
  26. package/dist/lib/neurolink.d.ts +54 -0
  27. package/dist/lib/neurolink.js +302 -204
  28. package/dist/lib/types/analytics.d.ts +127 -0
  29. package/dist/lib/types/cli.d.ts +7 -2
  30. package/dist/lib/utils/logger.d.ts +12 -0
  31. package/dist/lib/utils/logger.js +16 -0
  32. package/dist/neurolink.d.ts +54 -0
  33. package/dist/neurolink.js +302 -204
  34. package/dist/types/analytics.d.ts +127 -0
  35. package/dist/types/cli.d.ts +7 -2
  36. package/dist/utils/logger.d.ts +12 -0
  37. package/dist/utils/logger.js +16 -0
  38. 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
+ };
@@ -138,8 +138,8 @@ export type StreamCommandArgs = BaseCommandArgs & CliToolRoutingFlags & CliClass
138
138
  * Batch command arguments
139
139
  */
140
140
  export type BatchCommandArgs = BaseCommandArgs & CliToolRoutingFlags & CliClassifierRouterFlags & {
141
- /** Input file path */
142
- file?: string;
141
+ /** Prompts-list file path (the `<promptsFile>` positional) */
142
+ promptsFile?: string;
143
143
  /** AI provider to use */
144
144
  provider?: string;
145
145
  /** Model name */
@@ -1684,3 +1684,8 @@ export type CliAudioPlayerCommand = {
1684
1684
  command: string;
1685
1685
  args: string[];
1686
1686
  };
1687
+ /**
1688
+ * The CLI flags validated by `validateCliInputFiles` before a
1689
+ * generate/stream/batch run starts (--image/--csv/--pdf/--video/--file).
1690
+ */
1691
+ export type CliValidatedFileOption = "--image" | "--csv" | "--pdf" | "--video" | "--file";
@@ -162,6 +162,17 @@ declare class NeuroLinkLogger {
162
162
  * @param args - The arguments to log. These are passed directly to `console.log`.
163
163
  */
164
164
  always(...args: unknown[]): void;
165
+ /**
166
+ * Logs messages unconditionally using `console.error` (stderr).
167
+ *
168
+ * Same semantics as `always()` — bypasses log level checks and debug mode
169
+ * gating — but targets stderr instead of stdout. Use this for output that
170
+ * must stay visible (safety warnings, notices) without risking corruption
171
+ * of machine-readable stdout (e.g. `--format json`).
172
+ *
173
+ * @param args - The arguments to log. These are passed directly to `console.error`.
174
+ */
175
+ alwaysStderr(...args: unknown[]): void;
165
176
  /**
166
177
  * Displays tabular data unconditionally using `console.table`.
167
178
  *
@@ -200,6 +211,7 @@ export declare const logger: {
200
211
  warn: (...args: unknown[]) => void;
201
212
  error: (...args: unknown[]) => void;
202
213
  always: (...args: unknown[]) => void;
214
+ alwaysStderr: (...args: unknown[]) => void;
203
215
  table: (data: unknown) => void;
204
216
  shouldLog: (level: LogLevel) => boolean;
205
217
  setLogLevel: (level: LogLevel) => void;
@@ -347,6 +347,19 @@ class NeuroLinkLogger {
347
347
  always(...args) {
348
348
  console.log(...args);
349
349
  }
350
+ /**
351
+ * Logs messages unconditionally using `console.error` (stderr).
352
+ *
353
+ * Same semantics as `always()` — bypasses log level checks and debug mode
354
+ * gating — but targets stderr instead of stdout. Use this for output that
355
+ * must stay visible (safety warnings, notices) without risking corruption
356
+ * of machine-readable stdout (e.g. `--format json`).
357
+ *
358
+ * @param args - The arguments to log. These are passed directly to `console.error`.
359
+ */
360
+ alwaysStderr(...args) {
361
+ console.error(...args);
362
+ }
350
363
  /**
351
364
  * Displays tabular data unconditionally using `console.table`.
352
365
  *
@@ -436,6 +449,9 @@ export const logger = {
436
449
  always: (...args) => {
437
450
  neuroLinkLogger.always(...args);
438
451
  },
452
+ alwaysStderr: (...args) => {
453
+ neuroLinkLogger.alwaysStderr(...args);
454
+ },
439
455
  table: (data) => {
440
456
  neuroLinkLogger.table(data);
441
457
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juspay/neurolink",
3
- "version": "9.94.7",
3
+ "version": "9.95.1",
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",