@t0ken.ai/memoryx-sdk 1.0.0 → 1.0.1
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 +50 -50
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,65 +1,65 @@
|
|
|
1
1
|
# @t0ken.ai/memoryx-sdk
|
|
2
2
|
|
|
3
|
-
MemoryX Node.js SDK -
|
|
3
|
+
MemoryX Node.js SDK - Enable AI Agents with persistent memory
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
8
|
npm install @t0ken.ai/memoryx-sdk
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## Quick Start
|
|
12
12
|
|
|
13
13
|
```typescript
|
|
14
|
-
import { MemoryXSDK, PRESET } from '@t0ken/memoryx-sdk';
|
|
14
|
+
import { MemoryXSDK, PRESET } from '@t0ken.ai/memoryx-sdk';
|
|
15
15
|
|
|
16
|
-
//
|
|
16
|
+
// Use preset mode
|
|
17
17
|
const sdk = new MemoryXSDK({ preset: 'batch' });
|
|
18
18
|
|
|
19
|
-
//
|
|
20
|
-
await sdk.addMemory("
|
|
19
|
+
// Add memory
|
|
20
|
+
await sdk.addMemory("User prefers Python for data analysis");
|
|
21
21
|
|
|
22
|
-
//
|
|
23
|
-
const results = await sdk.search("
|
|
22
|
+
// Search memories
|
|
23
|
+
const results = await sdk.search("data analysis");
|
|
24
24
|
console.log(results.data);
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
##
|
|
27
|
+
## Send Strategies
|
|
28
28
|
|
|
29
|
-
SDK
|
|
29
|
+
SDK supports flexible send strategy configuration:
|
|
30
30
|
|
|
31
|
-
###
|
|
31
|
+
### Preset Modes
|
|
32
32
|
|
|
33
33
|
```typescript
|
|
34
|
-
//
|
|
34
|
+
// Realtime mode - send immediately
|
|
35
35
|
const sdk = new MemoryXSDK({ preset: 'realtime' });
|
|
36
36
|
|
|
37
|
-
//
|
|
37
|
+
// Batch mode - 50 items or 5 seconds
|
|
38
38
|
const sdk = new MemoryXSDK({ preset: 'batch' });
|
|
39
39
|
|
|
40
|
-
//
|
|
40
|
+
// Conversation mode - 2 rounds or 30 minutes
|
|
41
41
|
const sdk = new MemoryXSDK({ preset: 'conversation' });
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
-
###
|
|
44
|
+
### Custom Strategy
|
|
45
45
|
|
|
46
46
|
```typescript
|
|
47
47
|
const sdk = new MemoryXSDK({
|
|
48
48
|
strategy: {
|
|
49
|
-
rounds: 3, // 3
|
|
50
|
-
batchSize: 100, //
|
|
51
|
-
intervalMs: 60000 //
|
|
49
|
+
rounds: 3, // Send after 3 conversation rounds
|
|
50
|
+
batchSize: 100, // Or 100 messages
|
|
51
|
+
intervalMs: 60000 // Or 1 minute
|
|
52
52
|
}
|
|
53
53
|
});
|
|
54
54
|
```
|
|
55
55
|
|
|
56
|
-
###
|
|
56
|
+
### Fully Custom
|
|
57
57
|
|
|
58
58
|
```typescript
|
|
59
59
|
const sdk = new MemoryXSDK({
|
|
60
60
|
strategy: {
|
|
61
61
|
customTrigger: (stats) => {
|
|
62
|
-
//
|
|
62
|
+
// Custom logic
|
|
63
63
|
return stats.rounds >= 2 || stats.totalTokens >= 4000;
|
|
64
64
|
}
|
|
65
65
|
}
|
|
@@ -68,68 +68,68 @@ const sdk = new MemoryXSDK({
|
|
|
68
68
|
|
|
69
69
|
## API
|
|
70
70
|
|
|
71
|
-
###
|
|
71
|
+
### Memory Operations
|
|
72
72
|
|
|
73
73
|
```typescript
|
|
74
|
-
//
|
|
74
|
+
// Add memory
|
|
75
75
|
await sdk.addMemory(content, metadata?);
|
|
76
76
|
|
|
77
|
-
//
|
|
77
|
+
// Search memories
|
|
78
78
|
const results = await sdk.search(query, limit?);
|
|
79
79
|
|
|
80
|
-
//
|
|
80
|
+
// List memories
|
|
81
81
|
const memories = await sdk.list(limit?, offset?);
|
|
82
82
|
|
|
83
|
-
//
|
|
83
|
+
// Delete memory
|
|
84
84
|
await sdk.delete(memoryId);
|
|
85
85
|
|
|
86
|
-
//
|
|
86
|
+
// Get quota
|
|
87
87
|
const quota = await sdk.getQuota();
|
|
88
88
|
```
|
|
89
89
|
|
|
90
|
-
###
|
|
90
|
+
### Conversation Operations
|
|
91
91
|
|
|
92
92
|
```typescript
|
|
93
|
-
//
|
|
94
|
-
await sdk.addMessage('user', '
|
|
95
|
-
await sdk.addMessage('assistant', '
|
|
93
|
+
// Add conversation message
|
|
94
|
+
await sdk.addMessage('user', 'Hello');
|
|
95
|
+
await sdk.addMessage('assistant', 'Hi! How can I help you?');
|
|
96
96
|
|
|
97
|
-
//
|
|
97
|
+
// Start new conversation
|
|
98
98
|
sdk.startNewConversation();
|
|
99
99
|
```
|
|
100
100
|
|
|
101
|
-
###
|
|
101
|
+
### Queue Operations
|
|
102
102
|
|
|
103
103
|
```typescript
|
|
104
|
-
//
|
|
104
|
+
// Manual flush queue
|
|
105
105
|
await sdk.flush();
|
|
106
106
|
|
|
107
|
-
//
|
|
107
|
+
// Get queue stats
|
|
108
108
|
const stats = await sdk.getQueueStats();
|
|
109
109
|
```
|
|
110
110
|
|
|
111
|
-
##
|
|
111
|
+
## Strategy Parameters
|
|
112
112
|
|
|
113
|
-
|
|
|
114
|
-
|
|
115
|
-
| `rounds` | number | N
|
|
116
|
-
| `batchSize` | number | N
|
|
117
|
-
| `intervalMs` | number | N
|
|
118
|
-
| `maxTokens` | number | N tokens
|
|
119
|
-
| `customTrigger` | function |
|
|
113
|
+
| Parameter | Type | Description |
|
|
114
|
+
|-----------|------|-------------|
|
|
115
|
+
| `rounds` | number | Send after N conversation rounds |
|
|
116
|
+
| `batchSize` | number | Send after N messages |
|
|
117
|
+
| `intervalMs` | number | Send after N milliseconds |
|
|
118
|
+
| `maxTokens` | number | Send after N tokens |
|
|
119
|
+
| `customTrigger` | function | Custom trigger function |
|
|
120
120
|
|
|
121
|
-
##
|
|
121
|
+
## Queue Stats
|
|
122
122
|
|
|
123
123
|
```typescript
|
|
124
124
|
interface QueueStats {
|
|
125
|
-
messageCount: number; //
|
|
126
|
-
rounds: number; //
|
|
127
|
-
totalTokens: number; //
|
|
128
|
-
oldestMessageAge: number; //
|
|
129
|
-
conversationId: string; //
|
|
125
|
+
messageCount: number; // Current message count
|
|
126
|
+
rounds: number; // Current rounds
|
|
127
|
+
totalTokens: number; // Total tokens
|
|
128
|
+
oldestMessageAge: number; // Age of oldest message
|
|
129
|
+
conversationId: string; // Conversation ID
|
|
130
130
|
}
|
|
131
131
|
```
|
|
132
132
|
|
|
133
133
|
## License
|
|
134
134
|
|
|
135
|
-
MIT
|
|
135
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@t0ken.ai/memoryx-sdk",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "MemoryX Node.js SDK -
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "MemoryX Node.js SDK - Enable AI Agents with persistent memory",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"scripts": {
|