@juspay/neurolink 7.53.5 → 7.54.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 CHANGED
@@ -1,3 +1,9 @@
1
+ ## [7.54.0](https://github.com/juspay/neurolink/compare/v7.53.5...v7.54.0) (2025-11-08)
2
+
3
+ ### Features
4
+
5
+ - **(logs):** enable neurolink logs to be pushed into lighthouse ([9a752c4](https://github.com/juspay/neurolink/commit/9a752c4de4d300512027b7d405dda633701fae15))
6
+
1
7
  ## [7.53.5](https://github.com/juspay/neurolink/compare/v7.53.4...v7.53.5) (2025-11-06)
2
8
 
3
9
  ## [7.53.4](https://github.com/juspay/neurolink/compare/v7.53.3...v7.53.4) (2025-11-05)
@@ -187,6 +187,7 @@ export class NeuroLink {
187
187
  this.observabilityConfig = config?.observability;
188
188
  // Initialize orchestration setting
189
189
  this.enableOrchestration = config?.enableOrchestration ?? false;
190
+ logger.setEventEmitter(this.emitter);
190
191
  // Read tool cache duration from environment variables, with a default
191
192
  const cacheDurationEnv = process.env.NEUROLINK_TOOL_CACHE_DURATION;
192
193
  this.toolCacheDuration = cacheDurationEnv
@@ -1945,36 +1946,11 @@ export class NeuroLink {
1945
1946
  finally {
1946
1947
  // Store memory after stream consumption is complete
1947
1948
  if (self.conversationMemory && enhancedOptions.context?.sessionId) {
1948
- const storageStartTime = Date.now();
1949
1949
  const sessionId = enhancedOptions.context?.sessionId;
1950
1950
  const userId = enhancedOptions.context
1951
1951
  ?.userId;
1952
1952
  try {
1953
- self.emitter.emit("log-event", {
1954
- type: "log-event:storage:start",
1955
- data: {
1956
- operation: "storeConversationTurn",
1957
- sessionId,
1958
- userId,
1959
- timestamp: storageStartTime,
1960
- source: "stream-finally-block",
1961
- userInputLength: originalPrompt?.length ?? 0,
1962
- responseLength: accumulatedContent.length,
1963
- },
1964
- });
1965
1953
  await self.conversationMemory.storeConversationTurn(sessionId, userId, originalPrompt ?? "", accumulatedContent, new Date(startTime));
1966
- self.emitter.emit("log-event", {
1967
- type: "log-event:storage:end",
1968
- data: {
1969
- operation: "storeConversationTurn",
1970
- sessionId,
1971
- userId,
1972
- timestamp: Date.now(),
1973
- duration: Date.now() - storageStartTime,
1974
- source: "stream-finally-block",
1975
- success: true,
1976
- },
1977
- });
1978
1954
  logger.debug("Stream conversation turn stored", {
1979
1955
  sessionId,
1980
1956
  userInputLength: originalPrompt?.length ?? 0,
@@ -1982,18 +1958,6 @@ export class NeuroLink {
1982
1958
  });
1983
1959
  }
1984
1960
  catch (error) {
1985
- self.emitter.emit("log-event", {
1986
- type: "log-event:storage:error",
1987
- data: {
1988
- operation: "storeConversationTurn",
1989
- sessionId,
1990
- userId,
1991
- timestamp: Date.now(),
1992
- duration: Date.now() - storageStartTime,
1993
- source: "stream-finally-block",
1994
- error: error instanceof Error ? error.message : String(error),
1995
- },
1996
- });
1997
1961
  logger.warn("Failed to store stream conversation turn", {
1998
1962
  error: error instanceof Error ? error.message : String(error),
1999
1963
  });
@@ -2187,36 +2151,11 @@ export class NeuroLink {
2187
2151
  finally {
2188
2152
  // Store memory after fallback stream consumption is complete
2189
2153
  if (self.conversationMemory && enhancedOptions?.context?.sessionId) {
2190
- const storageStartTime = Date.now();
2191
2154
  const sessionId = enhancedOptions?.context?.sessionId;
2192
2155
  const userId = enhancedOptions?.context
2193
2156
  ?.userId;
2194
2157
  try {
2195
- self.emitter.emit("log", {
2196
- type: "log-event:storage:start",
2197
- data: {
2198
- operation: "storeConversationTurn",
2199
- sessionId,
2200
- userId,
2201
- timestamp: storageStartTime,
2202
- source: "fallback-stream-finally-block",
2203
- userInputLength: originalPrompt?.length ?? 0,
2204
- responseLength: fallbackAccumulatedContent.length,
2205
- },
2206
- });
2207
2158
  await self.conversationMemory.storeConversationTurn(sessionId || options.context?.sessionId, userId || options.context?.userId, originalPrompt ?? "", fallbackAccumulatedContent, new Date(startTime));
2208
- self.emitter.emit("log", {
2209
- type: "log-event:storage:end",
2210
- data: {
2211
- operation: "storeConversationTurn",
2212
- sessionId,
2213
- userId,
2214
- timestamp: Date.now(),
2215
- duration: Date.now() - storageStartTime,
2216
- source: "fallback-stream-finally-block",
2217
- success: true,
2218
- },
2219
- });
2220
2159
  logger.debug("Fallback stream conversation turn stored", {
2221
2160
  sessionId: sessionId || options.context?.sessionId,
2222
2161
  userInputLength: originalPrompt?.length ?? 0,
@@ -2224,18 +2163,6 @@ export class NeuroLink {
2224
2163
  });
2225
2164
  }
2226
2165
  catch (error) {
2227
- self.emitter.emit("log-event", {
2228
- type: "log-event:storage:error",
2229
- data: {
2230
- operation: "storeConversationTurn",
2231
- sessionId,
2232
- userId,
2233
- timestamp: Date.now(),
2234
- duration: Date.now() - storageStartTime,
2235
- source: "fallback-stream-finally-block",
2236
- error: error instanceof Error ? error.message : String(error),
2237
- },
2238
- });
2239
2166
  logger.warn("Failed to store fallback stream conversation turn", {
2240
2167
  error: error instanceof Error ? error.message : String(error),
2241
2168
  });
@@ -4254,6 +4181,7 @@ export class NeuroLink {
4254
4181
  try {
4255
4182
  logger.debug("[NeuroLink] Removing all event listeners...");
4256
4183
  this.emitter.removeAllListeners();
4184
+ logger.clearEventEmitter();
4257
4185
  logger.debug("[NeuroLink] Event listeners removed successfully");
4258
4186
  }
4259
4187
  catch (error) {
@@ -114,6 +114,7 @@ export type NeuroLinkEvents = {
114
114
  message: unknown;
115
115
  error: unknown;
116
116
  log: unknown;
117
+ "log-event": unknown;
117
118
  [key: string]: unknown;
118
119
  };
119
120
  /**
@@ -19,7 +19,22 @@ declare class NeuroLinkLogger {
19
19
  private logs;
20
20
  private maxLogs;
21
21
  private isDebugMode;
22
+ private eventEmitter?;
22
23
  constructor();
24
+ /**
25
+ * Sets the event emitter that will receive log events.
26
+ * When set, all log operations will emit a "log-event" event.
27
+ *
28
+ * @param emitter - The event emitter instance
29
+ */
30
+ setEventEmitter(emitter: {
31
+ emit: (event: string, ...args: unknown[]) => boolean;
32
+ }): void;
33
+ /**
34
+ * Clears the event emitter reference.
35
+ * Should be called when a NeuroLink instance is disposed to prevent memory leaks.
36
+ */
37
+ clearEventEmitter(): void;
23
38
  /**
24
39
  * Sets the minimum log level that will be processed and output.
25
40
  * Log messages with a level lower than this will be ignored.
@@ -63,6 +78,7 @@ declare class NeuroLinkLogger {
63
78
  * 2. Storing entries in the log history
64
79
  * 3. Managing log rotation to prevent memory issues
65
80
  * 4. Outputting formatted logs to the console
81
+ * 5. Emitting log events if an event emitter is configured
66
82
  *
67
83
  * This is the central method called by all specific logging methods (debug, info, etc.)
68
84
  *
@@ -164,6 +180,7 @@ declare class NeuroLinkLogger {
164
180
  * - Unconditional logging (always, table)
165
181
  * - Log level control and configuration
166
182
  * - Log history management
183
+ * - Event emission for all log operations (when emitter is configured)
167
184
  */
168
185
  export declare const logger: {
169
186
  debug: (...args: unknown[]) => void;
@@ -175,6 +192,10 @@ export declare const logger: {
175
192
  setLogLevel: (level: LogLevel) => void;
176
193
  getLogs: (level?: LogLevel) => LogEntry[];
177
194
  clearLogs: () => void;
195
+ setEventEmitter: (emitter: {
196
+ emit: (event: string, ...args: unknown[]) => boolean;
197
+ }) => void;
198
+ clearEventEmitter: () => void;
178
199
  };
179
200
  /**
180
201
  * MCP compatibility exports - all use the same unified logger instance.
@@ -25,6 +25,7 @@ class NeuroLinkLogger {
25
25
  logs = [];
26
26
  maxLogs = 1000;
27
27
  isDebugMode;
28
+ eventEmitter;
28
29
  constructor() {
29
30
  // Cache debug mode check to avoid repeated array searches
30
31
  this.isDebugMode =
@@ -36,6 +37,22 @@ class NeuroLinkLogger {
36
37
  this.logLevel = envLevel;
37
38
  }
38
39
  }
40
+ /**
41
+ * Sets the event emitter that will receive log events.
42
+ * When set, all log operations will emit a "log-event" event.
43
+ *
44
+ * @param emitter - The event emitter instance
45
+ */
46
+ setEventEmitter(emitter) {
47
+ this.eventEmitter = emitter;
48
+ }
49
+ /**
50
+ * Clears the event emitter reference.
51
+ * Should be called when a NeuroLink instance is disposed to prevent memory leaks.
52
+ */
53
+ clearEventEmitter() {
54
+ this.eventEmitter = undefined;
55
+ }
39
56
  /**
40
57
  * Sets the minimum log level that will be processed and output.
41
58
  * Log messages with a level lower than this will be ignored.
@@ -106,6 +123,7 @@ class NeuroLinkLogger {
106
123
  * 2. Storing entries in the log history
107
124
  * 3. Managing log rotation to prevent memory issues
108
125
  * 4. Outputting formatted logs to the console
126
+ * 5. Emitting log events if an event emitter is configured
109
127
  *
110
128
  * This is the central method called by all specific logging methods (debug, info, etc.)
111
129
  *
@@ -123,6 +141,20 @@ class NeuroLinkLogger {
123
141
  timestamp: new Date(),
124
142
  data,
125
143
  };
144
+ // Emit log event if emitter is configured
145
+ if (this.eventEmitter) {
146
+ try {
147
+ this.eventEmitter.emit("log-event", {
148
+ level,
149
+ message,
150
+ timestamp: new Date().getTime(),
151
+ data,
152
+ });
153
+ }
154
+ catch {
155
+ // Silently ignore emitter errors to avoid disrupting logging
156
+ }
157
+ }
126
158
  // Store log entry
127
159
  this.logs.push(entry);
128
160
  // Trim old logs
@@ -277,6 +309,7 @@ function processLoggerArgs(args, logMethod) {
277
309
  * - Unconditional logging (always, table)
278
310
  * - Log level control and configuration
279
311
  * - Log history management
312
+ * - Event emission for all log operations (when emitter is configured)
280
313
  */
281
314
  export const logger = {
282
315
  debug: (...args) => {
@@ -309,6 +342,8 @@ export const logger = {
309
342
  setLogLevel: (level) => neuroLinkLogger.setLogLevel(level),
310
343
  getLogs: (level) => neuroLinkLogger.getLogs(level),
311
344
  clearLogs: () => neuroLinkLogger.clearLogs(),
345
+ setEventEmitter: (emitter) => neuroLinkLogger.setEventEmitter(emitter),
346
+ clearEventEmitter: () => neuroLinkLogger.clearEventEmitter(),
312
347
  };
313
348
  /**
314
349
  * MCP compatibility exports - all use the same unified logger instance.
package/dist/neurolink.js CHANGED
@@ -187,6 +187,7 @@ export class NeuroLink {
187
187
  this.observabilityConfig = config?.observability;
188
188
  // Initialize orchestration setting
189
189
  this.enableOrchestration = config?.enableOrchestration ?? false;
190
+ logger.setEventEmitter(this.emitter);
190
191
  // Read tool cache duration from environment variables, with a default
191
192
  const cacheDurationEnv = process.env.NEUROLINK_TOOL_CACHE_DURATION;
192
193
  this.toolCacheDuration = cacheDurationEnv
@@ -1945,36 +1946,11 @@ export class NeuroLink {
1945
1946
  finally {
1946
1947
  // Store memory after stream consumption is complete
1947
1948
  if (self.conversationMemory && enhancedOptions.context?.sessionId) {
1948
- const storageStartTime = Date.now();
1949
1949
  const sessionId = enhancedOptions.context?.sessionId;
1950
1950
  const userId = enhancedOptions.context
1951
1951
  ?.userId;
1952
1952
  try {
1953
- self.emitter.emit("log-event", {
1954
- type: "log-event:storage:start",
1955
- data: {
1956
- operation: "storeConversationTurn",
1957
- sessionId,
1958
- userId,
1959
- timestamp: storageStartTime,
1960
- source: "stream-finally-block",
1961
- userInputLength: originalPrompt?.length ?? 0,
1962
- responseLength: accumulatedContent.length,
1963
- },
1964
- });
1965
1953
  await self.conversationMemory.storeConversationTurn(sessionId, userId, originalPrompt ?? "", accumulatedContent, new Date(startTime));
1966
- self.emitter.emit("log-event", {
1967
- type: "log-event:storage:end",
1968
- data: {
1969
- operation: "storeConversationTurn",
1970
- sessionId,
1971
- userId,
1972
- timestamp: Date.now(),
1973
- duration: Date.now() - storageStartTime,
1974
- source: "stream-finally-block",
1975
- success: true,
1976
- },
1977
- });
1978
1954
  logger.debug("Stream conversation turn stored", {
1979
1955
  sessionId,
1980
1956
  userInputLength: originalPrompt?.length ?? 0,
@@ -1982,18 +1958,6 @@ export class NeuroLink {
1982
1958
  });
1983
1959
  }
1984
1960
  catch (error) {
1985
- self.emitter.emit("log-event", {
1986
- type: "log-event:storage:error",
1987
- data: {
1988
- operation: "storeConversationTurn",
1989
- sessionId,
1990
- userId,
1991
- timestamp: Date.now(),
1992
- duration: Date.now() - storageStartTime,
1993
- source: "stream-finally-block",
1994
- error: error instanceof Error ? error.message : String(error),
1995
- },
1996
- });
1997
1961
  logger.warn("Failed to store stream conversation turn", {
1998
1962
  error: error instanceof Error ? error.message : String(error),
1999
1963
  });
@@ -2187,36 +2151,11 @@ export class NeuroLink {
2187
2151
  finally {
2188
2152
  // Store memory after fallback stream consumption is complete
2189
2153
  if (self.conversationMemory && enhancedOptions?.context?.sessionId) {
2190
- const storageStartTime = Date.now();
2191
2154
  const sessionId = enhancedOptions?.context?.sessionId;
2192
2155
  const userId = enhancedOptions?.context
2193
2156
  ?.userId;
2194
2157
  try {
2195
- self.emitter.emit("log", {
2196
- type: "log-event:storage:start",
2197
- data: {
2198
- operation: "storeConversationTurn",
2199
- sessionId,
2200
- userId,
2201
- timestamp: storageStartTime,
2202
- source: "fallback-stream-finally-block",
2203
- userInputLength: originalPrompt?.length ?? 0,
2204
- responseLength: fallbackAccumulatedContent.length,
2205
- },
2206
- });
2207
2158
  await self.conversationMemory.storeConversationTurn(sessionId || options.context?.sessionId, userId || options.context?.userId, originalPrompt ?? "", fallbackAccumulatedContent, new Date(startTime));
2208
- self.emitter.emit("log", {
2209
- type: "log-event:storage:end",
2210
- data: {
2211
- operation: "storeConversationTurn",
2212
- sessionId,
2213
- userId,
2214
- timestamp: Date.now(),
2215
- duration: Date.now() - storageStartTime,
2216
- source: "fallback-stream-finally-block",
2217
- success: true,
2218
- },
2219
- });
2220
2159
  logger.debug("Fallback stream conversation turn stored", {
2221
2160
  sessionId: sessionId || options.context?.sessionId,
2222
2161
  userInputLength: originalPrompt?.length ?? 0,
@@ -2224,18 +2163,6 @@ export class NeuroLink {
2224
2163
  });
2225
2164
  }
2226
2165
  catch (error) {
2227
- self.emitter.emit("log-event", {
2228
- type: "log-event:storage:error",
2229
- data: {
2230
- operation: "storeConversationTurn",
2231
- sessionId,
2232
- userId,
2233
- timestamp: Date.now(),
2234
- duration: Date.now() - storageStartTime,
2235
- source: "fallback-stream-finally-block",
2236
- error: error instanceof Error ? error.message : String(error),
2237
- },
2238
- });
2239
2166
  logger.warn("Failed to store fallback stream conversation turn", {
2240
2167
  error: error instanceof Error ? error.message : String(error),
2241
2168
  });
@@ -4254,6 +4181,7 @@ export class NeuroLink {
4254
4181
  try {
4255
4182
  logger.debug("[NeuroLink] Removing all event listeners...");
4256
4183
  this.emitter.removeAllListeners();
4184
+ logger.clearEventEmitter();
4257
4185
  logger.debug("[NeuroLink] Event listeners removed successfully");
4258
4186
  }
4259
4187
  catch (error) {
@@ -114,6 +114,7 @@ export type NeuroLinkEvents = {
114
114
  message: unknown;
115
115
  error: unknown;
116
116
  log: unknown;
117
+ "log-event": unknown;
117
118
  [key: string]: unknown;
118
119
  };
119
120
  /**
@@ -19,7 +19,22 @@ declare class NeuroLinkLogger {
19
19
  private logs;
20
20
  private maxLogs;
21
21
  private isDebugMode;
22
+ private eventEmitter?;
22
23
  constructor();
24
+ /**
25
+ * Sets the event emitter that will receive log events.
26
+ * When set, all log operations will emit a "log-event" event.
27
+ *
28
+ * @param emitter - The event emitter instance
29
+ */
30
+ setEventEmitter(emitter: {
31
+ emit: (event: string, ...args: unknown[]) => boolean;
32
+ }): void;
33
+ /**
34
+ * Clears the event emitter reference.
35
+ * Should be called when a NeuroLink instance is disposed to prevent memory leaks.
36
+ */
37
+ clearEventEmitter(): void;
23
38
  /**
24
39
  * Sets the minimum log level that will be processed and output.
25
40
  * Log messages with a level lower than this will be ignored.
@@ -63,6 +78,7 @@ declare class NeuroLinkLogger {
63
78
  * 2. Storing entries in the log history
64
79
  * 3. Managing log rotation to prevent memory issues
65
80
  * 4. Outputting formatted logs to the console
81
+ * 5. Emitting log events if an event emitter is configured
66
82
  *
67
83
  * This is the central method called by all specific logging methods (debug, info, etc.)
68
84
  *
@@ -164,6 +180,7 @@ declare class NeuroLinkLogger {
164
180
  * - Unconditional logging (always, table)
165
181
  * - Log level control and configuration
166
182
  * - Log history management
183
+ * - Event emission for all log operations (when emitter is configured)
167
184
  */
168
185
  export declare const logger: {
169
186
  debug: (...args: unknown[]) => void;
@@ -175,6 +192,10 @@ export declare const logger: {
175
192
  setLogLevel: (level: LogLevel) => void;
176
193
  getLogs: (level?: LogLevel) => LogEntry[];
177
194
  clearLogs: () => void;
195
+ setEventEmitter: (emitter: {
196
+ emit: (event: string, ...args: unknown[]) => boolean;
197
+ }) => void;
198
+ clearEventEmitter: () => void;
178
199
  };
179
200
  /**
180
201
  * MCP compatibility exports - all use the same unified logger instance.
@@ -25,6 +25,7 @@ class NeuroLinkLogger {
25
25
  logs = [];
26
26
  maxLogs = 1000;
27
27
  isDebugMode;
28
+ eventEmitter;
28
29
  constructor() {
29
30
  // Cache debug mode check to avoid repeated array searches
30
31
  this.isDebugMode =
@@ -36,6 +37,22 @@ class NeuroLinkLogger {
36
37
  this.logLevel = envLevel;
37
38
  }
38
39
  }
40
+ /**
41
+ * Sets the event emitter that will receive log events.
42
+ * When set, all log operations will emit a "log-event" event.
43
+ *
44
+ * @param emitter - The event emitter instance
45
+ */
46
+ setEventEmitter(emitter) {
47
+ this.eventEmitter = emitter;
48
+ }
49
+ /**
50
+ * Clears the event emitter reference.
51
+ * Should be called when a NeuroLink instance is disposed to prevent memory leaks.
52
+ */
53
+ clearEventEmitter() {
54
+ this.eventEmitter = undefined;
55
+ }
39
56
  /**
40
57
  * Sets the minimum log level that will be processed and output.
41
58
  * Log messages with a level lower than this will be ignored.
@@ -106,6 +123,7 @@ class NeuroLinkLogger {
106
123
  * 2. Storing entries in the log history
107
124
  * 3. Managing log rotation to prevent memory issues
108
125
  * 4. Outputting formatted logs to the console
126
+ * 5. Emitting log events if an event emitter is configured
109
127
  *
110
128
  * This is the central method called by all specific logging methods (debug, info, etc.)
111
129
  *
@@ -123,6 +141,20 @@ class NeuroLinkLogger {
123
141
  timestamp: new Date(),
124
142
  data,
125
143
  };
144
+ // Emit log event if emitter is configured
145
+ if (this.eventEmitter) {
146
+ try {
147
+ this.eventEmitter.emit("log-event", {
148
+ level,
149
+ message,
150
+ timestamp: new Date().getTime(),
151
+ data,
152
+ });
153
+ }
154
+ catch {
155
+ // Silently ignore emitter errors to avoid disrupting logging
156
+ }
157
+ }
126
158
  // Store log entry
127
159
  this.logs.push(entry);
128
160
  // Trim old logs
@@ -277,6 +309,7 @@ function processLoggerArgs(args, logMethod) {
277
309
  * - Unconditional logging (always, table)
278
310
  * - Log level control and configuration
279
311
  * - Log history management
312
+ * - Event emission for all log operations (when emitter is configured)
280
313
  */
281
314
  export const logger = {
282
315
  debug: (...args) => {
@@ -309,6 +342,8 @@ export const logger = {
309
342
  setLogLevel: (level) => neuroLinkLogger.setLogLevel(level),
310
343
  getLogs: (level) => neuroLinkLogger.getLogs(level),
311
344
  clearLogs: () => neuroLinkLogger.clearLogs(),
345
+ setEventEmitter: (emitter) => neuroLinkLogger.setEventEmitter(emitter),
346
+ clearEventEmitter: () => neuroLinkLogger.clearEventEmitter(),
312
347
  };
313
348
  /**
314
349
  * MCP compatibility exports - all use the same unified logger instance.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juspay/neurolink",
3
- "version": "7.53.5",
3
+ "version": "7.54.0",
4
4
  "description": "Universal AI Development Platform with working MCP integration, multi-provider support, and professional CLI. Built-in tools operational, 58+ external MCP servers discoverable. Connect to filesystem, GitHub, database operations, and more. Build, test, and deploy AI applications with 9 major providers: OpenAI, Anthropic, Google AI, AWS Bedrock, Azure, Hugging Face, Ollama, and Mistral AI.",
5
5
  "author": {
6
6
  "name": "Juspay Technologies",