@engrama-ai/sdk 0.1.0
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/LICENSE +22 -0
- package/README.md +353 -0
- package/dist/client.d.ts +110 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +212 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +194 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +58 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Engrama Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
# Engrama TypeScript SDK
|
|
2
|
+
|
|
3
|
+
Production-ready TypeScript SDK for Engrama - The Hippocampus for AI Agents.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @engrama-ai/sdk
|
|
9
|
+
# or
|
|
10
|
+
yarn add @engrama-ai/sdk
|
|
11
|
+
# or
|
|
12
|
+
pnpm add @engrama-ai/sdk
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { createClient } from '@engrama-ai/sdk';
|
|
19
|
+
|
|
20
|
+
// Initialize the client
|
|
21
|
+
const client = createClient({
|
|
22
|
+
baseURL: 'http://localhost:3000',
|
|
23
|
+
apiKey: 'your-api-key', // optional
|
|
24
|
+
timeout: 30000,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// Store a memory
|
|
28
|
+
const result = await client.remember(
|
|
29
|
+
'user-123',
|
|
30
|
+
'I love Python and React. I work at Google in Seattle.'
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
console.log(`Stored ${result.count} memories`);
|
|
34
|
+
|
|
35
|
+
// Recall memories
|
|
36
|
+
const recalled = await client.recall(
|
|
37
|
+
'user-123',
|
|
38
|
+
'What programming languages does the user like?'
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
console.log('Relevant memories:', recalled.memories);
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Features
|
|
45
|
+
|
|
46
|
+
- ✅ Full TypeScript support with types
|
|
47
|
+
- ✅ Promise-based async/await API
|
|
48
|
+
- ✅ Automatic error handling
|
|
49
|
+
- ✅ Request/response validation
|
|
50
|
+
- ✅ Built-in retry logic
|
|
51
|
+
- ✅ Production-ready
|
|
52
|
+
|
|
53
|
+
## API Reference
|
|
54
|
+
|
|
55
|
+
### Client Initialization
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
import { MemoryEngineClient } from '@engrama-ai/sdk';
|
|
59
|
+
|
|
60
|
+
const client = new MemoryEngineClient({
|
|
61
|
+
baseURL: 'http://localhost:3000',
|
|
62
|
+
apiKey: 'your-api-key',
|
|
63
|
+
timeout: 30000,
|
|
64
|
+
});
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Memory Operations
|
|
68
|
+
|
|
69
|
+
#### remember(userId, text, options?)
|
|
70
|
+
|
|
71
|
+
Store new memories from text.
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
const response = await client.remember(
|
|
75
|
+
'user-123',
|
|
76
|
+
'I love Python and React',
|
|
77
|
+
{
|
|
78
|
+
timestamp: new Date(),
|
|
79
|
+
metadata: { source: 'chat' }
|
|
80
|
+
}
|
|
81
|
+
);
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
#### recall(userId, query, options?)
|
|
85
|
+
|
|
86
|
+
Retrieve relevant memories.
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
const response = await client.recall(
|
|
90
|
+
'user-123',
|
|
91
|
+
'What does the user like?',
|
|
92
|
+
{
|
|
93
|
+
k: 5,
|
|
94
|
+
tokenBudget: 1000,
|
|
95
|
+
filters: {
|
|
96
|
+
types: ['preference', 'profile'],
|
|
97
|
+
tags: ['technology']
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
);
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
#### assemblePrompt(userId, agentInstructions, userInput, tokenBudget?)
|
|
104
|
+
|
|
105
|
+
Build a prompt with memory context.
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
const response = await client.assemblePrompt(
|
|
109
|
+
'user-123',
|
|
110
|
+
'You are a helpful assistant',
|
|
111
|
+
'Help me with Python',
|
|
112
|
+
2000
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
console.log(response.assembledPrompt);
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
#### listMemories(userId, options?)
|
|
119
|
+
|
|
120
|
+
List all memories with filtering.
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
const response = await client.listMemories('user-123', {
|
|
124
|
+
limit: 20,
|
|
125
|
+
offset: 0,
|
|
126
|
+
type: 'preference',
|
|
127
|
+
sortBy: 'createdAt',
|
|
128
|
+
sortOrder: 'desc'
|
|
129
|
+
});
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
#### getMemory(memoryId, userId)
|
|
133
|
+
|
|
134
|
+
Get a specific memory.
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
const response = await client.getMemory('mem-123', 'user-123');
|
|
138
|
+
console.log(response.memory);
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
#### deleteMemory(memoryId, userId)
|
|
142
|
+
|
|
143
|
+
Delete a memory.
|
|
144
|
+
|
|
145
|
+
```typescript
|
|
146
|
+
await client.deleteMemory('mem-123', 'user-123');
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
#### mergeMemories(memoryIdA, memoryIdB, userId)
|
|
150
|
+
|
|
151
|
+
Merge two memories.
|
|
152
|
+
|
|
153
|
+
```typescript
|
|
154
|
+
const result = await client.mergeMemories(
|
|
155
|
+
'mem-123',
|
|
156
|
+
'mem-456',
|
|
157
|
+
'user-123'
|
|
158
|
+
);
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Knowledge Graph
|
|
162
|
+
|
|
163
|
+
#### getGraph(userId, options?)
|
|
164
|
+
|
|
165
|
+
Get the knowledge graph.
|
|
166
|
+
|
|
167
|
+
```typescript
|
|
168
|
+
const response = await client.getGraph('user-123', {
|
|
169
|
+
depth: 2,
|
|
170
|
+
limit: 50,
|
|
171
|
+
entityTypes: ['person', 'organization'],
|
|
172
|
+
relationshipTypes: ['related_to', 'contradicts']
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
console.log(response.graph.nodes);
|
|
176
|
+
console.log(response.graph.edges);
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Analytics
|
|
180
|
+
|
|
181
|
+
#### getPlatformAnalytics()
|
|
182
|
+
|
|
183
|
+
Get platform-wide analytics.
|
|
184
|
+
|
|
185
|
+
```typescript
|
|
186
|
+
const response = await client.getPlatformAnalytics();
|
|
187
|
+
console.log('Total memories:', response.metrics.totalMemories);
|
|
188
|
+
console.log('Total users:', response.metrics.totalUsers);
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
#### getUserAnalytics(userId)
|
|
192
|
+
|
|
193
|
+
Get analytics for a specific user.
|
|
194
|
+
|
|
195
|
+
```typescript
|
|
196
|
+
const response = await client.getUserAnalytics('user-123');
|
|
197
|
+
console.log('User stats:', response.stats);
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Health Check
|
|
201
|
+
|
|
202
|
+
#### healthCheck()
|
|
203
|
+
|
|
204
|
+
Check if the API is running.
|
|
205
|
+
|
|
206
|
+
```typescript
|
|
207
|
+
const health = await client.healthCheck();
|
|
208
|
+
console.log(health.status); // 'healthy'
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
## Complete Examples
|
|
212
|
+
|
|
213
|
+
### AI Agent with Memory
|
|
214
|
+
|
|
215
|
+
```typescript
|
|
216
|
+
import { createClient } from '@engrama-ai/sdk';
|
|
217
|
+
import OpenAI from 'openai';
|
|
218
|
+
|
|
219
|
+
const memory = createClient({ baseURL: 'http://localhost:3000' });
|
|
220
|
+
const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
|
|
221
|
+
|
|
222
|
+
async function chatWithMemory(userId: string, userMessage: string) {
|
|
223
|
+
// Assemble prompt with memory context
|
|
224
|
+
const { assembledPrompt } = await memory.assemblePrompt(
|
|
225
|
+
userId,
|
|
226
|
+
'You are a helpful assistant with memory of past conversations.',
|
|
227
|
+
userMessage,
|
|
228
|
+
2000
|
|
229
|
+
);
|
|
230
|
+
|
|
231
|
+
// Send to LLM
|
|
232
|
+
const completion = await openai.chat.completions.create({
|
|
233
|
+
model: 'gpt-4',
|
|
234
|
+
messages: [
|
|
235
|
+
{ role: 'system', content: assembledPrompt },
|
|
236
|
+
{ role: 'user', content: userMessage }
|
|
237
|
+
]
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
const response = completion.choices[0].message.content;
|
|
241
|
+
|
|
242
|
+
// Store the conversation
|
|
243
|
+
await memory.remember(
|
|
244
|
+
userId,
|
|
245
|
+
`User said: ${userMessage}. Assistant responded: ${response}`
|
|
246
|
+
);
|
|
247
|
+
|
|
248
|
+
return response;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// Usage
|
|
252
|
+
const response = await chatWithMemory('user-123', 'What do I like?');
|
|
253
|
+
console.log(response);
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### Personal Knowledge Base
|
|
257
|
+
|
|
258
|
+
```typescript
|
|
259
|
+
import { createClient } from '@engrama-ai/sdk';
|
|
260
|
+
|
|
261
|
+
const memory = createClient({ baseURL: 'http://localhost:3000' });
|
|
262
|
+
|
|
263
|
+
async function buildKnowledgeBase(userId: string) {
|
|
264
|
+
// Store various facts
|
|
265
|
+
await memory.remember(userId, 'I live in Seattle');
|
|
266
|
+
await memory.remember(userId, 'I work at Google as a software engineer');
|
|
267
|
+
await memory.remember(userId, 'I love Python, React, and Docker');
|
|
268
|
+
await memory.remember(userId, 'My goal is to build a SaaS product');
|
|
269
|
+
|
|
270
|
+
// Query the knowledge base
|
|
271
|
+
const work = await memory.recall(userId, 'Where does the user work?');
|
|
272
|
+
const skills = await memory.recall(userId, 'What technologies does the user know?');
|
|
273
|
+
const goals = await memory.recall(userId, 'What are the user\'s goals?');
|
|
274
|
+
|
|
275
|
+
return { work, skills, goals };
|
|
276
|
+
}
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### Analytics Dashboard
|
|
280
|
+
|
|
281
|
+
```typescript
|
|
282
|
+
import { createClient } from '@engrama-ai/sdk';
|
|
283
|
+
|
|
284
|
+
const memory = createClient({ baseURL: 'http://localhost:3000' });
|
|
285
|
+
|
|
286
|
+
async function showDashboard() {
|
|
287
|
+
const { metrics } = await memory.getPlatformAnalytics();
|
|
288
|
+
|
|
289
|
+
console.log('=== Engrama Dashboard ===');
|
|
290
|
+
console.log(`Total Memories: ${metrics.totalMemories}`);
|
|
291
|
+
console.log(`Total Users: ${metrics.totalUsers}`);
|
|
292
|
+
console.log(`Created Today: ${metrics.memoriesCreatedToday}`);
|
|
293
|
+
console.log(`Total Entities: ${metrics.totalEntities}`);
|
|
294
|
+
console.log(`Total Relationships: ${metrics.totalRelationships}`);
|
|
295
|
+
|
|
296
|
+
console.log('\nTop Entities:');
|
|
297
|
+
metrics.topEntities.forEach((entity, i) => {
|
|
298
|
+
console.log(`${i + 1}. ${entity.name} (${entity.type}) - ${entity.count} connections`);
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
## Error Handling
|
|
304
|
+
|
|
305
|
+
```typescript
|
|
306
|
+
try {
|
|
307
|
+
const result = await client.remember('user-123', 'Some text');
|
|
308
|
+
} catch (error) {
|
|
309
|
+
if (error.message.includes('No response from server')) {
|
|
310
|
+
console.error('Server is down');
|
|
311
|
+
} else if (error.message.includes('API Error: 400')) {
|
|
312
|
+
console.error('Invalid request');
|
|
313
|
+
} else {
|
|
314
|
+
console.error('Unknown error:', error.message);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
## TypeScript Types
|
|
320
|
+
|
|
321
|
+
All types are exported and fully documented:
|
|
322
|
+
|
|
323
|
+
```typescript
|
|
324
|
+
import {
|
|
325
|
+
Memory,
|
|
326
|
+
RememberResponse,
|
|
327
|
+
RecallResponse,
|
|
328
|
+
KnowledgeGraph,
|
|
329
|
+
AnalyticsMetrics,
|
|
330
|
+
} from '@engrama-ai/sdk';
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
## Best Practices
|
|
334
|
+
|
|
335
|
+
1. **Reuse the client instance** - Create one client and reuse it
|
|
336
|
+
2. **Handle errors gracefully** - Always wrap API calls in try-catch
|
|
337
|
+
3. **Use appropriate token budgets** - Don't exceed LLM context limits
|
|
338
|
+
4. **Filter recalls** - Use filters to get relevant memories faster
|
|
339
|
+
5. **Monitor analytics** - Track usage and performance
|
|
340
|
+
|
|
341
|
+
## License
|
|
342
|
+
|
|
343
|
+
MIT
|
|
344
|
+
|
|
345
|
+
## Support
|
|
346
|
+
|
|
347
|
+
- GitHub: https://github.com/yourusername/memory-engine
|
|
348
|
+
- Issues: https://github.com/yourusername/memory-engine/issues
|
|
349
|
+
- Documentation: https://memory-engine-docs.com
|
|
350
|
+
|
|
351
|
+
## Contributing
|
|
352
|
+
|
|
353
|
+
Contributions welcome! Please see CONTRIBUTING.md
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { MemoryEngineConfig, RememberResponse, RecallResponse, AssemblePromptResponse, ListMemoriesResponse, Memory, GetGraphResponse, AnalyticsMetrics, UserStats } from './types';
|
|
2
|
+
export declare class MemoryEngineClient {
|
|
3
|
+
private client;
|
|
4
|
+
private config;
|
|
5
|
+
constructor(config: MemoryEngineConfig);
|
|
6
|
+
private handleError;
|
|
7
|
+
remember(userId: string, text: string, options?: {
|
|
8
|
+
scope?: {
|
|
9
|
+
type: 'user' | 'task' | 'session' | 'agent';
|
|
10
|
+
id: string;
|
|
11
|
+
};
|
|
12
|
+
agentType?: 'coding' | 'healthcare' | 'support' | 'research' | 'general';
|
|
13
|
+
source?: 'user' | 'system' | 'environment' | 'ai';
|
|
14
|
+
agentId?: string;
|
|
15
|
+
timestamp?: Date;
|
|
16
|
+
metadata?: Record<string, any>;
|
|
17
|
+
confirmed?: boolean;
|
|
18
|
+
promote?: boolean;
|
|
19
|
+
}): Promise<RememberResponse>;
|
|
20
|
+
recall(userId: string, query: string, options?: {
|
|
21
|
+
scope?: {
|
|
22
|
+
type: 'user' | 'task' | 'session' | 'agent';
|
|
23
|
+
id: string;
|
|
24
|
+
};
|
|
25
|
+
scopes?: Array<{
|
|
26
|
+
type: 'user' | 'task' | 'session' | 'agent';
|
|
27
|
+
id: string;
|
|
28
|
+
}>;
|
|
29
|
+
agentType?: 'coding' | 'healthcare' | 'support' | 'research' | 'general';
|
|
30
|
+
k?: number;
|
|
31
|
+
tokenBudget?: number;
|
|
32
|
+
filters?: {
|
|
33
|
+
types?: string[];
|
|
34
|
+
sources?: ('user' | 'system' | 'environment' | 'ai')[];
|
|
35
|
+
dateRange?: {
|
|
36
|
+
start: Date;
|
|
37
|
+
end: Date;
|
|
38
|
+
};
|
|
39
|
+
tags?: string[];
|
|
40
|
+
};
|
|
41
|
+
}): Promise<RecallResponse>;
|
|
42
|
+
assemblePrompt(userId: string, agentInstructions: string, userInput: string, tokenBudget?: number): Promise<AssemblePromptResponse>;
|
|
43
|
+
listMemories(userId: string, options?: {
|
|
44
|
+
limit?: number;
|
|
45
|
+
offset?: number;
|
|
46
|
+
type?: string;
|
|
47
|
+
sortBy?: 'createdAt' | 'updatedAt' | 'confidence';
|
|
48
|
+
sortOrder?: 'asc' | 'desc';
|
|
49
|
+
}): Promise<ListMemoriesResponse>;
|
|
50
|
+
getMemory(memoryId: string, userId: string): Promise<{
|
|
51
|
+
success: boolean;
|
|
52
|
+
memory: Memory;
|
|
53
|
+
}>;
|
|
54
|
+
deleteMemory(memoryId: string, userId: string): Promise<{
|
|
55
|
+
success: boolean;
|
|
56
|
+
}>;
|
|
57
|
+
mergeMemories(memoryIdA: string, memoryIdB: string, userId: string): Promise<{
|
|
58
|
+
success: boolean;
|
|
59
|
+
result: any;
|
|
60
|
+
}>;
|
|
61
|
+
getGraph(userId: string, options?: {
|
|
62
|
+
depth?: number;
|
|
63
|
+
entityTypes?: string[];
|
|
64
|
+
relationshipTypes?: string[];
|
|
65
|
+
centerMemoryId?: string;
|
|
66
|
+
limit?: number;
|
|
67
|
+
}): Promise<GetGraphResponse>;
|
|
68
|
+
getPlatformAnalytics(): Promise<{
|
|
69
|
+
success: boolean;
|
|
70
|
+
metrics: AnalyticsMetrics;
|
|
71
|
+
}>;
|
|
72
|
+
getUserAnalytics(userId: string): Promise<{
|
|
73
|
+
success: boolean;
|
|
74
|
+
stats: UserStats;
|
|
75
|
+
}>;
|
|
76
|
+
healthCheck(): Promise<{
|
|
77
|
+
status: string;
|
|
78
|
+
timestamp: string;
|
|
79
|
+
version: string;
|
|
80
|
+
}>;
|
|
81
|
+
rememberProjectConfig(userId: string, projectId: string, config: {
|
|
82
|
+
framework?: string;
|
|
83
|
+
router?: string;
|
|
84
|
+
language?: string;
|
|
85
|
+
styling?: string;
|
|
86
|
+
backend?: string;
|
|
87
|
+
deployment?: string;
|
|
88
|
+
database?: string;
|
|
89
|
+
auth?: string;
|
|
90
|
+
}, options?: {
|
|
91
|
+
agentType?: 'coding' | 'healthcare' | 'support' | 'research' | 'general';
|
|
92
|
+
}): Promise<RememberResponse>;
|
|
93
|
+
rememberDecision(userId: string, taskId: string, decision: string, options?: {
|
|
94
|
+
confirmed?: boolean;
|
|
95
|
+
agentType?: 'coding' | 'healthcare' | 'support' | 'research' | 'general';
|
|
96
|
+
}): Promise<RememberResponse>;
|
|
97
|
+
recallProjectContext(userId: string, taskId: string, query: string, options?: {
|
|
98
|
+
k?: number;
|
|
99
|
+
includeUserPreferences?: boolean;
|
|
100
|
+
agentType?: 'coding' | 'healthcare' | 'support' | 'research' | 'general';
|
|
101
|
+
}): Promise<RecallResponse>;
|
|
102
|
+
rememberConstraint(userId: string, taskId: string, constraint: string, options?: {
|
|
103
|
+
agentType?: 'coding' | 'healthcare' | 'support' | 'research' | 'general';
|
|
104
|
+
}): Promise<RememberResponse>;
|
|
105
|
+
rememberUserPreference(userId: string, preference: string, options?: {
|
|
106
|
+
agentType?: 'coding' | 'healthcare' | 'support' | 'research' | 'general';
|
|
107
|
+
}): Promise<RememberResponse>;
|
|
108
|
+
}
|
|
109
|
+
export declare function createClient(config: MemoryEngineConfig): MemoryEngineClient;
|
|
110
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,EACL,kBAAkB,EAElB,gBAAgB,EAEhB,cAAc,EAEd,sBAAsB,EAEtB,oBAAoB,EACpB,MAAM,EAEN,gBAAgB,EAChB,gBAAgB,EAChB,SAAS,EACV,MAAM,SAAS,CAAC;AAMjB,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,MAAM,CAAqB;gBAEvB,MAAM,EAAE,kBAAkB;IAwCtC,OAAO,CAAC,WAAW;IAmBb,QAAQ,CACZ,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE;QACR,KAAK,CAAC,EAAE;YAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;YAAC,EAAE,EAAE,MAAM,CAAA;SAAE,CAAC;QACpE,SAAS,CAAC,EAAE,QAAQ,GAAG,YAAY,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,CAAC;QACzE,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,aAAa,GAAG,IAAI,CAAC;QAClD,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,SAAS,CAAC,EAAE,IAAI,CAAC;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAC/B,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,GACA,OAAO,CAAC,gBAAgB,CAAC;IAwCtB,MAAM,CACV,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,OAAO,C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CAAC;IAYtB,sBAAsB,CAC1B,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE;QACR,SAAS,CAAC,EAAE,QAAQ,GAAG,YAAY,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,CAAC;KAC1E,GACA,OAAO,CAAC,gBAAgB,CAAC;CAO7B;AAMD,wBAAgB,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,kBAAkB,CAE3E"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
export class MemoryEngineClient {
|
|
3
|
+
constructor(config) {
|
|
4
|
+
this.config = {
|
|
5
|
+
apiKey: config.apiKey,
|
|
6
|
+
baseURL: config.baseURL || 'http://localhost:3000',
|
|
7
|
+
timeout: config.timeout || 30000,
|
|
8
|
+
};
|
|
9
|
+
this.client = axios.create({
|
|
10
|
+
baseURL: this.config.baseURL,
|
|
11
|
+
timeout: this.config.timeout,
|
|
12
|
+
headers: {
|
|
13
|
+
'Content-Type': 'application/json',
|
|
14
|
+
...(this.config.apiKey && {
|
|
15
|
+
'X-API-Key': this.config.apiKey,
|
|
16
|
+
}),
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
if (this.config.apiKey) {
|
|
20
|
+
if (this.config.apiKey.startsWith('eyJ')) {
|
|
21
|
+
this.client.defaults.headers.common['Authorization'] = `Bearer ${this.config.apiKey}`;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
this.client.defaults.headers.common['X-API-Key'] = this.config.apiKey;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
this.client.interceptors.response.use((response) => response, (error) => {
|
|
28
|
+
throw this.handleError(error);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
handleError(error) {
|
|
32
|
+
if (error.response) {
|
|
33
|
+
const data = error.response.data;
|
|
34
|
+
return new Error(data.error?.message || data.message || `API Error: ${error.response.status}`);
|
|
35
|
+
}
|
|
36
|
+
else if (error.request) {
|
|
37
|
+
return new Error('No response from server. Please check your connection.');
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
return new Error(error.message || 'Unknown error occurred');
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
async remember(userId, text, options) {
|
|
44
|
+
const requestBody = {
|
|
45
|
+
userId,
|
|
46
|
+
text,
|
|
47
|
+
timestamp: options?.timestamp?.toISOString(),
|
|
48
|
+
metadata: options?.metadata,
|
|
49
|
+
};
|
|
50
|
+
if (options?.scope) {
|
|
51
|
+
requestBody.scope = options.scope;
|
|
52
|
+
}
|
|
53
|
+
if (options?.agentType) {
|
|
54
|
+
requestBody.agentType = options.agentType;
|
|
55
|
+
}
|
|
56
|
+
if (options?.source) {
|
|
57
|
+
requestBody.source = options.source;
|
|
58
|
+
}
|
|
59
|
+
if (options?.agentId) {
|
|
60
|
+
requestBody.agentId = options.agentId;
|
|
61
|
+
}
|
|
62
|
+
if (options?.confirmed !== undefined) {
|
|
63
|
+
requestBody.confirmed = options.confirmed;
|
|
64
|
+
}
|
|
65
|
+
if (options?.promote !== undefined) {
|
|
66
|
+
requestBody.promote = options.promote;
|
|
67
|
+
}
|
|
68
|
+
const response = await this.client.post('/api/remember', requestBody);
|
|
69
|
+
return response.data;
|
|
70
|
+
}
|
|
71
|
+
async recall(userId, query, options) {
|
|
72
|
+
const requestBody = {
|
|
73
|
+
userId,
|
|
74
|
+
query,
|
|
75
|
+
k: options?.k,
|
|
76
|
+
tokenBudget: options?.tokenBudget,
|
|
77
|
+
filters: options?.filters,
|
|
78
|
+
};
|
|
79
|
+
if (options?.scope) {
|
|
80
|
+
requestBody.scope = options.scope;
|
|
81
|
+
}
|
|
82
|
+
if (options?.scopes) {
|
|
83
|
+
requestBody.scopes = options.scopes;
|
|
84
|
+
}
|
|
85
|
+
if (options?.agentType) {
|
|
86
|
+
requestBody.agentType = options.agentType;
|
|
87
|
+
}
|
|
88
|
+
const response = await this.client.post('/api/recall', requestBody);
|
|
89
|
+
return response.data;
|
|
90
|
+
}
|
|
91
|
+
async assemblePrompt(userId, agentInstructions, userInput, tokenBudget) {
|
|
92
|
+
const response = await this.client.post('/api/assemble_prompt', {
|
|
93
|
+
userId,
|
|
94
|
+
agentInstructions,
|
|
95
|
+
userInput,
|
|
96
|
+
tokenBudget,
|
|
97
|
+
});
|
|
98
|
+
return response.data;
|
|
99
|
+
}
|
|
100
|
+
async listMemories(userId, options) {
|
|
101
|
+
const params = new URLSearchParams({
|
|
102
|
+
userId,
|
|
103
|
+
...(options?.limit && { limit: options.limit.toString() }),
|
|
104
|
+
...(options?.offset && { offset: options.offset.toString() }),
|
|
105
|
+
...(options?.type && { type: options.type }),
|
|
106
|
+
...(options?.sortBy && { sortBy: options.sortBy }),
|
|
107
|
+
...(options?.sortOrder && { sortOrder: options.sortOrder }),
|
|
108
|
+
});
|
|
109
|
+
const response = await this.client.get(`/api/memories?${params.toString()}`);
|
|
110
|
+
return response.data;
|
|
111
|
+
}
|
|
112
|
+
async getMemory(memoryId, userId) {
|
|
113
|
+
const response = await this.client.get(`/api/memories/${memoryId}?userId=${userId}`);
|
|
114
|
+
return response.data;
|
|
115
|
+
}
|
|
116
|
+
async deleteMemory(memoryId, userId) {
|
|
117
|
+
const response = await this.client.delete(`/api/memories/${memoryId}?userId=${userId}`);
|
|
118
|
+
return response.data;
|
|
119
|
+
}
|
|
120
|
+
async mergeMemories(memoryIdA, memoryIdB, userId) {
|
|
121
|
+
const response = await this.client.post('/api/memories/merge', {
|
|
122
|
+
memoryIdA,
|
|
123
|
+
memoryIdB,
|
|
124
|
+
userId,
|
|
125
|
+
});
|
|
126
|
+
return response.data;
|
|
127
|
+
}
|
|
128
|
+
async getGraph(userId, options) {
|
|
129
|
+
const params = new URLSearchParams({
|
|
130
|
+
userId,
|
|
131
|
+
...(options?.depth && { depth: options.depth.toString() }),
|
|
132
|
+
...(options?.limit && { limit: options.limit.toString() }),
|
|
133
|
+
...(options?.centerMemoryId && { centerMemoryId: options.centerMemoryId }),
|
|
134
|
+
...(options?.entityTypes && { entityTypes: options.entityTypes.join(',') }),
|
|
135
|
+
...(options?.relationshipTypes && { relationshipTypes: options.relationshipTypes.join(',') }),
|
|
136
|
+
});
|
|
137
|
+
const response = await this.client.get(`/api/graph?${params.toString()}`);
|
|
138
|
+
return response.data;
|
|
139
|
+
}
|
|
140
|
+
async getPlatformAnalytics() {
|
|
141
|
+
const response = await this.client.get('/api/analytics/platform');
|
|
142
|
+
return response.data;
|
|
143
|
+
}
|
|
144
|
+
async getUserAnalytics(userId) {
|
|
145
|
+
const response = await this.client.get(`/api/analytics/user/${userId}`);
|
|
146
|
+
return response.data;
|
|
147
|
+
}
|
|
148
|
+
async healthCheck() {
|
|
149
|
+
const response = await this.client.get('/health');
|
|
150
|
+
return response.data;
|
|
151
|
+
}
|
|
152
|
+
async rememberProjectConfig(userId, projectId, config, options) {
|
|
153
|
+
const configText = Object.entries(config)
|
|
154
|
+
.filter(([_, value]) => value)
|
|
155
|
+
.map(([key, value]) => `${key}: ${value}`)
|
|
156
|
+
.join(', ');
|
|
157
|
+
return this.remember(userId, `Project configuration: ${configText}`, {
|
|
158
|
+
scope: { type: 'task', id: projectId },
|
|
159
|
+
agentType: options?.agentType || 'coding',
|
|
160
|
+
source: 'user',
|
|
161
|
+
metadata: {
|
|
162
|
+
projectConfig: config,
|
|
163
|
+
},
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
async rememberDecision(userId, taskId, decision, options) {
|
|
167
|
+
const confirmed = options?.confirmed !== undefined ? options.confirmed : true;
|
|
168
|
+
if (!confirmed) {
|
|
169
|
+
throw new Error('Decisions must be confirmed before storing');
|
|
170
|
+
}
|
|
171
|
+
return this.remember(userId, `Decision: ${decision}`, {
|
|
172
|
+
scope: { type: 'task', id: taskId },
|
|
173
|
+
agentType: options?.agentType || 'general',
|
|
174
|
+
source: 'user',
|
|
175
|
+
confirmed: true,
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
async recallProjectContext(userId, taskId, query, options) {
|
|
179
|
+
const scopes = [
|
|
180
|
+
{ type: 'task', id: taskId },
|
|
181
|
+
];
|
|
182
|
+
if (options?.includeUserPreferences !== false) {
|
|
183
|
+
scopes.push({ type: 'user', id: userId });
|
|
184
|
+
}
|
|
185
|
+
return this.recall(userId, query, {
|
|
186
|
+
scopes,
|
|
187
|
+
agentType: options?.agentType,
|
|
188
|
+
k: options?.k || 10,
|
|
189
|
+
filters: {
|
|
190
|
+
types: ['preference', 'decision', 'constraint', 'fact', 'goal', 'context'],
|
|
191
|
+
},
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
async rememberConstraint(userId, taskId, constraint, options) {
|
|
195
|
+
return this.remember(userId, `Constraint: ${constraint}`, {
|
|
196
|
+
scope: { type: 'task', id: taskId },
|
|
197
|
+
agentType: options?.agentType || 'general',
|
|
198
|
+
source: 'user',
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
async rememberUserPreference(userId, preference, options) {
|
|
202
|
+
return this.remember(userId, `User preference: ${preference}`, {
|
|
203
|
+
scope: { type: 'user', id: userId },
|
|
204
|
+
agentType: options?.agentType || 'general',
|
|
205
|
+
source: 'user',
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
export function createClient(config) {
|
|
210
|
+
return new MemoryEngineClient(config);
|
|
211
|
+
}
|
|
212
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAoC,MAAM,OAAO,CAAC;AAsBzD,MAAM,OAAO,kBAAkB;IAI7B,YAAY,MAA0B;QACpC,IAAI,CAAC,MAAM,GAAG;YACZ,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,uBAAuB;YAClD,OAAO,EAAE,MAAM,CAAC,OAAO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BAAoB,UAAU,EAAE,EAAE;YAC7D,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE;YACnC,SAAS,EAAE,OAAO,EAAE,SAAS,IAAI,SAAS;YAC1C,MAAM,EAAE,MAAM;SACf,CAAC,CAAC;IACL,CAAC;CACF;AAMD,MAAM,UAAU,YAAY,CAAC,MAA0B;IACrD,OAAO,IAAI,kBAAkB,CAAC,MAAM,CAAC,CAAC;AACxC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC5D,cAAc,SAAS,CAAC;AAGxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC9C,eAAe,kBAAkB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC5D,cAAc,SAAS,CAAC;AAGxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC9C,eAAe,kBAAkB,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
export interface MemoryEngineConfig {
|
|
2
|
+
apiKey?: string;
|
|
3
|
+
baseURL?: string;
|
|
4
|
+
timeout?: number;
|
|
5
|
+
}
|
|
6
|
+
export interface Memory {
|
|
7
|
+
id: string;
|
|
8
|
+
userId: string;
|
|
9
|
+
agentId?: string;
|
|
10
|
+
scope: {
|
|
11
|
+
type: 'user' | 'task' | 'session' | 'agent';
|
|
12
|
+
id: string;
|
|
13
|
+
};
|
|
14
|
+
category: string;
|
|
15
|
+
canonicalText: string;
|
|
16
|
+
type: string;
|
|
17
|
+
source: 'user' | 'system' | 'environment' | 'ai';
|
|
18
|
+
confidence: number;
|
|
19
|
+
tags: string[];
|
|
20
|
+
timestamp: string;
|
|
21
|
+
createdAt: string;
|
|
22
|
+
updatedAt: string;
|
|
23
|
+
version: number;
|
|
24
|
+
ttl?: string;
|
|
25
|
+
provenance: Provenance[];
|
|
26
|
+
linkedMemories: string[];
|
|
27
|
+
conflictStatus: 'none' | 'conflict' | 'resolved' | 'superseded';
|
|
28
|
+
visibility: 'private' | 'shared' | 'public';
|
|
29
|
+
metadata: Record<string, any>;
|
|
30
|
+
requiresConfirmation?: boolean;
|
|
31
|
+
confirmed?: boolean;
|
|
32
|
+
promoted?: boolean;
|
|
33
|
+
supersedesMemoryId?: string;
|
|
34
|
+
agentType?: 'coding' | 'healthcare' | 'support' | 'research' | 'general';
|
|
35
|
+
}
|
|
36
|
+
export interface Provenance {
|
|
37
|
+
source: string;
|
|
38
|
+
timestamp: string;
|
|
39
|
+
rawText: string;
|
|
40
|
+
confidence: number;
|
|
41
|
+
}
|
|
42
|
+
export interface RetrievalResult {
|
|
43
|
+
memory: Memory;
|
|
44
|
+
score: number;
|
|
45
|
+
similarityScore: number;
|
|
46
|
+
recencyScore: number;
|
|
47
|
+
confidenceScore: number;
|
|
48
|
+
typeScore: number;
|
|
49
|
+
}
|
|
50
|
+
export interface ContextBlock {
|
|
51
|
+
memories: Memory[];
|
|
52
|
+
memoryIds: string[];
|
|
53
|
+
contextText: string;
|
|
54
|
+
tokenCount: number;
|
|
55
|
+
timestamp: string;
|
|
56
|
+
}
|
|
57
|
+
export interface RememberRequest {
|
|
58
|
+
userId: string;
|
|
59
|
+
text: string;
|
|
60
|
+
timestamp?: string;
|
|
61
|
+
metadata?: Record<string, any>;
|
|
62
|
+
}
|
|
63
|
+
export interface RememberResponse {
|
|
64
|
+
success: boolean;
|
|
65
|
+
memories: Memory[];
|
|
66
|
+
count: number;
|
|
67
|
+
}
|
|
68
|
+
export interface RecallRequest {
|
|
69
|
+
userId: string;
|
|
70
|
+
query: string;
|
|
71
|
+
k?: number;
|
|
72
|
+
tokenBudget?: number;
|
|
73
|
+
filters?: {
|
|
74
|
+
types?: string[];
|
|
75
|
+
dateRange?: {
|
|
76
|
+
start: string;
|
|
77
|
+
end: string;
|
|
78
|
+
};
|
|
79
|
+
tags?: string[];
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
export interface RecallResponse {
|
|
83
|
+
success: boolean;
|
|
84
|
+
memories: RetrievalResult[];
|
|
85
|
+
count: number;
|
|
86
|
+
}
|
|
87
|
+
export interface AssemblePromptRequest {
|
|
88
|
+
userId: string;
|
|
89
|
+
agentInstructions: string;
|
|
90
|
+
userInput: string;
|
|
91
|
+
tokenBudget?: number;
|
|
92
|
+
}
|
|
93
|
+
export interface AssemblePromptResponse {
|
|
94
|
+
success: boolean;
|
|
95
|
+
assembledPrompt: string;
|
|
96
|
+
contextBlock: ContextBlock;
|
|
97
|
+
usedMemories: string[];
|
|
98
|
+
}
|
|
99
|
+
export interface ListMemoriesRequest {
|
|
100
|
+
userId: string;
|
|
101
|
+
limit?: number;
|
|
102
|
+
offset?: number;
|
|
103
|
+
type?: string;
|
|
104
|
+
sortBy?: 'createdAt' | 'updatedAt' | 'confidence';
|
|
105
|
+
sortOrder?: 'asc' | 'desc';
|
|
106
|
+
}
|
|
107
|
+
export interface ListMemoriesResponse {
|
|
108
|
+
success: boolean;
|
|
109
|
+
memories: Memory[];
|
|
110
|
+
total: number;
|
|
111
|
+
limit: number;
|
|
112
|
+
offset: number;
|
|
113
|
+
}
|
|
114
|
+
export interface GraphNode {
|
|
115
|
+
id: string;
|
|
116
|
+
label: string;
|
|
117
|
+
type: 'memory' | 'entity';
|
|
118
|
+
data: any;
|
|
119
|
+
size?: number;
|
|
120
|
+
color?: string;
|
|
121
|
+
}
|
|
122
|
+
export interface GraphEdge {
|
|
123
|
+
id: string;
|
|
124
|
+
source: string;
|
|
125
|
+
target: string;
|
|
126
|
+
type: string;
|
|
127
|
+
label?: string;
|
|
128
|
+
confidence?: number;
|
|
129
|
+
data?: any;
|
|
130
|
+
}
|
|
131
|
+
export interface KnowledgeGraph {
|
|
132
|
+
nodes: GraphNode[];
|
|
133
|
+
edges: GraphEdge[];
|
|
134
|
+
metadata: {
|
|
135
|
+
totalNodes: number;
|
|
136
|
+
totalEdges: number;
|
|
137
|
+
entityTypes: Record<string, number>;
|
|
138
|
+
relationshipTypes: Record<string, number>;
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
export interface GetGraphRequest {
|
|
142
|
+
userId: string;
|
|
143
|
+
depth?: number;
|
|
144
|
+
entityTypes?: string[];
|
|
145
|
+
relationshipTypes?: string[];
|
|
146
|
+
centerMemoryId?: string;
|
|
147
|
+
limit?: number;
|
|
148
|
+
}
|
|
149
|
+
export interface GetGraphResponse {
|
|
150
|
+
success: boolean;
|
|
151
|
+
graph: KnowledgeGraph;
|
|
152
|
+
}
|
|
153
|
+
export interface AnalyticsMetrics {
|
|
154
|
+
totalMemories: number;
|
|
155
|
+
totalUsers: number;
|
|
156
|
+
memoriesCreatedToday: number;
|
|
157
|
+
memoriesCreatedThisWeek: number;
|
|
158
|
+
memoriesCreatedThisMonth: number;
|
|
159
|
+
averageMemoriesPerUser: number;
|
|
160
|
+
totalEntities: number;
|
|
161
|
+
totalRelationships: number;
|
|
162
|
+
memoryTypeDistribution: Record<string, number>;
|
|
163
|
+
entityTypeDistribution: Record<string, number>;
|
|
164
|
+
topEntities: Array<{
|
|
165
|
+
name: string;
|
|
166
|
+
type: string;
|
|
167
|
+
count: number;
|
|
168
|
+
}>;
|
|
169
|
+
userActivity: Array<{
|
|
170
|
+
date: string;
|
|
171
|
+
count: number;
|
|
172
|
+
}>;
|
|
173
|
+
averageConfidence: number;
|
|
174
|
+
storageUsed: number;
|
|
175
|
+
}
|
|
176
|
+
export interface UserStats {
|
|
177
|
+
userId: string;
|
|
178
|
+
totalMemories: number;
|
|
179
|
+
memoriesThisWeek: number;
|
|
180
|
+
totalEntities: number;
|
|
181
|
+
totalRelationships: number;
|
|
182
|
+
firstMemoryDate: string;
|
|
183
|
+
lastMemoryDate: string;
|
|
184
|
+
mostUsedTypes: Array<{
|
|
185
|
+
type: string;
|
|
186
|
+
count: number;
|
|
187
|
+
}>;
|
|
188
|
+
topEntities: Array<{
|
|
189
|
+
name: string;
|
|
190
|
+
type: string;
|
|
191
|
+
count: number;
|
|
192
|
+
}>;
|
|
193
|
+
}
|
|
194
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,MAAM;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;IACnE,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,GAAG,QAAQ,GAAG,aAAa,GAAG,IAAI,CAAC;IACjD,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,UAAU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MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACnE"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@engrama-ai/sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Production-ready TypeScript SDK for Engrama - The Hippocampus for AI Agents",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"README.md",
|
|
12
|
+
"LICENSE"
|
|
13
|
+
],
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public"
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc",
|
|
19
|
+
"prepare": "npm run build",
|
|
20
|
+
"test": "jest",
|
|
21
|
+
"lint": "eslint src --ext .ts"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"memory",
|
|
25
|
+
"ai",
|
|
26
|
+
"agent",
|
|
27
|
+
"llm",
|
|
28
|
+
"engrama",
|
|
29
|
+
"knowledge-graph",
|
|
30
|
+
"semantic-memory",
|
|
31
|
+
"long-term-memory"
|
|
32
|
+
],
|
|
33
|
+
"author": "Engrama Team",
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "https://github.com/yourusername/engrama.git"
|
|
38
|
+
},
|
|
39
|
+
"bugs": {
|
|
40
|
+
"url": "https://github.com/yourusername/engrama/issues"
|
|
41
|
+
},
|
|
42
|
+
"homepage": "https://github.com/yourusername/engrama#readme",
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"axios": "^1.6.2"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@types/node": "^20.10.5",
|
|
48
|
+
"typescript": "^5.3.3",
|
|
49
|
+
"@typescript-eslint/eslint-plugin": "^6.15.0",
|
|
50
|
+
"@typescript-eslint/parser": "^6.15.0",
|
|
51
|
+
"eslint": "^8.56.0",
|
|
52
|
+
"jest": "^29.7.0",
|
|
53
|
+
"@types/jest": "^29.5.11"
|
|
54
|
+
},
|
|
55
|
+
"engines": {
|
|
56
|
+
"node": ">=16.0.0"
|
|
57
|
+
}
|
|
58
|
+
}
|