@amaster.ai/pi-memory-mem0 0.1.8 → 0.1.10
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/README.md +94 -35
- package/dist/dedup.d.ts +8 -2
- package/dist/dedup.d.ts.map +1 -1
- package/dist/dedup.js +92 -27
- package/dist/dedup.js.map +1 -1
- package/dist/index.d.ts +17 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +247 -25
- package/dist/index.js.map +1 -1
- package/dist/prefetch.d.ts +21 -0
- package/dist/prefetch.d.ts.map +1 -0
- package/dist/prefetch.js +64 -0
- package/dist/prefetch.js.map +1 -0
- package/dist/privacy.d.ts +2 -1
- package/dist/privacy.d.ts.map +1 -1
- package/dist/privacy.js +3 -1
- package/dist/privacy.js.map +1 -1
- package/dist/provider.d.ts +28 -17
- package/dist/provider.d.ts.map +1 -1
- package/dist/provider.js +288 -50
- package/dist/provider.js.map +1 -1
- package/dist/tools.d.ts +27 -10
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +101 -89
- package/dist/tools.js.map +1 -1
- package/dist/types.d.ts +19 -5
- package/dist/types.d.ts.map +1 -1
- package/package.json +8 -3
package/dist/tools.js
CHANGED
|
@@ -1,108 +1,120 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Active memory tool — the LLM-callable interface over the Mem0 provider.
|
|
3
|
+
*
|
|
4
|
+
* Borrowed from the official @mem0/pi-agent-plugin design (a single
|
|
5
|
+
* action-dispatched tool), but built on this package's Mem0Provider so it
|
|
6
|
+
* works with platform, embedded, and self-hosted backends, and keeps the
|
|
7
|
+
* package's security boundaries: credentials are redacted before storage,
|
|
8
|
+
* and memory text returned to the model is wrapped as untrusted data.
|
|
3
9
|
*/
|
|
10
|
+
import { StringEnum } from '@earendil-works/pi-ai';
|
|
4
11
|
import { truncateHead, truncateLine } from '@earendil-works/pi-coding-agent';
|
|
5
12
|
import { Type } from 'typebox';
|
|
6
13
|
import { formatRecalledMemory, redactMemoryText } from './privacy.js';
|
|
14
|
+
/** Tool results land in model context — keep the block small. */
|
|
15
|
+
const MAX_ENTRY_CHARS = 1_000;
|
|
16
|
+
const MAX_BLOCK_BYTES = 16 * 1024;
|
|
17
|
+
const MAX_BLOCK_LINES = 200;
|
|
7
18
|
function textResult(text) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
return { content: [{ type: 'text', text }], details: undefined };
|
|
20
|
+
}
|
|
21
|
+
function errorResult(text) {
|
|
22
|
+
return { isError: true, content: [{ type: 'text', text }], details: undefined };
|
|
23
|
+
}
|
|
24
|
+
function formatEntry(entry) {
|
|
25
|
+
const text = truncateLine(entry.memory.trim(), MAX_ENTRY_CHARS).text;
|
|
26
|
+
return `- ${entry.id}: ${formatRecalledMemory(text)}`;
|
|
27
|
+
}
|
|
28
|
+
function formatBlock(title, entries) {
|
|
29
|
+
const lines = entries.filter((e) => e.memory?.trim()).map(formatEntry);
|
|
30
|
+
if (lines.length === 0)
|
|
31
|
+
return textResult('No memories found.');
|
|
32
|
+
return textResult(truncateHead(`${title}\n${lines.join('\n')}`, {
|
|
33
|
+
maxBytes: MAX_BLOCK_BYTES,
|
|
34
|
+
maxLines: MAX_BLOCK_LINES,
|
|
35
|
+
}).content);
|
|
19
36
|
}
|
|
20
|
-
export function
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
37
|
+
export function createMem0MemoryTool(opts) {
|
|
38
|
+
const topK = opts.topK ?? 5;
|
|
39
|
+
return {
|
|
40
|
+
name: 'mem0_memory',
|
|
41
|
+
label: 'Mem0 Memory',
|
|
42
|
+
description: 'Read and manage long-term semantic memories about the user and their projects. ' +
|
|
43
|
+
'Memories are facts extracted from past conversations, stored in Mem0.\n\n' +
|
|
44
|
+
'Actions:\n' +
|
|
45
|
+
'- search: semantic search over memories (requires query)\n' +
|
|
46
|
+
'- add: store a durable fact (requires content)\n' +
|
|
47
|
+
'- get_all: list every stored memory\n' +
|
|
48
|
+
'- delete: remove a memory by id (requires memory_id, taken from search/get_all results)',
|
|
49
|
+
promptSnippet: 'Search and manage long-term semantic memories (Mem0).',
|
|
50
|
+
promptGuidelines: [
|
|
51
|
+
'Search mem0_memory BEFORE answering when the request could depend on the user’s past work, preferences, or prior decisions.',
|
|
52
|
+
'Save durable facts proactively — user preferences, corrections, environment facts. Do not save task progress or temporary session state.',
|
|
53
|
+
],
|
|
26
54
|
parameters: Type.Object({
|
|
27
|
-
|
|
28
|
-
|
|
55
|
+
action: StringEnum(['search', 'add', 'get_all', 'delete'], {
|
|
56
|
+
description: 'The memory operation to perform.',
|
|
57
|
+
}),
|
|
58
|
+
query: Type.Optional(Type.String({ description: 'Search query. Required for search.' })),
|
|
59
|
+
content: Type.Optional(Type.String({ description: 'Memory content to store. Required for add.' })),
|
|
60
|
+
memory_id: Type.Optional(Type.String({ description: 'Memory id to remove. Required for delete.' })),
|
|
29
61
|
}),
|
|
30
|
-
async execute(_toolCallId, params) {
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
if (!
|
|
34
|
-
return
|
|
35
|
-
try {
|
|
36
|
-
const results = await provider.search(query, { userId, topK });
|
|
37
|
-
if (results.length === 0) {
|
|
38
|
-
return textResult(JSON.stringify({ result: 'No relevant memories found.' }));
|
|
39
|
-
}
|
|
40
|
-
return textResult(JSON.stringify({
|
|
41
|
-
results: results.map((r) => ({
|
|
42
|
-
memory: formatRecalledMemory(r.memory),
|
|
43
|
-
score: r.score,
|
|
44
|
-
})),
|
|
45
|
-
count: results.length,
|
|
46
|
-
}));
|
|
47
|
-
}
|
|
48
|
-
catch (err) {
|
|
49
|
-
return textResult(JSON.stringify({
|
|
50
|
-
error: `Search failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
51
|
-
}));
|
|
62
|
+
async execute(_toolCallId, params, signal, _onUpdate, _ctx) {
|
|
63
|
+
const action = String(params.action ?? '');
|
|
64
|
+
const signalOpts = signal ? { signal } : {};
|
|
65
|
+
if (!opts.isEnabled()) {
|
|
66
|
+
return errorResult('mem0_memory is disabled in this session.');
|
|
52
67
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
promptSnippet: 'Full dump of all stored user memories.',
|
|
60
|
-
parameters: Type.Object({}),
|
|
61
|
-
async execute() {
|
|
68
|
+
const provider = opts.getProvider();
|
|
69
|
+
if (!provider)
|
|
70
|
+
return errorResult('Mem0 is not active.');
|
|
71
|
+
const userId = opts.getUserId();
|
|
72
|
+
const agentId = opts.getAgentId();
|
|
73
|
+
const scope = { userId, ...(agentId ? { agentId } : {}) };
|
|
62
74
|
try {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
75
|
+
switch (action) {
|
|
76
|
+
case 'search': {
|
|
77
|
+
const query = redactMemoryText(String(params.query ?? '').trim());
|
|
78
|
+
if (!query)
|
|
79
|
+
return errorResult('query is required for the search action.');
|
|
80
|
+
const results = await provider.search(query, { ...scope, topK, ...signalOpts });
|
|
81
|
+
return formatBlock(`## Memories matching "${query}"`, results);
|
|
82
|
+
}
|
|
83
|
+
case 'add': {
|
|
84
|
+
const content = redactMemoryText(String(params.content ?? '').trim());
|
|
85
|
+
if (!content)
|
|
86
|
+
return errorResult('content is required for the add action.');
|
|
87
|
+
const result = await provider.add([{ role: 'user', content }], {
|
|
88
|
+
...scope,
|
|
89
|
+
...signalOpts,
|
|
90
|
+
});
|
|
91
|
+
const created = result?.results ?? [];
|
|
92
|
+
if (created.length === 0) {
|
|
93
|
+
return textResult('No memory was extracted from the provided content.');
|
|
94
|
+
}
|
|
95
|
+
return formatBlock(`Saved ${created.length} memories:`, created);
|
|
96
|
+
}
|
|
97
|
+
case 'get_all': {
|
|
98
|
+
const results = await provider.getAll({ ...scope, ...signalOpts });
|
|
99
|
+
return formatBlock(`## All memories (${results.length})`, results);
|
|
100
|
+
}
|
|
101
|
+
case 'delete': {
|
|
102
|
+
const memoryId = String(params.memory_id ?? '').trim();
|
|
103
|
+
if (!memoryId)
|
|
104
|
+
return errorResult('memory_id is required for the delete action.');
|
|
105
|
+
await provider.delete(memoryId, signalOpts);
|
|
106
|
+
return textResult(`Deleted memory ${memoryId}.`);
|
|
107
|
+
}
|
|
108
|
+
default:
|
|
109
|
+
return errorResult(`Unknown action "${action}". Available: search, add, get_all, delete.`);
|
|
66
110
|
}
|
|
67
|
-
const lines = memories
|
|
68
|
-
.map((m) => m.memory)
|
|
69
|
-
.filter(Boolean)
|
|
70
|
-
.map(formatRecalledMemory);
|
|
71
|
-
return textResult(JSON.stringify({ result: lines.join('\n'), count: lines.length }));
|
|
72
|
-
}
|
|
73
|
-
catch (err) {
|
|
74
|
-
return textResult(JSON.stringify({
|
|
75
|
-
error: `Profile failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
76
|
-
}));
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
};
|
|
80
|
-
const saveTool = {
|
|
81
|
-
name: 'mem0_save',
|
|
82
|
-
label: 'Mem0',
|
|
83
|
-
description: 'Store a durable fact about the user verbatim (no LLM extraction). Use for explicit preferences or corrections.',
|
|
84
|
-
promptSnippet: 'Save a fact to long-term memory verbatim.',
|
|
85
|
-
parameters: Type.Object({
|
|
86
|
-
fact: Type.String({ description: 'The fact to store.' }),
|
|
87
|
-
}),
|
|
88
|
-
async execute(_toolCallId, params) {
|
|
89
|
-
const fact = String(params.fact ?? '').trim();
|
|
90
|
-
if (!fact)
|
|
91
|
-
return textResult(JSON.stringify({ error: 'Fact cannot be empty.' }));
|
|
92
|
-
try {
|
|
93
|
-
const result = await provider.add([{ role: 'user', content: redactMemoryText(fact) }], {
|
|
94
|
-
userId,
|
|
95
|
-
infer: false,
|
|
96
|
-
});
|
|
97
|
-
return textResult(JSON.stringify(result ? { result: 'Fact stored.' } : { error: 'Failed to store.' }));
|
|
98
111
|
}
|
|
99
112
|
catch (err) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
})
|
|
113
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
114
|
+
console.error(`[pi-memory-mem0] mem0_memory ${action} failed: ${message}`);
|
|
115
|
+
return errorResult(`mem0_memory ${action} failed: ${message}`);
|
|
103
116
|
}
|
|
104
117
|
},
|
|
105
118
|
};
|
|
106
|
-
return [searchTool, profileTool, saveTool];
|
|
107
119
|
}
|
|
108
120
|
//# sourceMappingURL=tools.js.map
|
package/dist/tools.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAOnD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGtE,iEAAiE;AACjE,MAAM,eAAe,GAAG,KAAK,CAAC;AAC9B,MAAM,eAAe,GAAG,EAAE,GAAG,IAAI,CAAC;AAClC,MAAM,eAAe,GAAG,GAAG,CAAC;AA8B5B,SAAS,UAAU,CAAC,IAAY;IAC9B,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;AAC5E,CAAC;AAED,SAAS,WAAW,CAAC,IAAY;IAC/B,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE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,EAAE,GAAG,UAAU,EAAE,CAAC,CAAC;wBACnE,OAAO,WAAW,CAAC,oBAAoB,OAAO,CAAC,MAAM,GAAG,EAAE,OAAO,CAAC,CAAC;oBACrE,CAAC;oBACD,KAAK,QAAQ,CAAC,CAAC,CAAC;wBACd,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;wBACvD,IAAI,CAAC,QAAQ;4BAAE,OAAO,WAAW,CAAC,8CAA8C,CAAC,CAAC;wBAClF,MAAM,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;wBAC5C,OAAO,UAAU,CAAC,kBAAkB,QAAQ,GAAG,CAAC,CAAC;oBACnD,CAAC;oBACD;wBACE,OAAO,WAAW,CAChB,mBAAmB,MAAM,6CAA6C,CACvE,CAAC;gBACN,CAAC;YACH,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;gBACjE,OAAO,CAAC,KAAK,CAAC,gCAAgC,MAAM,YAAY,OAAO,EAAE,CAAC,CAAC;gBAC3E,OAAO,WAAW,CAAC,eAAe,MAAM,YAAY,OAAO,EAAE,CAAC,CAAC;YACjE,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Configuration types for pi-memory-mem0.
|
|
3
3
|
*/
|
|
4
|
-
export type Mem0Mode = 'platform' | '
|
|
4
|
+
export type Mem0Mode = 'platform' | 'embedded' | 'self-hosted';
|
|
5
|
+
export type Mem0MemoryMode = 'hybrid' | 'active' | 'passive';
|
|
6
|
+
export type MemoryUserIdScope = 'project' | 'exact';
|
|
5
7
|
export interface Mem0ExtensionConfig {
|
|
6
|
-
/**
|
|
8
|
+
/** Mem0 Cloud, in-process OSS, or a remote OSS server. Default: "platform". */
|
|
7
9
|
mode?: Mem0Mode;
|
|
8
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* Memory behavior: "passive" = automatic capture + recall injection only,
|
|
12
|
+
* "active" = LLM-callable mem0_memory tool only, "hybrid" = both.
|
|
13
|
+
* Default: "hybrid".
|
|
14
|
+
*/
|
|
15
|
+
memoryMode?: Mem0MemoryMode;
|
|
16
|
+
/** Mem0 API key. Supports ${MEM0_API_KEY}. */
|
|
9
17
|
apiKey?: string;
|
|
10
|
-
/**
|
|
18
|
+
/** Platform override or required self-hosted OSS server URL. */
|
|
11
19
|
baseUrl?: string;
|
|
20
|
+
/** Remote request timeout in milliseconds. Default: 30000. */
|
|
21
|
+
requestTimeoutMs?: number;
|
|
12
22
|
oss?: {
|
|
13
23
|
embedder?: {
|
|
14
24
|
provider: string;
|
|
@@ -33,10 +43,14 @@ export interface Mem0ExtensionConfig {
|
|
|
33
43
|
};
|
|
34
44
|
/** User identifier for memory scoping. Supports ${USER}. */
|
|
35
45
|
userId?: string;
|
|
46
|
+
/** Optional agent identifier for memory scoping. Supports environment interpolation. */
|
|
47
|
+
agentId?: string;
|
|
48
|
+
/** Append a cwd hash (default) or use userId verbatim. */
|
|
49
|
+
userIdScope?: MemoryUserIdScope;
|
|
36
50
|
/** Max recalled memories per turn. Default: 5 */
|
|
37
51
|
topK?: number;
|
|
38
52
|
/**
|
|
39
|
-
* When true (default),
|
|
53
|
+
* When true (default), embedded mode will attempt to resolve API keys from
|
|
40
54
|
* pi's model registry instead of requiring separate env vars.
|
|
41
55
|
* Falls back to OPENAI_API_KEY / DEEPSEEK_API_KEY env vars if registry lookup fails.
|
|
42
56
|
*/
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;G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a,CAAC,EAAE,MAAM,CAAC;QACvB,cAAc,CAAC,EAAE,OAAO,CAAC;KAC1B,CAAC;IAGF,4DAA4D;IAC5D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,wFAAwF;IACxF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,0DAA0D;IAC1D,WAAW,CAAC,EAAE,iBAAiB,CAAC;IAChC,iDAAiD;IACjD,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC;AAED,MAAM,WAAW,SAAS;IACxB,OAAO,CAAC,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAChE"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amaster.ai/pi-memory-mem0",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.10",
|
|
4
|
+
"description": "Mem0 semantic memory for pi — automatic capture, semantic recall, and an agent-callable memory tool. Platform, embedded, or self-hosted.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
|
7
7
|
"pi",
|
|
@@ -54,13 +54,17 @@
|
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"mem0ai": "3.0.7",
|
|
57
|
-
"@amaster.ai/pi-shared": "0.1.
|
|
57
|
+
"@amaster.ai/pi-shared": "0.1.10"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
|
+
"@earendil-works/pi-ai": ">=0.80.10",
|
|
60
61
|
"@earendil-works/pi-coding-agent": ">=0.79.1",
|
|
61
62
|
"typebox": "*"
|
|
62
63
|
},
|
|
63
64
|
"peerDependenciesMeta": {
|
|
65
|
+
"@earendil-works/pi-ai": {
|
|
66
|
+
"optional": true
|
|
67
|
+
},
|
|
64
68
|
"@earendil-works/pi-coding-agent": {
|
|
65
69
|
"optional": true
|
|
66
70
|
},
|
|
@@ -69,6 +73,7 @@
|
|
|
69
73
|
}
|
|
70
74
|
},
|
|
71
75
|
"devDependencies": {
|
|
76
|
+
"@earendil-works/pi-ai": "0.80.10",
|
|
72
77
|
"@earendil-works/pi-coding-agent": "0.80.10",
|
|
73
78
|
"typebox": "*",
|
|
74
79
|
"vitest": "^4.0.0"
|