memo-grafter 0.2.2 → 0.2.4
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 +81 -73
- package/USER_GUIDE.md +306 -73
- package/dist/MemoGrafterAgent.d.ts +7 -3
- package/dist/MemoGrafterAgent.d.ts.map +1 -1
- package/dist/MemoGrafterAgent.js +64 -23
- package/dist/MemoGrafterAgent.js.map +1 -1
- package/dist/crawler/ConflictDetectionPass.d.ts +6 -0
- package/dist/crawler/ConflictDetectionPass.d.ts.map +1 -0
- package/dist/crawler/ConflictDetectionPass.js +46 -0
- package/dist/crawler/ConflictDetectionPass.js.map +1 -0
- package/dist/crawler/DecayScoringPass.d.ts +17 -0
- package/dist/crawler/DecayScoringPass.d.ts.map +1 -0
- package/dist/crawler/DecayScoringPass.js +73 -0
- package/dist/crawler/DecayScoringPass.js.map +1 -0
- package/dist/crawler/MemoGrafterCrawler.d.ts +14 -0
- package/dist/crawler/MemoGrafterCrawler.d.ts.map +1 -0
- package/dist/crawler/MemoGrafterCrawler.js +108 -0
- package/dist/crawler/MemoGrafterCrawler.js.map +1 -0
- package/dist/crawler/VersioningPass.d.ts +6 -0
- package/dist/crawler/VersioningPass.d.ts.map +1 -0
- package/dist/crawler/VersioningPass.js +43 -0
- package/dist/crawler/VersioningPass.js.map +1 -0
- package/dist/crawler/decayScoring.d.ts +7 -0
- package/dist/crawler/decayScoring.d.ts.map +1 -0
- package/dist/crawler/decayScoring.js +9 -0
- package/dist/crawler/decayScoring.js.map +1 -0
- package/dist/crawler/index.d.ts +7 -0
- package/dist/crawler/index.d.ts.map +1 -0
- package/dist/crawler/index.js +5 -0
- package/dist/crawler/index.js.map +1 -0
- package/dist/crawler/memoryMaintenance.d.ts +14 -0
- package/dist/crawler/memoryMaintenance.d.ts.map +1 -0
- package/dist/crawler/memoryMaintenance.js +40 -0
- package/dist/crawler/memoryMaintenance.js.map +1 -0
- package/dist/crawler/types.d.ts +63 -0
- package/dist/crawler/types.d.ts.map +1 -0
- package/dist/crawler/types.js +2 -0
- package/dist/crawler/types.js.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/pipeline/GrafterPipeline.d.ts.map +1 -1
- package/dist/pipeline/GrafterPipeline.js +42 -1
- package/dist/pipeline/GrafterPipeline.js.map +1 -1
- package/dist/pipeline/IngestPipeline.d.ts +2 -0
- package/dist/pipeline/IngestPipeline.d.ts.map +1 -1
- package/dist/pipeline/IngestPipeline.js +93 -17
- package/dist/pipeline/IngestPipeline.js.map +1 -1
- package/dist/prompts/memoryInjectionPrompt.d.ts +6 -2
- package/dist/prompts/memoryInjectionPrompt.d.ts.map +1 -1
- package/dist/prompts/memoryInjectionPrompt.js +25 -2
- package/dist/prompts/memoryInjectionPrompt.js.map +1 -1
- package/dist/store/GraphStore.d.ts +20 -1
- package/dist/store/GraphStore.d.ts.map +1 -1
- package/dist/store/postgres-pgvector/GraphStore.d.ts +25 -1
- package/dist/store/postgres-pgvector/GraphStore.d.ts.map +1 -1
- package/dist/store/postgres-pgvector/GraphStore.js +334 -1
- package/dist/store/postgres-pgvector/GraphStore.js.map +1 -1
- package/dist/types.d.ts +29 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/drift/cosineSimilarity.test.d.ts +2 -0
- package/dist/utils/drift/cosineSimilarity.test.d.ts.map +1 -0
- package/dist/utils/drift/cosineSimilarity.test.js +25 -0
- package/dist/utils/drift/cosineSimilarity.test.js.map +1 -0
- package/dist/utils/drift/vectorAvg.test.d.ts +2 -0
- package/dist/utils/drift/vectorAvg.test.d.ts.map +1 -0
- package/dist/utils/drift/vectorAvg.test.js +36 -0
- package/dist/utils/drift/vectorAvg.test.js.map +1 -0
- package/dist/utils/text/normalizeText.test.d.ts +2 -0
- package/dist/utils/text/normalizeText.test.d.ts.map +1 -0
- package/dist/utils/text/normalizeText.test.js +23 -0
- package/dist/utils/text/normalizeText.test.js.map +1 -0
- package/dist/utils/vector/vectorLiteral.test.d.ts +2 -0
- package/dist/utils/vector/vectorLiteral.test.d.ts.map +1 -0
- package/dist/utils/vector/vectorLiteral.test.js +28 -0
- package/dist/utils/vector/vectorLiteral.test.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,73 +1,81 @@
|
|
|
1
|
-
# MemoGrafter
|
|
2
|
-
[](https://www.npmjs.com/package/memo-grafter)
|
|
3
|
-
|
|
4
|
-
Structured memory for TypeScript chatbots.
|
|
5
|
-
|
|
6
|
-
MemoGrafter helps chatbot applications remember conversations without stuffing every old message back into the prompt. It turns conversation history into topic-based memory, recalls relevant details later, and can copy useful memory from one chatbot or session into another.
|
|
7
|
-
|
|
8
|
-
It is a memory framework, not an autonomous agent runtime. It does not run tools, schedule work, or decide goals for an agent.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
|
|
17
|
-
##
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
1
|
+
# MemoGrafter
|
|
2
|
+
[](https://www.npmjs.com/package/memo-grafter)
|
|
3
|
+
|
|
4
|
+
Structured memory for TypeScript chatbots.
|
|
5
|
+
|
|
6
|
+
MemoGrafter helps chatbot applications remember conversations without stuffing every old message back into the prompt. It turns conversation history into topic-based memory, recalls relevant details later, and can copy useful memory from one chatbot or session into another.
|
|
7
|
+
|
|
8
|
+
It is a memory framework, not an autonomous agent runtime. It does not run tools, schedule work, or decide goals for an agent.
|
|
9
|
+
|
|
10
|
+
MemoGrafter builds the memory graph incrementally. New chatbot turns append topic and memory nodes to the existing graph instead of clearing and rebuilding the session on every response, so grafted and externally enriched memory can survive later conversation turns. Use `clearSession()` explicitly when you want to reset an agent's local history and stored session memory.
|
|
11
|
+
|
|
12
|
+
## Playground
|
|
13
|
+
|
|
14
|
+
- Try the [MemoGrafter Playground](https://mgplayground-green.vercel.app/).
|
|
15
|
+
- View the playground demo repo at [mayhemking007/mg-demo](https://github.com/mayhemking007/mg-demo).
|
|
16
|
+
|
|
17
|
+
## What It Is For
|
|
18
|
+
|
|
19
|
+
- Chatbots that need long-running memory.
|
|
20
|
+
- Assistants that should recall user preferences, prior context, and open questions.
|
|
21
|
+
- Multi-chatbot or multi-session flows where selected memory can be grafted into another conversation.
|
|
22
|
+
- TypeScript apps that need reusable memory, retrieval, and graph-backed conversation primitives.
|
|
23
|
+
|
|
24
|
+
## How It Works
|
|
25
|
+
|
|
26
|
+
```text
|
|
27
|
+
chat messages
|
|
28
|
+
-> topic-based memory
|
|
29
|
+
-> graph links
|
|
30
|
+
-> relevant recall
|
|
31
|
+
-> optional memory grafting
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
MemoGrafter stores conversation turns, tracks which messages have already been ingested, detects topic changes for new turns with recent context, summarizes useful context, links related memories, and retrieves or grafts memory when needed.
|
|
35
|
+
|
|
36
|
+
## Install
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
npm install memo-grafter
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
MemoGrafter runs server-side on Node.js. The built-in storage backend uses PostgreSQL with `pgvector`.
|
|
43
|
+
|
|
44
|
+
## Minimal Example
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
import "dotenv/config";
|
|
48
|
+
|
|
49
|
+
import {
|
|
50
|
+
MemoGrafterAgent,
|
|
51
|
+
OpenAIEmbedAdapter,
|
|
52
|
+
OpenAILLMAdapter,
|
|
53
|
+
} from "memo-grafter";
|
|
54
|
+
|
|
55
|
+
const agent = new MemoGrafterAgent({
|
|
56
|
+
db: { connectionString: process.env.DATABASE_URL! },
|
|
57
|
+
llm: new OpenAILLMAdapter("gpt-4o"),
|
|
58
|
+
embedder: new OpenAIEmbedAdapter("text-embedding-3-small"),
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
await agent.initialize();
|
|
62
|
+
|
|
63
|
+
await agent.invoke("I am planning a Japan trip.");
|
|
64
|
+
await agent.invoke("I like quiet towns, bookstores, and local cafes.");
|
|
65
|
+
|
|
66
|
+
const recall = await agent.recall("travel preferences");
|
|
67
|
+
console.log(recall.facts);
|
|
68
|
+
|
|
69
|
+
await agent.close();
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Learn More
|
|
73
|
+
|
|
74
|
+
- [USER_GUIDE.md](https://github.com/mayhemking007/memo-grafter/blob/main/USER_GUIDE.md) covers setup, configuration, adapters, queue mode, fleet APIs, examples, and troubleshooting.
|
|
75
|
+
- [ARCHITECTURE.md](https://github.com/mayhemking007/memo-grafter/blob/main/ARCHITECTURE.md) explains the current high-level implementation.
|
|
76
|
+
- `examples/basic-chat-memory` is the simplest runnable single-agent memory demo.
|
|
77
|
+
- `examples/chatbot-memory-demo` shows the larger two-agent grafting workflow.
|
|
78
|
+
|
|
79
|
+
## License
|
|
80
|
+
|
|
81
|
+
MIT
|