@positronic/mem0 0.0.57
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 +301 -0
- package/dist/src/helpers.js +275 -0
- package/dist/src/index.js +8 -0
- package/dist/src/provider.js +271 -0
- package/dist/src/tools.js +284 -0
- package/dist/types/adapter.d.ts +41 -0
- package/dist/types/adapter.d.ts.map +1 -0
- package/dist/types/helpers.d.ts +104 -0
- package/dist/types/helpers.d.ts.map +1 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/provider.d.ts +37 -0
- package/dist/types/provider.d.ts.map +1 -0
- package/dist/types/tools.d.ts +100 -0
- package/dist/types/tools.d.ts.map +1 -0
- package/package.json +34 -0
|
@@ -0,0 +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,CAoBjB;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,YAAY,EACpB,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,MAAM,CAAC,CAGjB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { createMem0Provider } from './provider.js';
|
|
2
|
+
export type { Mem0Config } from './provider.js';
|
|
3
|
+
export { createMem0Tools, rememberFact, recallMemories } from './tools.js';
|
|
4
|
+
export { createMem0Adapter } from './adapter.js';
|
|
5
|
+
export type { Mem0AdapterConfig } from './adapter.js';
|
|
6
|
+
export { formatMemories, createMemorySystemPrompt, getMemoryContext, } from './helpers.js';
|
|
7
|
+
export type { FormatMemoriesOptions, CreateMemorySystemPromptOptions, } from './helpers.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAGhD,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAG3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,YAAY,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGtD,OAAO,EACL,cAAc,EACd,wBAAwB,EACxB,gBAAgB,GACjB,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,qBAAqB,EACrB,+BAA+B,GAChC,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { MemoryProvider } from '@positronic/core';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration for the Mem0 memory provider.
|
|
4
|
+
*/
|
|
5
|
+
export interface Mem0Config {
|
|
6
|
+
/** Mem0 API key */
|
|
7
|
+
apiKey: string;
|
|
8
|
+
/** Base URL for the Mem0 API (defaults to https://api.mem0.ai/v1) */
|
|
9
|
+
baseUrl?: string;
|
|
10
|
+
/** Organization ID (optional) */
|
|
11
|
+
orgId?: string;
|
|
12
|
+
/** Project ID (optional) */
|
|
13
|
+
projectId?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Creates a Mem0 memory provider.
|
|
17
|
+
*
|
|
18
|
+
* @param config - Configuration for the Mem0 provider
|
|
19
|
+
* @returns A MemoryProvider implementation
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const memory = createMem0Provider({
|
|
24
|
+
* apiKey: process.env.MEM0_API_KEY!,
|
|
25
|
+
* projectId: 'my-project',
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* const myBrain = brain('my-brain')
|
|
29
|
+
* .withMemory(memory)
|
|
30
|
+
* .brain('agent', async ({ memory }) => {
|
|
31
|
+
* const prefs = await memory.search('user preferences');
|
|
32
|
+
* return { system: `Preferences: ${prefs}`, prompt: 'Help' };
|
|
33
|
+
* });
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare function createMem0Provider(config: Mem0Config): MemoryProvider;
|
|
37
|
+
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EAIf,MAAM,kBAAkB,CAAC;AAE1B;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,mBAAmB;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,qEAAqE;IACrE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iCAAiC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4BAA4B;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAYD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,UAAU,GAAG,cAAc,CAmGrE"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { AgentTool } from '@positronic/core';
|
|
3
|
+
/**
|
|
4
|
+
* Schema for the rememberFact tool input
|
|
5
|
+
*/
|
|
6
|
+
declare const rememberFactSchema: z.ZodObject<{
|
|
7
|
+
fact: z.ZodString;
|
|
8
|
+
userId: z.ZodOptional<z.ZodString>;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
fact: string;
|
|
11
|
+
userId?: string | undefined;
|
|
12
|
+
}, {
|
|
13
|
+
fact: string;
|
|
14
|
+
userId?: string | undefined;
|
|
15
|
+
}>;
|
|
16
|
+
/**
|
|
17
|
+
* Schema for the recallMemories tool input
|
|
18
|
+
*/
|
|
19
|
+
declare const recallMemoriesSchema: z.ZodObject<{
|
|
20
|
+
query: z.ZodString;
|
|
21
|
+
userId: z.ZodOptional<z.ZodString>;
|
|
22
|
+
limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
23
|
+
}, "strip", z.ZodTypeAny, {
|
|
24
|
+
limit: number;
|
|
25
|
+
query: string;
|
|
26
|
+
userId?: string | undefined;
|
|
27
|
+
}, {
|
|
28
|
+
query: string;
|
|
29
|
+
userId?: string | undefined;
|
|
30
|
+
limit?: number | undefined;
|
|
31
|
+
}>;
|
|
32
|
+
/**
|
|
33
|
+
* Tool for storing facts in long-term memory.
|
|
34
|
+
*
|
|
35
|
+
* This tool allows the agent to store important information for future reference.
|
|
36
|
+
* Facts are stored with the agent's scope and optionally a user ID.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* const tools = createMem0Tools();
|
|
41
|
+
*
|
|
42
|
+
* const myBrain = brain('my-brain')
|
|
43
|
+
* .withMemory(memory)
|
|
44
|
+
* .brain('agent', ({ tools: defaultTools }) => ({
|
|
45
|
+
* system: 'You are helpful. Store user preferences with rememberFact.',
|
|
46
|
+
* prompt: 'User says: I prefer dark mode',
|
|
47
|
+
* tools: { ...defaultTools, ...tools },
|
|
48
|
+
* }));
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export declare const rememberFact: AgentTool<typeof rememberFactSchema>;
|
|
52
|
+
/**
|
|
53
|
+
* Tool for recalling memories from long-term storage.
|
|
54
|
+
*
|
|
55
|
+
* This tool allows the agent to search for and retrieve relevant memories.
|
|
56
|
+
* Memories are searched within the agent's scope and optionally a user ID.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* const tools = createMem0Tools();
|
|
61
|
+
*
|
|
62
|
+
* const myBrain = brain('my-brain')
|
|
63
|
+
* .withMemory(memory)
|
|
64
|
+
* .brain('agent', ({ tools: defaultTools }) => ({
|
|
65
|
+
* system: 'Use recallMemories to find relevant user preferences.',
|
|
66
|
+
* prompt: 'What theme does the user prefer?',
|
|
67
|
+
* tools: { ...defaultTools, ...tools },
|
|
68
|
+
* }));
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
export declare const recallMemories: AgentTool<typeof recallMemoriesSchema>;
|
|
72
|
+
/**
|
|
73
|
+
* Creates the standard Mem0 memory tools.
|
|
74
|
+
*
|
|
75
|
+
* Returns an object with `rememberFact` and `recallMemories` tools
|
|
76
|
+
* that can be spread into your agent's tools configuration.
|
|
77
|
+
*
|
|
78
|
+
* @returns Object containing memory tools
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```typescript
|
|
82
|
+
* import { createMem0Tools } from '@positronic/mem0';
|
|
83
|
+
*
|
|
84
|
+
* const memoryTools = createMem0Tools();
|
|
85
|
+
*
|
|
86
|
+
* const myBrain = brain('my-brain')
|
|
87
|
+
* .withMemory(provider)
|
|
88
|
+
* .brain('agent', () => ({
|
|
89
|
+
* system: 'You can remember and recall information.',
|
|
90
|
+
* prompt: 'Help the user',
|
|
91
|
+
* tools: memoryTools,
|
|
92
|
+
* }));
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
export declare function createMem0Tools(): {
|
|
96
|
+
rememberFact: typeof rememberFact;
|
|
97
|
+
recallMemories: typeof recallMemories;
|
|
98
|
+
};
|
|
99
|
+
export {};
|
|
100
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +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;;;;;;;;;EAMtB,CAAC;AAEH;;GAEG;AACH,QAAA,MAAM,oBAAoB;;;;;;;;;;;;EAWxB,CAAC;AAEH;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,YAAY,EAAE,SAAS,CAAC,OAAO,kBAAkB,CA+B7D,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,cAAc,EAAE,SAAS,CAAC,OAAO,oBAAoB,CAqCjE,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,eAAe,IAAI;IACjC,YAAY,EAAE,OAAO,YAAY,CAAC;IAClC,cAAc,EAAE,OAAO,cAAc,CAAC;CACvC,CAKA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@positronic/mem0",
|
|
3
|
+
"version": "0.0.57",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"description": "Mem0 memory provider for Positronic brains",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"main": "dist/src/index.js",
|
|
10
|
+
"types": "dist/types/index.d.ts",
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"files": [
|
|
13
|
+
"dist",
|
|
14
|
+
"package.json"
|
|
15
|
+
],
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/types/index.d.ts",
|
|
19
|
+
"import": "./dist/src/index.js"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"tsc": "tsc --project tsconfig.json",
|
|
24
|
+
"swc": "swc src -d dist",
|
|
25
|
+
"build": "npm run tsc && npm run swc",
|
|
26
|
+
"clean": "rm -rf tsconfig.tsbuildinfo dist node_modules"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"zod": "^3.24.1"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"@positronic/core": "^0.0.57"
|
|
33
|
+
}
|
|
34
|
+
}
|