@juspay/neurolink 8.4.0 → 8.4.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 +6 -0
- package/dist/lib/memory/mem0Initializer.d.ts +32 -1
- package/dist/lib/memory/mem0Initializer.js +55 -2
- package/dist/lib/neurolink.d.ts +1 -1
- package/dist/lib/neurolink.js +8 -7
- package/dist/memory/mem0Initializer.d.ts +32 -1
- package/dist/memory/mem0Initializer.js +55 -2
- package/dist/neurolink.d.ts +1 -1
- package/dist/neurolink.js +8 -7
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
## [8.4.1](https://github.com/juspay/neurolink/compare/v8.4.0...v8.4.1) (2025-12-04)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
- **(mem0):** custom instructions support for mem0 conversation ingestion ([486c55c](https://github.com/juspay/neurolink/commit/486c55c64eeaecf6704aea7a7bf5310270476be5))
|
|
6
|
+
|
|
1
7
|
## [8.4.0](https://github.com/juspay/neurolink/compare/v8.3.0...v8.4.0) (2025-12-01)
|
|
2
8
|
|
|
3
9
|
### Features
|
|
@@ -8,8 +8,39 @@ import { MemoryClient } from "mem0ai";
|
|
|
8
8
|
*/
|
|
9
9
|
export interface Mem0Config {
|
|
10
10
|
apiKey: string;
|
|
11
|
+
/**
|
|
12
|
+
* Optional organization ID - if not provided, will be auto-populated from ping() response
|
|
13
|
+
*/
|
|
14
|
+
organizationId?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Optional project ID - if not provided, will be auto-populated from ping() response
|
|
17
|
+
*/
|
|
18
|
+
projectId?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Whether to update project-level custom instructions during initialization
|
|
21
|
+
* Default: false (don't update project settings)
|
|
22
|
+
*
|
|
23
|
+
* Note: organizationId and projectId are NOT required - they will be auto-populated
|
|
24
|
+
* from the mem0 API via ping() if not provided
|
|
25
|
+
*/
|
|
26
|
+
updateProjectSettings?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Custom instructions and categories for mem0 extraction behavior
|
|
29
|
+
* Only used if updateProjectSettings is true
|
|
30
|
+
*/
|
|
31
|
+
customPrompts?: {
|
|
32
|
+
/**
|
|
33
|
+
* Custom instructions for how mem0 should extract and store memories
|
|
34
|
+
* This applies to ALL memories added to the project
|
|
35
|
+
*/
|
|
36
|
+
custom_instructions?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Custom categories for organizing memories
|
|
39
|
+
*/
|
|
40
|
+
custom_categories?: Array<Record<string, unknown>>;
|
|
41
|
+
};
|
|
11
42
|
}
|
|
12
43
|
/**
|
|
13
|
-
* Initialize mem0 memory instance with cloud API
|
|
44
|
+
* Initialize mem0 memory instance with cloud API and optional project settings
|
|
14
45
|
*/
|
|
15
46
|
export declare function initializeMem0(mem0Config: Mem0Config): Promise<MemoryClient | null>;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { MemoryClient } from "mem0ai";
|
|
6
6
|
import { logger } from "../utils/logger.js";
|
|
7
7
|
/**
|
|
8
|
-
* Initialize mem0 memory instance with cloud API
|
|
8
|
+
* Initialize mem0 memory instance with cloud API and optional project settings
|
|
9
9
|
*/
|
|
10
10
|
export async function initializeMem0(mem0Config) {
|
|
11
11
|
// Guard: skip initialization if API key is missing
|
|
@@ -18,8 +18,61 @@ export async function initializeMem0(mem0Config) {
|
|
|
18
18
|
// Create MemoryClient instance with cloud API
|
|
19
19
|
const client = new MemoryClient({
|
|
20
20
|
apiKey: mem0Config.apiKey,
|
|
21
|
+
organizationId: mem0Config.organizationId,
|
|
22
|
+
projectId: mem0Config.projectId,
|
|
23
|
+
});
|
|
24
|
+
// Track whether project settings were actually updated (not just requested)
|
|
25
|
+
let projectSettingsUpdated = false;
|
|
26
|
+
// Update project-level settings if requested
|
|
27
|
+
if (mem0Config.updateProjectSettings && mem0Config.customPrompts) {
|
|
28
|
+
// Build update payload - only include fields that are actually provided
|
|
29
|
+
const updatePayload = {};
|
|
30
|
+
if (mem0Config.customPrompts.custom_instructions &&
|
|
31
|
+
mem0Config.customPrompts.custom_instructions.trim() !== "") {
|
|
32
|
+
updatePayload.custom_instructions =
|
|
33
|
+
mem0Config.customPrompts.custom_instructions;
|
|
34
|
+
}
|
|
35
|
+
if (Array.isArray(mem0Config.customPrompts.custom_categories) &&
|
|
36
|
+
mem0Config.customPrompts.custom_categories.length > 0) {
|
|
37
|
+
updatePayload.custom_categories =
|
|
38
|
+
mem0Config.customPrompts.custom_categories;
|
|
39
|
+
}
|
|
40
|
+
// Only proceed if there's something to update
|
|
41
|
+
if (Object.keys(updatePayload).length > 0) {
|
|
42
|
+
try {
|
|
43
|
+
// Note: updateProject() internally calls ping() first, which auto-populates
|
|
44
|
+
// organizationId and projectId from the server, so they're not required
|
|
45
|
+
await client.updateProject(updatePayload);
|
|
46
|
+
projectSettingsUpdated = true; // Only set to true on successful update
|
|
47
|
+
logger.info("[mem0Initializer] Project settings updated successfully", {
|
|
48
|
+
hasInstructions: !!updatePayload.custom_instructions,
|
|
49
|
+
hasCategories: !!updatePayload.custom_categories,
|
|
50
|
+
// Note: These IDs are auto-populated by ping() inside updateProject()
|
|
51
|
+
organizationId: client.organizationId,
|
|
52
|
+
projectId: client.projectId,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
logger.warn("[mem0Initializer] Failed to update project settings", {
|
|
57
|
+
error: error instanceof Error ? error.message : String(error),
|
|
58
|
+
hint: "Ensure your MEM0_API_KEY has permission to update project settings",
|
|
59
|
+
});
|
|
60
|
+
// Continue initialization even if project update fails
|
|
61
|
+
// projectSettingsUpdated remains false
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
logger.warn("[mem0Initializer] updateProjectSettings=true but no custom instructions or categories provided - nothing to update");
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
else if (mem0Config.updateProjectSettings && !mem0Config.customPrompts) {
|
|
69
|
+
logger.warn("[mem0Initializer] updateProjectSettings=true but customPrompts not provided - nothing to update");
|
|
70
|
+
}
|
|
71
|
+
logger.info("[mem0Initializer] Mem0 cloud API initialized successfully", {
|
|
72
|
+
hasOrgId: !!client.organizationId,
|
|
73
|
+
hasProjectId: !!client.projectId,
|
|
74
|
+
projectSettingsUpdated,
|
|
21
75
|
});
|
|
22
|
-
logger.info("[mem0Initializer] Mem0 cloud API initialized successfully");
|
|
23
76
|
return client;
|
|
24
77
|
}
|
|
25
78
|
catch (error) {
|
package/dist/lib/neurolink.d.ts
CHANGED
|
@@ -137,7 +137,7 @@ export declare class NeuroLink {
|
|
|
137
137
|
/** Extract memory context from search results */
|
|
138
138
|
private extractMemoryContext;
|
|
139
139
|
/** Store conversation turn in mem0 */
|
|
140
|
-
private
|
|
140
|
+
private storeMem0ConversationTurn;
|
|
141
141
|
/**
|
|
142
142
|
* Set up HITL event forwarding to main emitter
|
|
143
143
|
*/
|
package/dist/lib/neurolink.js
CHANGED
|
@@ -402,9 +402,12 @@ Current user's request: ${currentInput}`;
|
|
|
402
402
|
.join("\n");
|
|
403
403
|
}
|
|
404
404
|
/** Store conversation turn in mem0 */
|
|
405
|
-
async
|
|
406
|
-
// Store user message
|
|
407
|
-
const conversationTurn = [
|
|
405
|
+
async storeMem0ConversationTurn(mem0, userContent, aiResponse, userId, metadata) {
|
|
406
|
+
// Store both user message and AI response for better context extraction
|
|
407
|
+
const conversationTurn = [
|
|
408
|
+
{ role: "user", content: userContent },
|
|
409
|
+
{ role: "assistant", content: aiResponse },
|
|
410
|
+
];
|
|
408
411
|
await mem0.add(conversationTurn, {
|
|
409
412
|
user_id: userId,
|
|
410
413
|
metadata,
|
|
@@ -1366,7 +1369,7 @@ Current user's request: ${currentInput}`;
|
|
|
1366
1369
|
try {
|
|
1367
1370
|
const mem0 = await this.ensureMem0Ready();
|
|
1368
1371
|
if (mem0) {
|
|
1369
|
-
await this.
|
|
1372
|
+
await this.storeMem0ConversationTurn(mem0, originalPrompt, generateResult.content, options.context?.userId, {
|
|
1370
1373
|
timestamp: new Date().toISOString(),
|
|
1371
1374
|
provider: generateResult.provider,
|
|
1372
1375
|
model: generateResult.model,
|
|
@@ -2037,11 +2040,9 @@ Current user's request: ${currentInput}`;
|
|
|
2037
2040
|
try {
|
|
2038
2041
|
const mem0 = await self.ensureMem0Ready();
|
|
2039
2042
|
if (mem0) {
|
|
2040
|
-
await self.
|
|
2043
|
+
await self.storeMem0ConversationTurn(mem0, originalPrompt, accumulatedContent.trim(), enhancedOptions.context?.userId, {
|
|
2041
2044
|
timestamp: new Date().toISOString(),
|
|
2042
2045
|
type: "conversation_turn_stream",
|
|
2043
|
-
userMessage: originalPrompt,
|
|
2044
|
-
aiResponse: accumulatedContent.trim(),
|
|
2045
2046
|
});
|
|
2046
2047
|
}
|
|
2047
2048
|
}
|
|
@@ -8,8 +8,39 @@ import { MemoryClient } from "mem0ai";
|
|
|
8
8
|
*/
|
|
9
9
|
export interface Mem0Config {
|
|
10
10
|
apiKey: string;
|
|
11
|
+
/**
|
|
12
|
+
* Optional organization ID - if not provided, will be auto-populated from ping() response
|
|
13
|
+
*/
|
|
14
|
+
organizationId?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Optional project ID - if not provided, will be auto-populated from ping() response
|
|
17
|
+
*/
|
|
18
|
+
projectId?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Whether to update project-level custom instructions during initialization
|
|
21
|
+
* Default: false (don't update project settings)
|
|
22
|
+
*
|
|
23
|
+
* Note: organizationId and projectId are NOT required - they will be auto-populated
|
|
24
|
+
* from the mem0 API via ping() if not provided
|
|
25
|
+
*/
|
|
26
|
+
updateProjectSettings?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Custom instructions and categories for mem0 extraction behavior
|
|
29
|
+
* Only used if updateProjectSettings is true
|
|
30
|
+
*/
|
|
31
|
+
customPrompts?: {
|
|
32
|
+
/**
|
|
33
|
+
* Custom instructions for how mem0 should extract and store memories
|
|
34
|
+
* This applies to ALL memories added to the project
|
|
35
|
+
*/
|
|
36
|
+
custom_instructions?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Custom categories for organizing memories
|
|
39
|
+
*/
|
|
40
|
+
custom_categories?: Array<Record<string, unknown>>;
|
|
41
|
+
};
|
|
11
42
|
}
|
|
12
43
|
/**
|
|
13
|
-
* Initialize mem0 memory instance with cloud API
|
|
44
|
+
* Initialize mem0 memory instance with cloud API and optional project settings
|
|
14
45
|
*/
|
|
15
46
|
export declare function initializeMem0(mem0Config: Mem0Config): Promise<MemoryClient | null>;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { MemoryClient } from "mem0ai";
|
|
6
6
|
import { logger } from "../utils/logger.js";
|
|
7
7
|
/**
|
|
8
|
-
* Initialize mem0 memory instance with cloud API
|
|
8
|
+
* Initialize mem0 memory instance with cloud API and optional project settings
|
|
9
9
|
*/
|
|
10
10
|
export async function initializeMem0(mem0Config) {
|
|
11
11
|
// Guard: skip initialization if API key is missing
|
|
@@ -18,8 +18,61 @@ export async function initializeMem0(mem0Config) {
|
|
|
18
18
|
// Create MemoryClient instance with cloud API
|
|
19
19
|
const client = new MemoryClient({
|
|
20
20
|
apiKey: mem0Config.apiKey,
|
|
21
|
+
organizationId: mem0Config.organizationId,
|
|
22
|
+
projectId: mem0Config.projectId,
|
|
23
|
+
});
|
|
24
|
+
// Track whether project settings were actually updated (not just requested)
|
|
25
|
+
let projectSettingsUpdated = false;
|
|
26
|
+
// Update project-level settings if requested
|
|
27
|
+
if (mem0Config.updateProjectSettings && mem0Config.customPrompts) {
|
|
28
|
+
// Build update payload - only include fields that are actually provided
|
|
29
|
+
const updatePayload = {};
|
|
30
|
+
if (mem0Config.customPrompts.custom_instructions &&
|
|
31
|
+
mem0Config.customPrompts.custom_instructions.trim() !== "") {
|
|
32
|
+
updatePayload.custom_instructions =
|
|
33
|
+
mem0Config.customPrompts.custom_instructions;
|
|
34
|
+
}
|
|
35
|
+
if (Array.isArray(mem0Config.customPrompts.custom_categories) &&
|
|
36
|
+
mem0Config.customPrompts.custom_categories.length > 0) {
|
|
37
|
+
updatePayload.custom_categories =
|
|
38
|
+
mem0Config.customPrompts.custom_categories;
|
|
39
|
+
}
|
|
40
|
+
// Only proceed if there's something to update
|
|
41
|
+
if (Object.keys(updatePayload).length > 0) {
|
|
42
|
+
try {
|
|
43
|
+
// Note: updateProject() internally calls ping() first, which auto-populates
|
|
44
|
+
// organizationId and projectId from the server, so they're not required
|
|
45
|
+
await client.updateProject(updatePayload);
|
|
46
|
+
projectSettingsUpdated = true; // Only set to true on successful update
|
|
47
|
+
logger.info("[mem0Initializer] Project settings updated successfully", {
|
|
48
|
+
hasInstructions: !!updatePayload.custom_instructions,
|
|
49
|
+
hasCategories: !!updatePayload.custom_categories,
|
|
50
|
+
// Note: These IDs are auto-populated by ping() inside updateProject()
|
|
51
|
+
organizationId: client.organizationId,
|
|
52
|
+
projectId: client.projectId,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
logger.warn("[mem0Initializer] Failed to update project settings", {
|
|
57
|
+
error: error instanceof Error ? error.message : String(error),
|
|
58
|
+
hint: "Ensure your MEM0_API_KEY has permission to update project settings",
|
|
59
|
+
});
|
|
60
|
+
// Continue initialization even if project update fails
|
|
61
|
+
// projectSettingsUpdated remains false
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
logger.warn("[mem0Initializer] updateProjectSettings=true but no custom instructions or categories provided - nothing to update");
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
else if (mem0Config.updateProjectSettings && !mem0Config.customPrompts) {
|
|
69
|
+
logger.warn("[mem0Initializer] updateProjectSettings=true but customPrompts not provided - nothing to update");
|
|
70
|
+
}
|
|
71
|
+
logger.info("[mem0Initializer] Mem0 cloud API initialized successfully", {
|
|
72
|
+
hasOrgId: !!client.organizationId,
|
|
73
|
+
hasProjectId: !!client.projectId,
|
|
74
|
+
projectSettingsUpdated,
|
|
21
75
|
});
|
|
22
|
-
logger.info("[mem0Initializer] Mem0 cloud API initialized successfully");
|
|
23
76
|
return client;
|
|
24
77
|
}
|
|
25
78
|
catch (error) {
|
package/dist/neurolink.d.ts
CHANGED
|
@@ -137,7 +137,7 @@ export declare class NeuroLink {
|
|
|
137
137
|
/** Extract memory context from search results */
|
|
138
138
|
private extractMemoryContext;
|
|
139
139
|
/** Store conversation turn in mem0 */
|
|
140
|
-
private
|
|
140
|
+
private storeMem0ConversationTurn;
|
|
141
141
|
/**
|
|
142
142
|
* Set up HITL event forwarding to main emitter
|
|
143
143
|
*/
|
package/dist/neurolink.js
CHANGED
|
@@ -402,9 +402,12 @@ Current user's request: ${currentInput}`;
|
|
|
402
402
|
.join("\n");
|
|
403
403
|
}
|
|
404
404
|
/** Store conversation turn in mem0 */
|
|
405
|
-
async
|
|
406
|
-
// Store user message
|
|
407
|
-
const conversationTurn = [
|
|
405
|
+
async storeMem0ConversationTurn(mem0, userContent, aiResponse, userId, metadata) {
|
|
406
|
+
// Store both user message and AI response for better context extraction
|
|
407
|
+
const conversationTurn = [
|
|
408
|
+
{ role: "user", content: userContent },
|
|
409
|
+
{ role: "assistant", content: aiResponse },
|
|
410
|
+
];
|
|
408
411
|
await mem0.add(conversationTurn, {
|
|
409
412
|
user_id: userId,
|
|
410
413
|
metadata,
|
|
@@ -1366,7 +1369,7 @@ Current user's request: ${currentInput}`;
|
|
|
1366
1369
|
try {
|
|
1367
1370
|
const mem0 = await this.ensureMem0Ready();
|
|
1368
1371
|
if (mem0) {
|
|
1369
|
-
await this.
|
|
1372
|
+
await this.storeMem0ConversationTurn(mem0, originalPrompt, generateResult.content, options.context?.userId, {
|
|
1370
1373
|
timestamp: new Date().toISOString(),
|
|
1371
1374
|
provider: generateResult.provider,
|
|
1372
1375
|
model: generateResult.model,
|
|
@@ -2037,11 +2040,9 @@ Current user's request: ${currentInput}`;
|
|
|
2037
2040
|
try {
|
|
2038
2041
|
const mem0 = await self.ensureMem0Ready();
|
|
2039
2042
|
if (mem0) {
|
|
2040
|
-
await self.
|
|
2043
|
+
await self.storeMem0ConversationTurn(mem0, originalPrompt, accumulatedContent.trim(), enhancedOptions.context?.userId, {
|
|
2041
2044
|
timestamp: new Date().toISOString(),
|
|
2042
2045
|
type: "conversation_turn_stream",
|
|
2043
|
-
userMessage: originalPrompt,
|
|
2044
|
-
aiResponse: accumulatedContent.trim(),
|
|
2045
2046
|
});
|
|
2046
2047
|
}
|
|
2047
2048
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juspay/neurolink",
|
|
3
|
-
"version": "8.4.
|
|
3
|
+
"version": "8.4.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",
|