@juspay/neurolink 8.0.0 → 8.0.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 +7 -0
- package/dist/lib/memory/mem0Initializer.d.ts +10 -5
- package/dist/lib/memory/mem0Initializer.js +17 -28
- package/dist/lib/neurolink.d.ts +4 -0
- package/dist/lib/neurolink.js +38 -42
- package/dist/lib/types/conversation.d.ts +3 -6
- package/dist/lib/types/utilities.d.ts +0 -35
- package/dist/memory/mem0Initializer.d.ts +10 -5
- package/dist/memory/mem0Initializer.js +17 -28
- package/dist/neurolink.d.ts +4 -0
- package/dist/neurolink.js +38 -42
- package/dist/types/conversation.d.ts +3 -6
- package/dist/types/utilities.d.ts +0 -35
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [8.0.1](https://github.com/juspay/neurolink/compare/v8.0.0...v8.0.1) (2025-11-20)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
- **(lint):** prettier and lint errors ([810475c](https://github.com/juspay/neurolink/commit/810475ce5bf997e389b4ee2c769cee0c03da7dfb))
|
|
6
|
+
- **(memory):** migrate to cloud-hosted mem0 API [BZ-45257] ([3a53a0c](https://github.com/juspay/neurolink/commit/3a53a0c792102fe5cd232f8b8c0ac59e73581497))
|
|
7
|
+
|
|
1
8
|
## [8.0.0](https://github.com/juspay/neurolink/compare/v7.54.0...v8.0.0) (2025-11-19)
|
|
2
9
|
|
|
3
10
|
### ⚠ BREAKING CHANGES
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Mem0 Memory Initializer
|
|
3
|
-
* Simple initialization logic for mem0ai
|
|
3
|
+
* Simple initialization logic for mem0ai cloud API integration
|
|
4
4
|
*/
|
|
5
|
-
import
|
|
6
|
-
import type { Mem0Memory } from "../types/utilities.js";
|
|
5
|
+
import { MemoryClient } from "mem0ai";
|
|
7
6
|
/**
|
|
8
|
-
*
|
|
7
|
+
* Mem0 cloud API configuration
|
|
9
8
|
*/
|
|
10
|
-
export
|
|
9
|
+
export interface Mem0Config {
|
|
10
|
+
apiKey: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Initialize mem0 memory instance with cloud API
|
|
14
|
+
*/
|
|
15
|
+
export declare function initializeMem0(mem0Config: Mem0Config): Promise<MemoryClient | null>;
|
|
@@ -1,43 +1,32 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Mem0 Memory Initializer
|
|
3
|
-
* Simple initialization logic for mem0ai
|
|
3
|
+
* Simple initialization logic for mem0ai cloud API integration
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import { MemoryClient } from "mem0ai";
|
|
6
6
|
import { logger } from "../utils/logger.js";
|
|
7
7
|
/**
|
|
8
|
-
* Initialize mem0 memory instance with
|
|
8
|
+
* Initialize mem0 memory instance with cloud API
|
|
9
9
|
*/
|
|
10
10
|
export async function initializeMem0(mem0Config) {
|
|
11
|
-
|
|
11
|
+
// Guard: skip initialization if API key is missing
|
|
12
|
+
if (!mem0Config?.apiKey || mem0Config.apiKey.trim() === "") {
|
|
13
|
+
logger.warn("[mem0Initializer] Missing MEM0_API_KEY; skipping mem0 initialization");
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
logger.debug("[mem0Initializer] Starting mem0 cloud API initialization");
|
|
12
17
|
try {
|
|
13
|
-
// Create
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
// Create MemoryClient instance with cloud API
|
|
19
|
+
const client = new MemoryClient({
|
|
20
|
+
apiKey: mem0Config.apiKey,
|
|
21
|
+
});
|
|
22
|
+
logger.info("[mem0Initializer] Mem0 cloud API initialized successfully");
|
|
23
|
+
return client;
|
|
17
24
|
}
|
|
18
25
|
catch (error) {
|
|
19
|
-
logger.warn("[mem0Initializer] Failed to initialize mem0
|
|
26
|
+
logger.warn("[mem0Initializer] Failed to initialize mem0 cloud API; disabling mem0", {
|
|
20
27
|
error: error instanceof Error ? error.message : String(error),
|
|
21
28
|
});
|
|
22
|
-
return
|
|
29
|
+
return null;
|
|
23
30
|
}
|
|
24
31
|
}
|
|
25
|
-
/**
|
|
26
|
-
* Create fallback memory implementation
|
|
27
|
-
*/
|
|
28
|
-
function createFallbackMemory() {
|
|
29
|
-
return {
|
|
30
|
-
search: async () => ({ results: [] }),
|
|
31
|
-
add: async () => ({ results: [] }),
|
|
32
|
-
get: async () => null,
|
|
33
|
-
update: async () => ({
|
|
34
|
-
message: "Fallback memory does not support updates",
|
|
35
|
-
}),
|
|
36
|
-
delete: async () => ({
|
|
37
|
-
message: "Fallback memory does not support deletion",
|
|
38
|
-
}),
|
|
39
|
-
history: async () => [],
|
|
40
|
-
reset: async () => { },
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
32
|
//# sourceMappingURL=mem0Initializer.js.map
|
package/dist/lib/neurolink.d.ts
CHANGED
|
@@ -134,6 +134,10 @@ export declare class NeuroLink {
|
|
|
134
134
|
private initializeHITL;
|
|
135
135
|
/** Format memory context for prompt inclusion */
|
|
136
136
|
private formatMemoryContext;
|
|
137
|
+
/** Extract memory context from search results */
|
|
138
|
+
private extractMemoryContext;
|
|
139
|
+
/** Store conversation turn in mem0 */
|
|
140
|
+
private storeConversationTurn;
|
|
137
141
|
/**
|
|
138
142
|
* Set up HITL event forwarding to main emitter
|
|
139
143
|
*/
|
package/dist/lib/neurolink.js
CHANGED
|
@@ -45,6 +45,7 @@ import { directToolsServer } from "./mcp/servers/agent/directToolsServer.js";
|
|
|
45
45
|
import { ModelRouter } from "./utils/modelRouter.js";
|
|
46
46
|
import { BinaryTaskClassifier } from "./utils/taskClassifier.js";
|
|
47
47
|
import { initializeOpenTelemetry, shutdownOpenTelemetry, flushOpenTelemetry, getLangfuseHealthStatus, setLangfuseContext, } from "./services/server/ai/observability/instrumentation.js";
|
|
48
|
+
import { initializeMem0 } from "./memory/mem0Initializer.js";
|
|
48
49
|
export class NeuroLink {
|
|
49
50
|
mcpInitialized = false;
|
|
50
51
|
emitter = new EventEmitter();
|
|
@@ -150,8 +151,6 @@ export class NeuroLink {
|
|
|
150
151
|
this.mem0Instance = null;
|
|
151
152
|
return null;
|
|
152
153
|
}
|
|
153
|
-
// Import and initialize from separate file
|
|
154
|
-
const { initializeMem0 } = await import("./memory/mem0Initializer.js");
|
|
155
154
|
if (!this.mem0Config) {
|
|
156
155
|
this.mem0Instance = null;
|
|
157
156
|
return null;
|
|
@@ -390,9 +389,28 @@ export class NeuroLink {
|
|
|
390
389
|
/** Format memory context for prompt inclusion */
|
|
391
390
|
formatMemoryContext(memoryContext, currentInput) {
|
|
392
391
|
return `Context from previous conversations:
|
|
393
|
-
${memoryContext}
|
|
394
392
|
|
|
395
|
-
|
|
393
|
+
${memoryContext}
|
|
394
|
+
|
|
395
|
+
Current user's request: ${currentInput}`;
|
|
396
|
+
}
|
|
397
|
+
/** Extract memory context from search results */
|
|
398
|
+
extractMemoryContext(memories) {
|
|
399
|
+
return memories
|
|
400
|
+
.map((m) => m.memory || "")
|
|
401
|
+
.filter(Boolean)
|
|
402
|
+
.join("\n");
|
|
403
|
+
}
|
|
404
|
+
/** Store conversation turn in mem0 */
|
|
405
|
+
async storeConversationTurn(mem0, userContent, userId, metadata) {
|
|
406
|
+
// Store user message only, reducing latency in mem0
|
|
407
|
+
const conversationTurn = [{ role: "user", content: userContent }];
|
|
408
|
+
await mem0.add(conversationTurn, {
|
|
409
|
+
user_id: userId,
|
|
410
|
+
metadata,
|
|
411
|
+
infer: true,
|
|
412
|
+
async_mode: true,
|
|
413
|
+
});
|
|
396
414
|
}
|
|
397
415
|
/**
|
|
398
416
|
* Set up HITL event forwarding to main emitter
|
|
@@ -1191,14 +1209,12 @@ export class NeuroLink {
|
|
|
1191
1209
|
}
|
|
1192
1210
|
else {
|
|
1193
1211
|
const memories = await mem0.search(options.input.text, {
|
|
1194
|
-
|
|
1212
|
+
user_id: options.context.userId,
|
|
1195
1213
|
limit: 5,
|
|
1196
1214
|
});
|
|
1197
|
-
if (memories
|
|
1215
|
+
if (memories && memories.length > 0) {
|
|
1198
1216
|
// Enhance the input with memory context
|
|
1199
|
-
const memoryContext = memories
|
|
1200
|
-
.map((m) => m.memory)
|
|
1201
|
-
.join("\n");
|
|
1217
|
+
const memoryContext = this.extractMemoryContext(memories);
|
|
1202
1218
|
options.input.text = this.formatMemoryContext(memoryContext, options.input.text);
|
|
1203
1219
|
}
|
|
1204
1220
|
}
|
|
@@ -1350,20 +1366,11 @@ export class NeuroLink {
|
|
|
1350
1366
|
try {
|
|
1351
1367
|
const mem0 = await this.ensureMem0Ready();
|
|
1352
1368
|
if (mem0) {
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
await mem0.add(JSON.stringify(conversationTurn), {
|
|
1359
|
-
userId: options.context?.userId,
|
|
1360
|
-
metadata: {
|
|
1361
|
-
timestamp: new Date().toISOString(),
|
|
1362
|
-
provider: generateResult.provider,
|
|
1363
|
-
model: generateResult.model,
|
|
1364
|
-
type: "conversation_turn",
|
|
1365
|
-
async_mode: true,
|
|
1366
|
-
},
|
|
1369
|
+
await this.storeConversationTurn(mem0, originalPrompt, options.context?.userId, {
|
|
1370
|
+
timestamp: new Date().toISOString(),
|
|
1371
|
+
provider: generateResult.provider,
|
|
1372
|
+
model: generateResult.model,
|
|
1373
|
+
type: "conversation_turn",
|
|
1367
1374
|
});
|
|
1368
1375
|
}
|
|
1369
1376
|
}
|
|
@@ -1920,14 +1927,12 @@ export class NeuroLink {
|
|
|
1920
1927
|
}
|
|
1921
1928
|
else {
|
|
1922
1929
|
const memories = await mem0.search(options.input.text, {
|
|
1923
|
-
|
|
1930
|
+
user_id: options.context.userId,
|
|
1924
1931
|
limit: 5,
|
|
1925
1932
|
});
|
|
1926
|
-
if (memories
|
|
1933
|
+
if (memories && memories.length > 0) {
|
|
1927
1934
|
// Enhance the input with memory context
|
|
1928
|
-
const memoryContext = memories
|
|
1929
|
-
.map((m) => m.memory)
|
|
1930
|
-
.join("\n");
|
|
1935
|
+
const memoryContext = this.extractMemoryContext(memories);
|
|
1931
1936
|
options.input.text = this.formatMemoryContext(memoryContext, options.input.text);
|
|
1932
1937
|
}
|
|
1933
1938
|
}
|
|
@@ -2009,20 +2014,11 @@ export class NeuroLink {
|
|
|
2009
2014
|
try {
|
|
2010
2015
|
const mem0 = await self.ensureMem0Ready();
|
|
2011
2016
|
if (mem0) {
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
await mem0.add(JSON.stringify(conversationTurn), {
|
|
2018
|
-
userId: enhancedOptions.context?.userId,
|
|
2019
|
-
metadata: {
|
|
2020
|
-
timestamp: new Date().toISOString(),
|
|
2021
|
-
type: "conversation_turn_stream",
|
|
2022
|
-
userMessage: originalPrompt,
|
|
2023
|
-
async_mode: true,
|
|
2024
|
-
aiResponse: accumulatedContent.trim(),
|
|
2025
|
-
},
|
|
2017
|
+
await self.storeConversationTurn(mem0, originalPrompt, enhancedOptions.context?.userId, {
|
|
2018
|
+
timestamp: new Date().toISOString(),
|
|
2019
|
+
type: "conversation_turn_stream",
|
|
2020
|
+
userMessage: originalPrompt,
|
|
2021
|
+
aiResponse: accumulatedContent.trim(),
|
|
2026
2022
|
});
|
|
2027
2023
|
}
|
|
2028
2024
|
}
|
|
@@ -2,10 +2,7 @@
|
|
|
2
2
|
* Conversation Memory Types for NeuroLink
|
|
3
3
|
* Provides type-safe conversation storage and context management
|
|
4
4
|
*/
|
|
5
|
-
import type {
|
|
6
|
-
/**
|
|
7
|
-
* Mem0 configuration type matching mem0ai/oss MemoryConfig structure
|
|
8
|
-
*/
|
|
5
|
+
import type { Mem0Config } from "../memory/mem0Initializer.js";
|
|
9
6
|
/**
|
|
10
7
|
* Configuration for conversation memory feature
|
|
11
8
|
*/
|
|
@@ -28,8 +25,8 @@ export type ConversationMemoryConfig = {
|
|
|
28
25
|
summarizationModel?: string;
|
|
29
26
|
/** Enable mem0 integration for conversation memory */
|
|
30
27
|
mem0Enabled?: boolean;
|
|
31
|
-
/** Configuration for mem0 integration */
|
|
32
|
-
mem0Config?:
|
|
28
|
+
/** Configuration for mem0 cloud API integration */
|
|
29
|
+
mem0Config?: Mem0Config;
|
|
33
30
|
/** Redis configuration (optional) - overrides environment variables */
|
|
34
31
|
redisConfig?: RedisStorageConfig;
|
|
35
32
|
};
|
|
@@ -171,38 +171,3 @@ export type EnvVarValidationResult = {
|
|
|
171
171
|
invalidVars: string[];
|
|
172
172
|
warnings: string[];
|
|
173
173
|
};
|
|
174
|
-
/**
|
|
175
|
-
* Interface for mem0 Memory instance methods based on actual mem0ai/oss API
|
|
176
|
-
*/
|
|
177
|
-
export type Mem0Memory = {
|
|
178
|
-
search(query: string, config: {
|
|
179
|
-
userId?: string;
|
|
180
|
-
limit?: number;
|
|
181
|
-
}): Promise<{
|
|
182
|
-
results: Array<{
|
|
183
|
-
memory: string;
|
|
184
|
-
id: string;
|
|
185
|
-
}>;
|
|
186
|
-
}>;
|
|
187
|
-
add(messages: string, config: {
|
|
188
|
-
userId?: string;
|
|
189
|
-
metadata?: Record<string, unknown>;
|
|
190
|
-
}): Promise<{
|
|
191
|
-
results: Array<{
|
|
192
|
-
id: string;
|
|
193
|
-
memory: string;
|
|
194
|
-
}>;
|
|
195
|
-
}>;
|
|
196
|
-
get(memoryId: string): Promise<{
|
|
197
|
-
id: string;
|
|
198
|
-
memory: string;
|
|
199
|
-
} | null>;
|
|
200
|
-
update(memoryId: string, data: string): Promise<{
|
|
201
|
-
message: string;
|
|
202
|
-
}>;
|
|
203
|
-
delete(memoryId: string): Promise<{
|
|
204
|
-
message: string;
|
|
205
|
-
}>;
|
|
206
|
-
history(memoryId: string): Promise<unknown[]>;
|
|
207
|
-
reset(): Promise<void>;
|
|
208
|
-
};
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Mem0 Memory Initializer
|
|
3
|
-
* Simple initialization logic for mem0ai
|
|
3
|
+
* Simple initialization logic for mem0ai cloud API integration
|
|
4
4
|
*/
|
|
5
|
-
import
|
|
6
|
-
import type { Mem0Memory } from "../types/utilities.js";
|
|
5
|
+
import { MemoryClient } from "mem0ai";
|
|
7
6
|
/**
|
|
8
|
-
*
|
|
7
|
+
* Mem0 cloud API configuration
|
|
9
8
|
*/
|
|
10
|
-
export
|
|
9
|
+
export interface Mem0Config {
|
|
10
|
+
apiKey: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Initialize mem0 memory instance with cloud API
|
|
14
|
+
*/
|
|
15
|
+
export declare function initializeMem0(mem0Config: Mem0Config): Promise<MemoryClient | null>;
|
|
@@ -1,42 +1,31 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Mem0 Memory Initializer
|
|
3
|
-
* Simple initialization logic for mem0ai
|
|
3
|
+
* Simple initialization logic for mem0ai cloud API integration
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import { MemoryClient } from "mem0ai";
|
|
6
6
|
import { logger } from "../utils/logger.js";
|
|
7
7
|
/**
|
|
8
|
-
* Initialize mem0 memory instance with
|
|
8
|
+
* Initialize mem0 memory instance with cloud API
|
|
9
9
|
*/
|
|
10
10
|
export async function initializeMem0(mem0Config) {
|
|
11
|
-
|
|
11
|
+
// Guard: skip initialization if API key is missing
|
|
12
|
+
if (!mem0Config?.apiKey || mem0Config.apiKey.trim() === "") {
|
|
13
|
+
logger.warn("[mem0Initializer] Missing MEM0_API_KEY; skipping mem0 initialization");
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
logger.debug("[mem0Initializer] Starting mem0 cloud API initialization");
|
|
12
17
|
try {
|
|
13
|
-
// Create
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
// Create MemoryClient instance with cloud API
|
|
19
|
+
const client = new MemoryClient({
|
|
20
|
+
apiKey: mem0Config.apiKey,
|
|
21
|
+
});
|
|
22
|
+
logger.info("[mem0Initializer] Mem0 cloud API initialized successfully");
|
|
23
|
+
return client;
|
|
17
24
|
}
|
|
18
25
|
catch (error) {
|
|
19
|
-
logger.warn("[mem0Initializer] Failed to initialize mem0
|
|
26
|
+
logger.warn("[mem0Initializer] Failed to initialize mem0 cloud API; disabling mem0", {
|
|
20
27
|
error: error instanceof Error ? error.message : String(error),
|
|
21
28
|
});
|
|
22
|
-
return
|
|
29
|
+
return null;
|
|
23
30
|
}
|
|
24
31
|
}
|
|
25
|
-
/**
|
|
26
|
-
* Create fallback memory implementation
|
|
27
|
-
*/
|
|
28
|
-
function createFallbackMemory() {
|
|
29
|
-
return {
|
|
30
|
-
search: async () => ({ results: [] }),
|
|
31
|
-
add: async () => ({ results: [] }),
|
|
32
|
-
get: async () => null,
|
|
33
|
-
update: async () => ({
|
|
34
|
-
message: "Fallback memory does not support updates",
|
|
35
|
-
}),
|
|
36
|
-
delete: async () => ({
|
|
37
|
-
message: "Fallback memory does not support deletion",
|
|
38
|
-
}),
|
|
39
|
-
history: async () => [],
|
|
40
|
-
reset: async () => { },
|
|
41
|
-
};
|
|
42
|
-
}
|
package/dist/neurolink.d.ts
CHANGED
|
@@ -134,6 +134,10 @@ export declare class NeuroLink {
|
|
|
134
134
|
private initializeHITL;
|
|
135
135
|
/** Format memory context for prompt inclusion */
|
|
136
136
|
private formatMemoryContext;
|
|
137
|
+
/** Extract memory context from search results */
|
|
138
|
+
private extractMemoryContext;
|
|
139
|
+
/** Store conversation turn in mem0 */
|
|
140
|
+
private storeConversationTurn;
|
|
137
141
|
/**
|
|
138
142
|
* Set up HITL event forwarding to main emitter
|
|
139
143
|
*/
|
package/dist/neurolink.js
CHANGED
|
@@ -45,6 +45,7 @@ import { directToolsServer } from "./mcp/servers/agent/directToolsServer.js";
|
|
|
45
45
|
import { ModelRouter } from "./utils/modelRouter.js";
|
|
46
46
|
import { BinaryTaskClassifier } from "./utils/taskClassifier.js";
|
|
47
47
|
import { initializeOpenTelemetry, shutdownOpenTelemetry, flushOpenTelemetry, getLangfuseHealthStatus, setLangfuseContext, } from "./services/server/ai/observability/instrumentation.js";
|
|
48
|
+
import { initializeMem0 } from "./memory/mem0Initializer.js";
|
|
48
49
|
export class NeuroLink {
|
|
49
50
|
mcpInitialized = false;
|
|
50
51
|
emitter = new EventEmitter();
|
|
@@ -150,8 +151,6 @@ export class NeuroLink {
|
|
|
150
151
|
this.mem0Instance = null;
|
|
151
152
|
return null;
|
|
152
153
|
}
|
|
153
|
-
// Import and initialize from separate file
|
|
154
|
-
const { initializeMem0 } = await import("./memory/mem0Initializer.js");
|
|
155
154
|
if (!this.mem0Config) {
|
|
156
155
|
this.mem0Instance = null;
|
|
157
156
|
return null;
|
|
@@ -390,9 +389,28 @@ export class NeuroLink {
|
|
|
390
389
|
/** Format memory context for prompt inclusion */
|
|
391
390
|
formatMemoryContext(memoryContext, currentInput) {
|
|
392
391
|
return `Context from previous conversations:
|
|
393
|
-
${memoryContext}
|
|
394
392
|
|
|
395
|
-
|
|
393
|
+
${memoryContext}
|
|
394
|
+
|
|
395
|
+
Current user's request: ${currentInput}`;
|
|
396
|
+
}
|
|
397
|
+
/** Extract memory context from search results */
|
|
398
|
+
extractMemoryContext(memories) {
|
|
399
|
+
return memories
|
|
400
|
+
.map((m) => m.memory || "")
|
|
401
|
+
.filter(Boolean)
|
|
402
|
+
.join("\n");
|
|
403
|
+
}
|
|
404
|
+
/** Store conversation turn in mem0 */
|
|
405
|
+
async storeConversationTurn(mem0, userContent, userId, metadata) {
|
|
406
|
+
// Store user message only, reducing latency in mem0
|
|
407
|
+
const conversationTurn = [{ role: "user", content: userContent }];
|
|
408
|
+
await mem0.add(conversationTurn, {
|
|
409
|
+
user_id: userId,
|
|
410
|
+
metadata,
|
|
411
|
+
infer: true,
|
|
412
|
+
async_mode: true,
|
|
413
|
+
});
|
|
396
414
|
}
|
|
397
415
|
/**
|
|
398
416
|
* Set up HITL event forwarding to main emitter
|
|
@@ -1191,14 +1209,12 @@ export class NeuroLink {
|
|
|
1191
1209
|
}
|
|
1192
1210
|
else {
|
|
1193
1211
|
const memories = await mem0.search(options.input.text, {
|
|
1194
|
-
|
|
1212
|
+
user_id: options.context.userId,
|
|
1195
1213
|
limit: 5,
|
|
1196
1214
|
});
|
|
1197
|
-
if (memories
|
|
1215
|
+
if (memories && memories.length > 0) {
|
|
1198
1216
|
// Enhance the input with memory context
|
|
1199
|
-
const memoryContext = memories
|
|
1200
|
-
.map((m) => m.memory)
|
|
1201
|
-
.join("\n");
|
|
1217
|
+
const memoryContext = this.extractMemoryContext(memories);
|
|
1202
1218
|
options.input.text = this.formatMemoryContext(memoryContext, options.input.text);
|
|
1203
1219
|
}
|
|
1204
1220
|
}
|
|
@@ -1350,20 +1366,11 @@ export class NeuroLink {
|
|
|
1350
1366
|
try {
|
|
1351
1367
|
const mem0 = await this.ensureMem0Ready();
|
|
1352
1368
|
if (mem0) {
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
await mem0.add(JSON.stringify(conversationTurn), {
|
|
1359
|
-
userId: options.context?.userId,
|
|
1360
|
-
metadata: {
|
|
1361
|
-
timestamp: new Date().toISOString(),
|
|
1362
|
-
provider: generateResult.provider,
|
|
1363
|
-
model: generateResult.model,
|
|
1364
|
-
type: "conversation_turn",
|
|
1365
|
-
async_mode: true,
|
|
1366
|
-
},
|
|
1369
|
+
await this.storeConversationTurn(mem0, originalPrompt, options.context?.userId, {
|
|
1370
|
+
timestamp: new Date().toISOString(),
|
|
1371
|
+
provider: generateResult.provider,
|
|
1372
|
+
model: generateResult.model,
|
|
1373
|
+
type: "conversation_turn",
|
|
1367
1374
|
});
|
|
1368
1375
|
}
|
|
1369
1376
|
}
|
|
@@ -1920,14 +1927,12 @@ export class NeuroLink {
|
|
|
1920
1927
|
}
|
|
1921
1928
|
else {
|
|
1922
1929
|
const memories = await mem0.search(options.input.text, {
|
|
1923
|
-
|
|
1930
|
+
user_id: options.context.userId,
|
|
1924
1931
|
limit: 5,
|
|
1925
1932
|
});
|
|
1926
|
-
if (memories
|
|
1933
|
+
if (memories && memories.length > 0) {
|
|
1927
1934
|
// Enhance the input with memory context
|
|
1928
|
-
const memoryContext = memories
|
|
1929
|
-
.map((m) => m.memory)
|
|
1930
|
-
.join("\n");
|
|
1935
|
+
const memoryContext = this.extractMemoryContext(memories);
|
|
1931
1936
|
options.input.text = this.formatMemoryContext(memoryContext, options.input.text);
|
|
1932
1937
|
}
|
|
1933
1938
|
}
|
|
@@ -2009,20 +2014,11 @@ export class NeuroLink {
|
|
|
2009
2014
|
try {
|
|
2010
2015
|
const mem0 = await self.ensureMem0Ready();
|
|
2011
2016
|
if (mem0) {
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
await mem0.add(JSON.stringify(conversationTurn), {
|
|
2018
|
-
userId: enhancedOptions.context?.userId,
|
|
2019
|
-
metadata: {
|
|
2020
|
-
timestamp: new Date().toISOString(),
|
|
2021
|
-
type: "conversation_turn_stream",
|
|
2022
|
-
userMessage: originalPrompt,
|
|
2023
|
-
async_mode: true,
|
|
2024
|
-
aiResponse: accumulatedContent.trim(),
|
|
2025
|
-
},
|
|
2017
|
+
await self.storeConversationTurn(mem0, originalPrompt, enhancedOptions.context?.userId, {
|
|
2018
|
+
timestamp: new Date().toISOString(),
|
|
2019
|
+
type: "conversation_turn_stream",
|
|
2020
|
+
userMessage: originalPrompt,
|
|
2021
|
+
aiResponse: accumulatedContent.trim(),
|
|
2026
2022
|
});
|
|
2027
2023
|
}
|
|
2028
2024
|
}
|
|
@@ -2,10 +2,7 @@
|
|
|
2
2
|
* Conversation Memory Types for NeuroLink
|
|
3
3
|
* Provides type-safe conversation storage and context management
|
|
4
4
|
*/
|
|
5
|
-
import type {
|
|
6
|
-
/**
|
|
7
|
-
* Mem0 configuration type matching mem0ai/oss MemoryConfig structure
|
|
8
|
-
*/
|
|
5
|
+
import type { Mem0Config } from "../memory/mem0Initializer.js";
|
|
9
6
|
/**
|
|
10
7
|
* Configuration for conversation memory feature
|
|
11
8
|
*/
|
|
@@ -28,8 +25,8 @@ export type ConversationMemoryConfig = {
|
|
|
28
25
|
summarizationModel?: string;
|
|
29
26
|
/** Enable mem0 integration for conversation memory */
|
|
30
27
|
mem0Enabled?: boolean;
|
|
31
|
-
/** Configuration for mem0 integration */
|
|
32
|
-
mem0Config?:
|
|
28
|
+
/** Configuration for mem0 cloud API integration */
|
|
29
|
+
mem0Config?: Mem0Config;
|
|
33
30
|
/** Redis configuration (optional) - overrides environment variables */
|
|
34
31
|
redisConfig?: RedisStorageConfig;
|
|
35
32
|
};
|
|
@@ -171,38 +171,3 @@ export type EnvVarValidationResult = {
|
|
|
171
171
|
invalidVars: string[];
|
|
172
172
|
warnings: string[];
|
|
173
173
|
};
|
|
174
|
-
/**
|
|
175
|
-
* Interface for mem0 Memory instance methods based on actual mem0ai/oss API
|
|
176
|
-
*/
|
|
177
|
-
export type Mem0Memory = {
|
|
178
|
-
search(query: string, config: {
|
|
179
|
-
userId?: string;
|
|
180
|
-
limit?: number;
|
|
181
|
-
}): Promise<{
|
|
182
|
-
results: Array<{
|
|
183
|
-
memory: string;
|
|
184
|
-
id: string;
|
|
185
|
-
}>;
|
|
186
|
-
}>;
|
|
187
|
-
add(messages: string, config: {
|
|
188
|
-
userId?: string;
|
|
189
|
-
metadata?: Record<string, unknown>;
|
|
190
|
-
}): Promise<{
|
|
191
|
-
results: Array<{
|
|
192
|
-
id: string;
|
|
193
|
-
memory: string;
|
|
194
|
-
}>;
|
|
195
|
-
}>;
|
|
196
|
-
get(memoryId: string): Promise<{
|
|
197
|
-
id: string;
|
|
198
|
-
memory: string;
|
|
199
|
-
} | null>;
|
|
200
|
-
update(memoryId: string, data: string): Promise<{
|
|
201
|
-
message: string;
|
|
202
|
-
}>;
|
|
203
|
-
delete(memoryId: string): Promise<{
|
|
204
|
-
message: string;
|
|
205
|
-
}>;
|
|
206
|
-
history(memoryId: string): Promise<unknown[]>;
|
|
207
|
-
reset(): Promise<void>;
|
|
208
|
-
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juspay/neurolink",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.1",
|
|
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",
|
|
@@ -293,7 +293,8 @@
|
|
|
293
293
|
"cookie@<0.7.0": ">=0.7.0",
|
|
294
294
|
"@eslint/plugin-kit@<0.3.4": ">=0.3.4",
|
|
295
295
|
"tmp@<=0.2.3": ">=0.2.4",
|
|
296
|
-
"axios@<1.8.2": ">=1.8.2"
|
|
296
|
+
"axios@<1.8.2": ">=1.8.2",
|
|
297
|
+
"glob@>=10.3.7 <=11.0.3": ">=11.1.0"
|
|
297
298
|
}
|
|
298
299
|
},
|
|
299
300
|
"os": [
|