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.
Files changed (78) hide show
  1. package/README.md +81 -73
  2. package/USER_GUIDE.md +306 -73
  3. package/dist/MemoGrafterAgent.d.ts +7 -3
  4. package/dist/MemoGrafterAgent.d.ts.map +1 -1
  5. package/dist/MemoGrafterAgent.js +64 -23
  6. package/dist/MemoGrafterAgent.js.map +1 -1
  7. package/dist/crawler/ConflictDetectionPass.d.ts +6 -0
  8. package/dist/crawler/ConflictDetectionPass.d.ts.map +1 -0
  9. package/dist/crawler/ConflictDetectionPass.js +46 -0
  10. package/dist/crawler/ConflictDetectionPass.js.map +1 -0
  11. package/dist/crawler/DecayScoringPass.d.ts +17 -0
  12. package/dist/crawler/DecayScoringPass.d.ts.map +1 -0
  13. package/dist/crawler/DecayScoringPass.js +73 -0
  14. package/dist/crawler/DecayScoringPass.js.map +1 -0
  15. package/dist/crawler/MemoGrafterCrawler.d.ts +14 -0
  16. package/dist/crawler/MemoGrafterCrawler.d.ts.map +1 -0
  17. package/dist/crawler/MemoGrafterCrawler.js +108 -0
  18. package/dist/crawler/MemoGrafterCrawler.js.map +1 -0
  19. package/dist/crawler/VersioningPass.d.ts +6 -0
  20. package/dist/crawler/VersioningPass.d.ts.map +1 -0
  21. package/dist/crawler/VersioningPass.js +43 -0
  22. package/dist/crawler/VersioningPass.js.map +1 -0
  23. package/dist/crawler/decayScoring.d.ts +7 -0
  24. package/dist/crawler/decayScoring.d.ts.map +1 -0
  25. package/dist/crawler/decayScoring.js +9 -0
  26. package/dist/crawler/decayScoring.js.map +1 -0
  27. package/dist/crawler/index.d.ts +7 -0
  28. package/dist/crawler/index.d.ts.map +1 -0
  29. package/dist/crawler/index.js +5 -0
  30. package/dist/crawler/index.js.map +1 -0
  31. package/dist/crawler/memoryMaintenance.d.ts +14 -0
  32. package/dist/crawler/memoryMaintenance.d.ts.map +1 -0
  33. package/dist/crawler/memoryMaintenance.js +40 -0
  34. package/dist/crawler/memoryMaintenance.js.map +1 -0
  35. package/dist/crawler/types.d.ts +63 -0
  36. package/dist/crawler/types.d.ts.map +1 -0
  37. package/dist/crawler/types.js +2 -0
  38. package/dist/crawler/types.js.map +1 -0
  39. package/dist/index.d.ts +3 -1
  40. package/dist/index.d.ts.map +1 -1
  41. package/dist/index.js +1 -0
  42. package/dist/index.js.map +1 -1
  43. package/dist/pipeline/GrafterPipeline.d.ts.map +1 -1
  44. package/dist/pipeline/GrafterPipeline.js +42 -1
  45. package/dist/pipeline/GrafterPipeline.js.map +1 -1
  46. package/dist/pipeline/IngestPipeline.d.ts +2 -0
  47. package/dist/pipeline/IngestPipeline.d.ts.map +1 -1
  48. package/dist/pipeline/IngestPipeline.js +93 -17
  49. package/dist/pipeline/IngestPipeline.js.map +1 -1
  50. package/dist/prompts/memoryInjectionPrompt.d.ts +6 -2
  51. package/dist/prompts/memoryInjectionPrompt.d.ts.map +1 -1
  52. package/dist/prompts/memoryInjectionPrompt.js +25 -2
  53. package/dist/prompts/memoryInjectionPrompt.js.map +1 -1
  54. package/dist/store/GraphStore.d.ts +20 -1
  55. package/dist/store/GraphStore.d.ts.map +1 -1
  56. package/dist/store/postgres-pgvector/GraphStore.d.ts +25 -1
  57. package/dist/store/postgres-pgvector/GraphStore.d.ts.map +1 -1
  58. package/dist/store/postgres-pgvector/GraphStore.js +334 -1
  59. package/dist/store/postgres-pgvector/GraphStore.js.map +1 -1
  60. package/dist/types.d.ts +29 -0
  61. package/dist/types.d.ts.map +1 -1
  62. package/dist/utils/drift/cosineSimilarity.test.d.ts +2 -0
  63. package/dist/utils/drift/cosineSimilarity.test.d.ts.map +1 -0
  64. package/dist/utils/drift/cosineSimilarity.test.js +25 -0
  65. package/dist/utils/drift/cosineSimilarity.test.js.map +1 -0
  66. package/dist/utils/drift/vectorAvg.test.d.ts +2 -0
  67. package/dist/utils/drift/vectorAvg.test.d.ts.map +1 -0
  68. package/dist/utils/drift/vectorAvg.test.js +36 -0
  69. package/dist/utils/drift/vectorAvg.test.js.map +1 -0
  70. package/dist/utils/text/normalizeText.test.d.ts +2 -0
  71. package/dist/utils/text/normalizeText.test.d.ts.map +1 -0
  72. package/dist/utils/text/normalizeText.test.js +23 -0
  73. package/dist/utils/text/normalizeText.test.js.map +1 -0
  74. package/dist/utils/vector/vectorLiteral.test.d.ts +2 -0
  75. package/dist/utils/vector/vectorLiteral.test.d.ts.map +1 -0
  76. package/dist/utils/vector/vectorLiteral.test.js +28 -0
  77. package/dist/utils/vector/vectorLiteral.test.js.map +1 -0
  78. package/package.json +1 -1
package/README.md CHANGED
@@ -1,73 +1,81 @@
1
- # MemoGrafter
2
- [![npm version](https://img.shields.io/npm/v/memo-grafter.svg)](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
- ## What It Is For
11
-
12
- - Chatbots that need long-running memory.
13
- - Assistants that should recall user preferences, prior context, and open questions.
14
- - Multi-chatbot or multi-session flows where selected memory can be grafted into another conversation.
15
- - TypeScript apps that need reusable memory, retrieval, and graph-backed conversation primitives.
16
-
17
- ## How It Works
18
-
19
- ```text
20
- chat messages
21
- -> topic-based memory
22
- -> graph links
23
- -> relevant recall
24
- -> optional memory grafting
25
- ```
26
-
27
- MemoGrafter stores conversation turns, detects topic changes, summarizes useful context, links related memories, and retrieves or grafts memory when needed.
28
-
29
- ## Install
30
-
31
- ```bash
32
- npm install memo-grafter
33
- ```
34
-
35
- MemoGrafter runs server-side on Node.js. The built-in storage backend uses PostgreSQL with `pgvector`.
36
-
37
- ## Minimal Example
38
-
39
- ```ts
40
- import "dotenv/config";
41
-
42
- import {
43
- MemoGrafterAgent,
44
- OpenAIEmbedAdapter,
45
- OpenAILLMAdapter,
46
- } from "memo-grafter";
47
-
48
- const agent = new MemoGrafterAgent({
49
- db: { connectionString: process.env.DATABASE_URL! },
50
- llm: new OpenAILLMAdapter("gpt-4o"),
51
- embedder: new OpenAIEmbedAdapter("text-embedding-3-small"),
52
- });
53
-
54
- await agent.initialize();
55
-
56
- await agent.invoke("I am planning a Japan trip.");
57
- await agent.invoke("I like quiet towns, bookstores, and local cafes.");
58
-
59
- const recall = await agent.recall("travel preferences");
60
- console.log(recall.facts);
61
-
62
- await agent.close();
63
- ```
64
-
65
- ## Learn More
66
-
67
- - [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.
68
- - [ARCHITECTURE.md](https://github.com/mayhemking007/memo-grafter/blob/main/ARCHITECTURE.md) explains the current high-level implementation.
69
- - `examples` contains runnable demo.
70
-
71
- ## License
72
-
73
- MIT
1
+ # MemoGrafter
2
+ [![npm version](https://img.shields.io/npm/v/memo-grafter.svg)](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