@juspay/neurolink 9.83.0 → 9.84.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 (117) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/agent/agent.d.ts +104 -0
  3. package/dist/agent/agent.js +401 -0
  4. package/dist/agent/agentNetwork.d.ts +87 -0
  5. package/dist/agent/agentNetwork.js +458 -0
  6. package/dist/agent/communication/index.d.ts +9 -0
  7. package/dist/agent/communication/index.js +9 -0
  8. package/dist/agent/communication/message-bus.d.ts +113 -0
  9. package/dist/agent/communication/message-bus.js +406 -0
  10. package/dist/agent/coordination/coordinator.d.ts +83 -0
  11. package/dist/agent/coordination/coordinator.js +598 -0
  12. package/dist/agent/coordination/index.d.ts +10 -0
  13. package/dist/agent/coordination/index.js +10 -0
  14. package/dist/agent/coordination/task-distributor.d.ts +113 -0
  15. package/dist/agent/coordination/task-distributor.js +585 -0
  16. package/dist/agent/index.d.ts +38 -0
  17. package/dist/agent/index.js +44 -0
  18. package/dist/agent/orchestration/index.d.ts +10 -0
  19. package/dist/agent/orchestration/index.js +10 -0
  20. package/dist/agent/orchestration/orchestrator.d.ts +114 -0
  21. package/dist/agent/orchestration/orchestrator.js +476 -0
  22. package/dist/agent/orchestration/topology.d.ts +164 -0
  23. package/dist/agent/orchestration/topology.js +520 -0
  24. package/dist/agent/prompts/routingPrompts.d.ts +63 -0
  25. package/dist/agent/prompts/routingPrompts.js +201 -0
  26. package/dist/browser/neurolink.min.js +377 -358
  27. package/dist/cli/commands/agent.d.ts +37 -0
  28. package/dist/cli/commands/agent.js +718 -0
  29. package/dist/cli/factories/commandFactory.d.ts +8 -0
  30. package/dist/cli/factories/commandFactory.js +116 -0
  31. package/dist/cli/loop/optionsSchema.d.ts +1 -1
  32. package/dist/cli/parser.js +4 -0
  33. package/dist/index.d.ts +6 -0
  34. package/dist/index.js +19 -0
  35. package/dist/lib/agent/agent.d.ts +104 -0
  36. package/dist/lib/agent/agent.js +402 -0
  37. package/dist/lib/agent/agentNetwork.d.ts +87 -0
  38. package/dist/lib/agent/agentNetwork.js +459 -0
  39. package/dist/lib/agent/communication/index.d.ts +9 -0
  40. package/dist/lib/agent/communication/index.js +10 -0
  41. package/dist/lib/agent/communication/message-bus.d.ts +113 -0
  42. package/dist/lib/agent/communication/message-bus.js +407 -0
  43. package/dist/lib/agent/coordination/coordinator.d.ts +83 -0
  44. package/dist/lib/agent/coordination/coordinator.js +599 -0
  45. package/dist/lib/agent/coordination/index.d.ts +10 -0
  46. package/dist/lib/agent/coordination/index.js +11 -0
  47. package/dist/lib/agent/coordination/task-distributor.d.ts +113 -0
  48. package/dist/lib/agent/coordination/task-distributor.js +586 -0
  49. package/dist/lib/agent/index.d.ts +38 -0
  50. package/dist/lib/agent/index.js +45 -0
  51. package/dist/lib/agent/orchestration/index.d.ts +10 -0
  52. package/dist/lib/agent/orchestration/index.js +11 -0
  53. package/dist/lib/agent/orchestration/orchestrator.d.ts +114 -0
  54. package/dist/lib/agent/orchestration/orchestrator.js +477 -0
  55. package/dist/lib/agent/orchestration/topology.d.ts +164 -0
  56. package/dist/lib/agent/orchestration/topology.js +521 -0
  57. package/dist/lib/agent/prompts/routingPrompts.d.ts +63 -0
  58. package/dist/lib/agent/prompts/routingPrompts.js +202 -0
  59. package/dist/lib/index.d.ts +6 -0
  60. package/dist/lib/index.js +19 -0
  61. package/dist/lib/neurolink.d.ts +129 -0
  62. package/dist/lib/neurolink.js +276 -0
  63. package/dist/lib/processors/config/{fileTypes.js → fileExtensions.js} +1 -1
  64. package/dist/lib/processors/config/index.d.ts +2 -2
  65. package/dist/lib/processors/config/index.js +2 -2
  66. package/dist/lib/processors/config/{mimeTypes.js → mimeConstants.js} +1 -1
  67. package/dist/lib/processors/index.js +8 -0
  68. package/dist/lib/providers/googleAiStudio.js +3 -3
  69. package/dist/lib/providers/googleNativeGemini3.d.ts +18 -0
  70. package/dist/lib/providers/googleNativeGemini3.js +47 -1
  71. package/dist/lib/providers/googleVertex.js +5 -5
  72. package/dist/lib/types/agentNetwork.d.ts +1184 -0
  73. package/dist/lib/types/agentNetwork.js +8 -0
  74. package/dist/lib/types/cli.d.ts +66 -0
  75. package/dist/lib/types/generate.d.ts +53 -0
  76. package/dist/lib/types/index.d.ts +2 -0
  77. package/dist/lib/types/index.js +3 -0
  78. package/dist/lib/types/ioProcessor.d.ts +119 -0
  79. package/dist/lib/types/ioProcessor.js +10 -0
  80. package/dist/lib/types/stream.d.ts +36 -0
  81. package/dist/lib/utils/piiDetector.d.ts +24 -0
  82. package/dist/lib/utils/piiDetector.js +221 -0
  83. package/dist/lib/utils/responseValidator.d.ts +21 -0
  84. package/dist/lib/utils/responseValidator.js +354 -0
  85. package/dist/lib/utils/tripwireEvaluator.d.ts +73 -0
  86. package/dist/lib/utils/tripwireEvaluator.js +285 -0
  87. package/dist/neurolink.d.ts +129 -0
  88. package/dist/neurolink.js +276 -0
  89. package/dist/processors/config/index.d.ts +2 -2
  90. package/dist/processors/config/index.js +2 -2
  91. package/dist/processors/index.js +8 -0
  92. package/dist/providers/googleAiStudio.js +3 -3
  93. package/dist/providers/googleNativeGemini3.d.ts +18 -0
  94. package/dist/providers/googleNativeGemini3.js +47 -1
  95. package/dist/providers/googleVertex.js +5 -5
  96. package/dist/types/agentNetwork.d.ts +1184 -0
  97. package/dist/types/agentNetwork.js +7 -0
  98. package/dist/types/cli.d.ts +66 -0
  99. package/dist/types/generate.d.ts +53 -0
  100. package/dist/types/index.d.ts +2 -0
  101. package/dist/types/index.js +3 -0
  102. package/dist/types/ioProcessor.d.ts +119 -0
  103. package/dist/types/ioProcessor.js +9 -0
  104. package/dist/types/stream.d.ts +36 -0
  105. package/dist/utils/piiDetector.d.ts +24 -0
  106. package/dist/utils/piiDetector.js +220 -0
  107. package/dist/utils/responseValidator.d.ts +21 -0
  108. package/dist/utils/responseValidator.js +353 -0
  109. package/dist/utils/tripwireEvaluator.d.ts +73 -0
  110. package/dist/utils/tripwireEvaluator.js +284 -0
  111. package/package.json +1 -1
  112. /package/dist/lib/processors/config/{fileTypes.d.ts → fileExtensions.d.ts} +0 -0
  113. /package/dist/lib/processors/config/{mimeTypes.d.ts → mimeConstants.d.ts} +0 -0
  114. /package/dist/processors/config/{fileTypes.d.ts → fileExtensions.d.ts} +0 -0
  115. /package/dist/processors/config/{fileTypes.js → fileExtensions.js} +0 -0
  116. /package/dist/processors/config/{mimeTypes.d.ts → mimeConstants.d.ts} +0 -0
  117. /package/dist/processors/config/{mimeTypes.js → mimeConstants.js} +0 -0
@@ -0,0 +1,284 @@
1
+ /**
2
+ * TripwireEvaluator - Standalone health-check utility
3
+ *
4
+ * Evaluates blocking conditions against LLM response data to detect
5
+ * runtime issues such as empty responses, high latency, max tokens hit,
6
+ * and repetition loops.
7
+ *
8
+ * This module has no dependency on the processor pipeline system and can
9
+ * be used independently.
10
+ *
11
+ * @module utils/tripwireEvaluator
12
+ */
13
+ // ============================================================================
14
+ // TripwireEvaluator
15
+ // ============================================================================
16
+ /**
17
+ * Manages and evaluates tripwire conditions against LLM response data.
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * const evaluator = createDefaultTripwireEvaluator();
22
+ *
23
+ * const result = evaluator.evaluate({
24
+ * responseText: "",
25
+ * latencyMs: 45000,
26
+ * finishReason: "length",
27
+ * });
28
+ *
29
+ * if (result.triggered && result.action === "abort") {
30
+ * throw new Error(result.message);
31
+ * }
32
+ * ```
33
+ */
34
+ export class TripwireEvaluator {
35
+ tripwires = [];
36
+ /**
37
+ * Register a tripwire. Replaces any existing tripwire with the same id.
38
+ */
39
+ register(tripwire) {
40
+ const existingIndex = this.tripwires.findIndex((t) => t.id === tripwire.id);
41
+ if (existingIndex !== -1) {
42
+ this.tripwires[existingIndex] = tripwire;
43
+ }
44
+ else {
45
+ this.tripwires.push(tripwire);
46
+ }
47
+ }
48
+ /**
49
+ * Remove a registered tripwire by id.
50
+ * @returns true if the tripwire was found and removed, false otherwise.
51
+ */
52
+ unregister(id) {
53
+ const index = this.tripwires.findIndex((t) => t.id === id);
54
+ if (index !== -1) {
55
+ this.tripwires.splice(index, 1);
56
+ return true;
57
+ }
58
+ return false;
59
+ }
60
+ /**
61
+ * Evaluate all tripwires and return the highest-priority triggered result.
62
+ *
63
+ * Priority order: "abort" > "warn" > "log"
64
+ *
65
+ * Bug fix (C1): The original implementation returned on the FIRST triggered
66
+ * tripwire regardless of action, which meant a "warn" registered before an
67
+ * "abort" would mask the abort. This implementation evaluates ALL tripwires
68
+ * and promotes the highest-severity action.
69
+ */
70
+ evaluate(data) {
71
+ let firstAbort = null;
72
+ let firstWarn = null;
73
+ let firstLog = null;
74
+ for (const tripwire of this.tripwires) {
75
+ let triggered;
76
+ try {
77
+ triggered = tripwire.condition(data);
78
+ }
79
+ catch {
80
+ // Skip tripwires whose condition throws — don't let evaluation errors
81
+ // block normal operation.
82
+ continue;
83
+ }
84
+ if (!triggered) {
85
+ continue;
86
+ }
87
+ const message = typeof tripwire.message === "function"
88
+ ? tripwire.message(data)
89
+ : tripwire.message;
90
+ const result = {
91
+ triggered: true,
92
+ tripwire,
93
+ message,
94
+ action: tripwire.action,
95
+ };
96
+ if (tripwire.action === "abort" && firstAbort === null) {
97
+ firstAbort = result;
98
+ }
99
+ else if (tripwire.action === "warn" && firstWarn === null) {
100
+ firstWarn = result;
101
+ }
102
+ else if (tripwire.action === "log" && firstLog === null) {
103
+ firstLog = result;
104
+ }
105
+ }
106
+ if (firstAbort !== null) {
107
+ return firstAbort;
108
+ }
109
+ if (firstWarn !== null) {
110
+ return firstWarn;
111
+ }
112
+ if (firstLog !== null) {
113
+ return firstLog;
114
+ }
115
+ return { triggered: false };
116
+ }
117
+ /**
118
+ * Evaluate all tripwires and return every triggered result.
119
+ */
120
+ evaluateAll(data) {
121
+ const results = [];
122
+ for (const tripwire of this.tripwires) {
123
+ let triggered;
124
+ try {
125
+ triggered = tripwire.condition(data);
126
+ }
127
+ catch {
128
+ continue;
129
+ }
130
+ if (!triggered) {
131
+ continue;
132
+ }
133
+ const message = typeof tripwire.message === "function"
134
+ ? tripwire.message(data)
135
+ : tripwire.message;
136
+ results.push({
137
+ triggered: true,
138
+ tripwire,
139
+ message,
140
+ action: tripwire.action,
141
+ });
142
+ }
143
+ return results;
144
+ }
145
+ /**
146
+ * Return a shallow copy of all registered tripwires.
147
+ */
148
+ getTripwires() {
149
+ return [...this.tripwires];
150
+ }
151
+ }
152
+ // ============================================================================
153
+ // Built-in tripwires
154
+ // ============================================================================
155
+ /**
156
+ * Triggers when the model hit its token output limit (finishReason === "length").
157
+ */
158
+ const maxTokensTripwire = {
159
+ id: "max-tokens",
160
+ name: "Maximum Tokens Hit",
161
+ description: "Triggers when the model stopped because it reached the token output limit.",
162
+ action: "abort",
163
+ condition: (data) => data.finishReason === "length",
164
+ message: "Model stopped at token limit — response may be truncated.",
165
+ };
166
+ /**
167
+ * Triggers when the response is empty or only whitespace.
168
+ */
169
+ const emptyResponseTripwire = {
170
+ id: "empty-response",
171
+ name: "Empty Response",
172
+ description: "Triggers when the model returns an empty or whitespace-only response.",
173
+ action: "abort",
174
+ condition: (data) => data.responseText !== undefined && data.responseText.trim().length === 0,
175
+ message: "Model returned an empty response.",
176
+ };
177
+ /**
178
+ * Triggers when the response contains highly repetitive phrases.
179
+ * Uses a sliding-window approach: splits into overlapping 10-word windows and
180
+ * counts duplicates. If more than 20% of windows are repeated the response is
181
+ * flagged as a repetition loop.
182
+ */
183
+ const repetitionLoopTripwire = {
184
+ id: "repetition-loop",
185
+ name: "Repetition Loop",
186
+ description: "Detects when the model is generating repetitive content, indicating a loop.",
187
+ action: "warn",
188
+ condition: (data) => {
189
+ const text = data.responseText;
190
+ if (!text) {
191
+ return false;
192
+ }
193
+ const words = text.split(/\s+/);
194
+ if (words.length < 30) {
195
+ return false;
196
+ }
197
+ const windowSize = 10;
198
+ const windows = new Map();
199
+ let duplicates = 0;
200
+ const totalWindows = words.length - windowSize + 1;
201
+ for (let i = 0; i <= words.length - windowSize; i++) {
202
+ const window = words.slice(i, i + windowSize).join(" ");
203
+ const count = (windows.get(window) ?? 0) + 1;
204
+ windows.set(window, count);
205
+ if (count > 1) {
206
+ duplicates++;
207
+ }
208
+ }
209
+ return duplicates / totalWindows > 0.2;
210
+ },
211
+ message: "Response contains highly repetitive content — possible generation loop.",
212
+ };
213
+ /**
214
+ * Triggers when the input text exceeds 100 000 characters.
215
+ */
216
+ const inputTooLongTripwire = {
217
+ id: "input-too-long",
218
+ name: "Input Too Long",
219
+ description: "Triggers when the input text exceeds the recommended length.",
220
+ action: "abort",
221
+ condition: (data) => data.inputText !== undefined && data.inputText.length > 100_000,
222
+ message: (data) => `Input is ${data.inputText?.length ?? 0} characters — exceeds the 100 000-character limit.`,
223
+ };
224
+ /**
225
+ * Triggers when the conversation has more than 100 messages.
226
+ */
227
+ const tooManyMessagesTripwire = {
228
+ id: "too-many-messages",
229
+ name: "Too Many Messages",
230
+ description: "Triggers when the conversation message count exceeds the recommended maximum.",
231
+ action: "warn",
232
+ condition: (data) => data.messageCount !== undefined && data.messageCount > 100,
233
+ message: (data) => `Conversation has ${data.messageCount} messages — consider summarising context.`,
234
+ };
235
+ /**
236
+ * Triggers when the response text exceeds 50 000 characters.
237
+ */
238
+ const responseTooLongTripwire = {
239
+ id: "response-too-long",
240
+ name: "Response Too Long",
241
+ description: "Triggers when the response text exceeds the recommended length.",
242
+ action: "warn",
243
+ condition: (data) => data.responseText !== undefined && data.responseText.length > 50_000,
244
+ message: (data) => `Response is ${data.responseText?.length ?? 0} characters — exceeds the 50 000-character limit.`,
245
+ };
246
+ /**
247
+ * Triggers when the measured end-to-end latency exceeds 30 seconds.
248
+ */
249
+ const highLatencyTripwire = {
250
+ id: "high-latency",
251
+ name: "High Latency",
252
+ description: "Triggers when the measured response latency exceeds the acceptable threshold.",
253
+ action: "warn",
254
+ condition: (data) => data.latencyMs !== undefined && data.latencyMs > 30_000,
255
+ message: (data) => `Response latency was ${data.latencyMs}ms — exceeds the 30 000ms threshold.`,
256
+ };
257
+ /**
258
+ * All built-in tripwires in default registration order.
259
+ *
260
+ * Registration order does not affect priority — `evaluate()` always promotes
261
+ * the highest-severity action ("abort" > "warn" > "log").
262
+ */
263
+ export const commonTripwires = [
264
+ maxTokensTripwire,
265
+ emptyResponseTripwire,
266
+ repetitionLoopTripwire,
267
+ inputTooLongTripwire,
268
+ tooManyMessagesTripwire,
269
+ responseTooLongTripwire,
270
+ highLatencyTripwire,
271
+ ];
272
+ // ============================================================================
273
+ // Factory
274
+ // ============================================================================
275
+ /**
276
+ * Create a TripwireEvaluator pre-loaded with all built-in tripwires.
277
+ */
278
+ export function createDefaultTripwireEvaluator() {
279
+ const evaluator = new TripwireEvaluator();
280
+ for (const tripwire of commonTripwires) {
281
+ evaluator.register(tripwire);
282
+ }
283
+ return evaluator;
284
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juspay/neurolink",
3
- "version": "9.83.0",
3
+ "version": "9.84.0",
4
4
  "packageManager": "pnpm@10.15.1",
5
5
  "description": "Universal AI Development Platform with working MCP integration, multi-provider support, voice (TTS/STT/realtime), and professional CLI. 58+ external MCP servers discoverable, multimodal file processing, RAG pipelines. Build, test, and deploy AI applications with 21+ providers: OpenAI, Anthropic, Google AI Studio, Google Vertex, AWS Bedrock, Azure OpenAI, Mistral, LiteLLM, SageMaker, Hugging Face, Ollama, OpenAI-compatible, OpenRouter, DeepSeek, NVIDIA NIM, LM Studio, llama.cpp, plus voice (OpenAI TTS, ElevenLabs, Deepgram, Azure Speech).",
6
6
  "author": {