@positronic/mem0 0.0.68 → 0.0.70
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/dist/src/adapter.js +22 -4
- package/dist/src/helpers.js +3 -5
- package/dist/src/tools.js +4 -9
- package/dist/types/adapter.d.ts.map +1 -1
- package/dist/types/helpers.d.ts +1 -2
- package/dist/types/helpers.d.ts.map +1 -1
- package/dist/types/tools.d.ts +2 -8
- package/dist/types/tools.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/src/adapter.js
CHANGED
|
@@ -151,16 +151,33 @@ import { BRAIN_EVENTS } from '@positronic/core';
|
|
|
151
151
|
return {
|
|
152
152
|
dispatch: function dispatch(event) {
|
|
153
153
|
return _async_to_generator(function() {
|
|
154
|
-
var brainRunId, agentId, buffer, buffer1, buffer2, buffer3, buffer4;
|
|
154
|
+
var brainRunId, startEvent, existing, agentId, existing1, buffer, buffer1, buffer2, buffer3, buffer4;
|
|
155
155
|
return _ts_generator(this, function(_state) {
|
|
156
156
|
switch(_state.label){
|
|
157
157
|
case 0:
|
|
158
158
|
brainRunId = event.brainRunId;
|
|
159
|
+
// Handle START - capture currentUser for later use in scope
|
|
160
|
+
if (event.type === BRAIN_EVENTS.START) {
|
|
161
|
+
startEvent = event;
|
|
162
|
+
existing = buffers.get(brainRunId);
|
|
163
|
+
if (existing) {
|
|
164
|
+
existing.userId = startEvent.currentUser.id;
|
|
165
|
+
} else {
|
|
166
|
+
buffers.set(brainRunId, {
|
|
167
|
+
agentId: '',
|
|
168
|
+
userId: startEvent.currentUser.id,
|
|
169
|
+
messages: []
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
}
|
|
159
173
|
// Handle AGENT_START - initialize buffer for this run
|
|
160
174
|
if (event.type === BRAIN_EVENTS.AGENT_START) {
|
|
161
175
|
agentId = event.stepTitle; // Use step title as agentId
|
|
162
|
-
// Initialize
|
|
163
|
-
|
|
176
|
+
// Initialize or update buffer
|
|
177
|
+
existing1 = buffers.get(brainRunId);
|
|
178
|
+
if (existing1) {
|
|
179
|
+
existing1.agentId = agentId;
|
|
180
|
+
} else {
|
|
164
181
|
buffers.set(brainRunId, {
|
|
165
182
|
agentId: agentId,
|
|
166
183
|
messages: []
|
|
@@ -276,7 +293,8 @@ import { BRAIN_EVENTS } from '@positronic/core';
|
|
|
276
293
|
return [
|
|
277
294
|
4,
|
|
278
295
|
provider.add(buffer.messages, {
|
|
279
|
-
agentId: buffer.agentId
|
|
296
|
+
agentId: buffer.agentId,
|
|
297
|
+
userId: buffer.userId
|
|
280
298
|
})
|
|
281
299
|
];
|
|
282
300
|
case 2:
|
package/dist/src/helpers.js
CHANGED
|
@@ -184,7 +184,7 @@ function _ts_generator(thisArg, body) {
|
|
|
184
184
|
* memory,
|
|
185
185
|
* 'You are a helpful assistant.',
|
|
186
186
|
* 'user preferences',
|
|
187
|
-
* {
|
|
187
|
+
* { memoriesHeader: '\n\nUser context:' }
|
|
188
188
|
* );
|
|
189
189
|
*
|
|
190
190
|
* return { system, prompt: 'Help me with my task' };
|
|
@@ -192,17 +192,16 @@ function _ts_generator(thisArg, body) {
|
|
|
192
192
|
* ```
|
|
193
193
|
*/ export function createMemorySystemPrompt(_0, _1, _2) {
|
|
194
194
|
return _async_to_generator(function(memory, basePrompt, query) {
|
|
195
|
-
var options,
|
|
195
|
+
var options, limit, _options_memoriesHeader, memoriesHeader, _options_includeScores, includeScores, memories, formattedMemories;
|
|
196
196
|
var _arguments = arguments;
|
|
197
197
|
return _ts_generator(this, function(_state) {
|
|
198
198
|
switch(_state.label){
|
|
199
199
|
case 0:
|
|
200
200
|
options = _arguments.length > 3 && _arguments[3] !== void 0 ? _arguments[3] : {};
|
|
201
|
-
|
|
201
|
+
limit = options.limit, _options_memoriesHeader = options.memoriesHeader, memoriesHeader = _options_memoriesHeader === void 0 ? '\n\nRelevant context from previous interactions:' : _options_memoriesHeader, _options_includeScores = options.includeScores, includeScores = _options_includeScores === void 0 ? false : _options_includeScores;
|
|
202
202
|
return [
|
|
203
203
|
4,
|
|
204
204
|
memory.search(query, {
|
|
205
|
-
userId: userId,
|
|
206
205
|
limit: limit
|
|
207
206
|
})
|
|
208
207
|
];
|
|
@@ -241,7 +240,6 @@ function _ts_generator(thisArg, body) {
|
|
|
241
240
|
* @example
|
|
242
241
|
* ```typescript
|
|
243
242
|
* const context = await getMemoryContext(memory, 'user preferences', {
|
|
244
|
-
* userId: 'user-123',
|
|
245
243
|
* limit: 5,
|
|
246
244
|
* });
|
|
247
245
|
*
|
package/dist/src/tools.js
CHANGED
|
@@ -122,21 +122,19 @@ import { z } from 'zod';
|
|
|
122
122
|
/**
|
|
123
123
|
* Schema for the rememberFact tool input
|
|
124
124
|
*/ var rememberFactSchema = z.object({
|
|
125
|
-
fact: z.string().describe('The fact or information to remember for later')
|
|
126
|
-
userId: z.string().optional().describe('Optional user ID to associate this memory with')
|
|
125
|
+
fact: z.string().describe('The fact or information to remember for later')
|
|
127
126
|
});
|
|
128
127
|
/**
|
|
129
128
|
* Schema for the recallMemories tool input
|
|
130
129
|
*/ var recallMemoriesSchema = z.object({
|
|
131
130
|
query: z.string().describe('The search query to find relevant memories'),
|
|
132
|
-
userId: z.string().optional().describe('Optional user ID to scope the search'),
|
|
133
131
|
limit: z.number().optional().default(10).describe('Maximum number of memories to return')
|
|
134
132
|
});
|
|
135
133
|
/**
|
|
136
134
|
* Tool for storing facts in long-term memory.
|
|
137
135
|
*
|
|
138
136
|
* This tool allows the agent to store important information for future reference.
|
|
139
|
-
* Facts are stored
|
|
137
|
+
* Facts are stored scoped to the current agent and user (auto-bound from currentUser).
|
|
140
138
|
*
|
|
141
139
|
* @example
|
|
142
140
|
* ```typescript
|
|
@@ -174,9 +172,7 @@ import { z } from 'zod';
|
|
|
174
172
|
role: 'assistant',
|
|
175
173
|
content: input.fact
|
|
176
174
|
}
|
|
177
|
-
]
|
|
178
|
-
userId: input.userId
|
|
179
|
-
})
|
|
175
|
+
])
|
|
180
176
|
];
|
|
181
177
|
case 1:
|
|
182
178
|
_state.sent();
|
|
@@ -196,7 +192,7 @@ import { z } from 'zod';
|
|
|
196
192
|
* Tool for recalling memories from long-term storage.
|
|
197
193
|
*
|
|
198
194
|
* This tool allows the agent to search for and retrieve relevant memories.
|
|
199
|
-
* Memories are searched within the agent
|
|
195
|
+
* Memories are searched within the current agent and user scope (auto-bound from currentUser).
|
|
200
196
|
*
|
|
201
197
|
* @example
|
|
202
198
|
* ```typescript
|
|
@@ -231,7 +227,6 @@ import { z } from 'zod';
|
|
|
231
227
|
return [
|
|
232
228
|
4,
|
|
233
229
|
context.memory.search(input.query, {
|
|
234
|
-
userId: input.userId,
|
|
235
230
|
limit: input.limit
|
|
236
231
|
})
|
|
237
232
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EAGP,cAAc,EAEf,MAAM,kBAAkB,CAAC;AAG1B;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,2DAA2D;IAC3D,QAAQ,EAAE,cAAc,CAAC;IACzB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAWD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAiIpE"}
|
package/dist/types/helpers.d.ts
CHANGED
|
@@ -68,7 +68,7 @@ export interface CreateMemorySystemPromptOptions extends MemorySearchOptions {
|
|
|
68
68
|
* memory,
|
|
69
69
|
* 'You are a helpful assistant.',
|
|
70
70
|
* 'user preferences',
|
|
71
|
-
* {
|
|
71
|
+
* { memoriesHeader: '\n\nUser context:' }
|
|
72
72
|
* );
|
|
73
73
|
*
|
|
74
74
|
* return { system, prompt: 'Help me with my task' };
|
|
@@ -91,7 +91,6 @@ export declare function createMemorySystemPrompt(memory: ScopedMemory, basePromp
|
|
|
91
91
|
* @example
|
|
92
92
|
* ```typescript
|
|
93
93
|
* const context = await getMemoryContext(memory, 'user preferences', {
|
|
94
|
-
* userId: 'user-123',
|
|
95
94
|
* limit: 5,
|
|
96
95
|
* });
|
|
97
96
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAElF;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,sDAAsD;IACtD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,yDAAyD;IACzD,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,8CAA8C;IAC9C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,MAAM,EAAE,EAClB,OAAO,GAAE,qBAA0B,GAClC,MAAM,CA0BR;AAED;;GAEG;AACH,MAAM,WAAW,+BAAgC,SAAQ,mBAAmB;IAC1E,8CAA8C;IAC9C,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,0CAA0C;IAC1C,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,YAAY,EACpB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,+BAAoC,GAC5C,OAAO,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAElF;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,sDAAsD;IACtD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,yDAAyD;IACzD,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,8CAA8C;IAC9C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,MAAM,EAAE,EAClB,OAAO,GAAE,qBAA0B,GAClC,MAAM,CA0BR;AAED;;GAEG;AACH,MAAM,WAAW,+BAAgC,SAAQ,mBAAmB;IAC1E,8CAA8C;IAC9C,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,0CAA0C;IAC1C,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,YAAY,EACpB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,+BAAoC,GAC5C,OAAO,CAAC,MAAM,CAAC,CAmBjB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,YAAY,EACpB,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,MAAM,CAAC,CAGjB"}
|
package/dist/types/tools.d.ts
CHANGED
|
@@ -5,35 +5,29 @@ import type { AgentTool } from '@positronic/core';
|
|
|
5
5
|
*/
|
|
6
6
|
declare const rememberFactSchema: z.ZodObject<{
|
|
7
7
|
fact: z.ZodString;
|
|
8
|
-
userId: z.ZodOptional<z.ZodString>;
|
|
9
8
|
}, "strip", z.ZodTypeAny, {
|
|
10
9
|
fact: string;
|
|
11
|
-
userId?: string | undefined;
|
|
12
10
|
}, {
|
|
13
11
|
fact: string;
|
|
14
|
-
userId?: string | undefined;
|
|
15
12
|
}>;
|
|
16
13
|
/**
|
|
17
14
|
* Schema for the recallMemories tool input
|
|
18
15
|
*/
|
|
19
16
|
declare const recallMemoriesSchema: z.ZodObject<{
|
|
20
17
|
query: z.ZodString;
|
|
21
|
-
userId: z.ZodOptional<z.ZodString>;
|
|
22
18
|
limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
23
19
|
}, "strip", z.ZodTypeAny, {
|
|
24
20
|
limit: number;
|
|
25
21
|
query: string;
|
|
26
|
-
userId?: string | undefined;
|
|
27
22
|
}, {
|
|
28
23
|
query: string;
|
|
29
|
-
userId?: string | undefined;
|
|
30
24
|
limit?: number | undefined;
|
|
31
25
|
}>;
|
|
32
26
|
/**
|
|
33
27
|
* Tool for storing facts in long-term memory.
|
|
34
28
|
*
|
|
35
29
|
* This tool allows the agent to store important information for future reference.
|
|
36
|
-
* Facts are stored
|
|
30
|
+
* Facts are stored scoped to the current agent and user (auto-bound from currentUser).
|
|
37
31
|
*
|
|
38
32
|
* @example
|
|
39
33
|
* ```typescript
|
|
@@ -53,7 +47,7 @@ export declare const rememberFact: AgentTool<typeof rememberFactSchema>;
|
|
|
53
47
|
* Tool for recalling memories from long-term storage.
|
|
54
48
|
*
|
|
55
49
|
* This tool allows the agent to search for and retrieve relevant memories.
|
|
56
|
-
* Memories are searched within the agent
|
|
50
|
+
* Memories are searched within the current agent and user scope (auto-bound from currentUser).
|
|
57
51
|
*
|
|
58
52
|
* @example
|
|
59
53
|
* ```typescript
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAe,MAAM,kBAAkB,CAAC;AAE/D;;GAEG;AACH,QAAA,MAAM,kBAAkB
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAe,MAAM,kBAAkB,CAAC;AAE/D;;GAEG;AACH,QAAA,MAAM,kBAAkB;;;;;;EAEtB,CAAC;AAEH;;GAEG;AACH,QAAA,MAAM,oBAAoB;;;;;;;;;EAOxB,CAAC;AAEH;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,YAAY,EAAE,SAAS,CAAC,OAAO,kBAAkB,CA8B7D,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,cAAc,EAAE,SAAS,CAAC,OAAO,oBAAoB,CAoCjE,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,eAAe,IAAI;IACjC,YAAY,EAAE,OAAO,YAAY,CAAC;IAClC,cAAc,EAAE,OAAO,cAAc,CAAC;CACvC,CAKA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@positronic/mem0",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.70",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -29,6 +29,6 @@
|
|
|
29
29
|
"zod": "^3.24.1"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"@positronic/core": "^0.0.
|
|
32
|
+
"@positronic/core": "^0.0.70"
|
|
33
33
|
}
|
|
34
34
|
}
|