@engrama-ai/sdk 0.1.0 → 2.0.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/dist/client.d.ts +43 -22
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +100 -36
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -4
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +66 -7
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +6 -1
- package/dist/types.js.map +1 -1
- package/package.json +20 -58
- package/LICENSE +0 -22
- package/README.md +0 -353
package/dist/client.d.ts
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import { MemoryEngineConfig, RememberResponse, RecallResponse, AssemblePromptResponse, ListMemoriesResponse, Memory, GetGraphResponse, AnalyticsMetrics, UserStats } from './types';
|
|
1
|
+
import { MemoryEngineConfig, RememberResponse, RecallResponse, AssemblePromptResponse, ListMemoriesResponse, Memory, GetGraphResponse, AnalyticsMetrics, UserStats, MemoryScope, RecallFilters, ContextResponse, MemoryExtractResponse, ConversationMessage } from './types';
|
|
2
2
|
export declare class MemoryEngineClient {
|
|
3
3
|
private client;
|
|
4
4
|
private config;
|
|
5
5
|
constructor(config: MemoryEngineConfig);
|
|
6
6
|
private handleError;
|
|
7
7
|
remember(userId: string, text: string, options?: {
|
|
8
|
-
scope?:
|
|
9
|
-
type: 'user' | 'task' | 'session' | 'agent';
|
|
10
|
-
id: string;
|
|
11
|
-
};
|
|
8
|
+
scope?: MemoryScope;
|
|
12
9
|
agentType?: 'coding' | 'healthcare' | 'support' | 'research' | 'general';
|
|
13
10
|
source?: 'user' | 'system' | 'environment' | 'ai';
|
|
14
11
|
agentId?: string;
|
|
@@ -18,28 +15,52 @@ export declare class MemoryEngineClient {
|
|
|
18
15
|
promote?: boolean;
|
|
19
16
|
}): Promise<RememberResponse>;
|
|
20
17
|
recall(userId: string, query: string, options?: {
|
|
21
|
-
scope?:
|
|
22
|
-
|
|
23
|
-
id: string;
|
|
24
|
-
};
|
|
25
|
-
scopes?: Array<{
|
|
26
|
-
type: 'user' | 'task' | 'session' | 'agent';
|
|
27
|
-
id: string;
|
|
28
|
-
}>;
|
|
18
|
+
scope?: MemoryScope;
|
|
19
|
+
scopes?: MemoryScope[];
|
|
29
20
|
agentType?: 'coding' | 'healthcare' | 'support' | 'research' | 'general';
|
|
30
21
|
k?: number;
|
|
31
22
|
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
|
-
};
|
|
23
|
+
filters?: RecallFilters;
|
|
41
24
|
}): Promise<RecallResponse>;
|
|
42
25
|
assemblePrompt(userId: string, agentInstructions: string, userInput: string, tokenBudget?: number): Promise<AssemblePromptResponse>;
|
|
26
|
+
/**
|
|
27
|
+
* Get complete memory context for a user query.
|
|
28
|
+
* Returns memories, entities, preferences, and a pre-assembled context block
|
|
29
|
+
* ready for LLM injection.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* const ctx = await client.context(userId, 'What is the user working on?');
|
|
33
|
+
* console.log(ctx.context.assembledContext); // Ready to inject into system prompt
|
|
34
|
+
*/
|
|
35
|
+
context(userId: string, query: string, options?: {
|
|
36
|
+
tokenBudget?: number;
|
|
37
|
+
scope?: MemoryScope;
|
|
38
|
+
scopes?: MemoryScope[];
|
|
39
|
+
includeEntities?: boolean;
|
|
40
|
+
includePreferences?: boolean;
|
|
41
|
+
k?: number;
|
|
42
|
+
agent?: string;
|
|
43
|
+
}): Promise<ContextResponse>;
|
|
44
|
+
/**
|
|
45
|
+
* Extract and store memories from a full conversation transcript.
|
|
46
|
+
* Automatically filters for user messages, extracts meaningful facts,
|
|
47
|
+
* deduplicates against existing memories, and stores new ones.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* await client.rememberConversation(userId, [
|
|
51
|
+
* { role: 'user', content: 'I prefer dark mode' },
|
|
52
|
+
* { role: 'assistant', content: 'Noted!' },
|
|
53
|
+
* { role: 'user', content: "I'm building a Next.js app" },
|
|
54
|
+
* ], { scope: { type: 'user', id: userId } });
|
|
55
|
+
*/
|
|
56
|
+
rememberConversation(userId: string, conversation: ConversationMessage[], options?: {
|
|
57
|
+
scope?: MemoryScope;
|
|
58
|
+
source?: 'user' | 'system' | 'environment' | 'ai';
|
|
59
|
+
agentType?: 'coding' | 'healthcare' | 'support' | 'research' | 'general';
|
|
60
|
+
agentId?: string;
|
|
61
|
+
agent?: string;
|
|
62
|
+
metadata?: Record<string, any>;
|
|
63
|
+
}): Promise<MemoryExtractResponse>;
|
|
43
64
|
listMemories(userId: string, options?: {
|
|
44
65
|
limit?: number;
|
|
45
66
|
offset?: number;
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,EACL,kBAAkB,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,sBAAsB,EACtB,oBAAoB,EACpB,MAAM,EACN,gBAAgB,EAChB,gBAAgB,EAChB,SAAS,EACT,WAAW,EACX,aAAa,EACb,eAAe,EACf,qBAAqB,EACrB,mBAAmB,EACpB,MAAM,SAAS,CAAC;AAEjB,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,MAAM,CAA+B;gBAEjC,MAAM,EAAE,kBAAkB;IA2BtC,OAAO,CAAC,WAAW;IAiBb,QAAQ,CACZ,MAAM,EAAE,MAAM,EACd,IAA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E3E"}
|
package/dist/client.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.MemoryEngineClient = void 0;
|
|
7
|
+
exports.createClient = createClient;
|
|
8
|
+
const axios_1 = __importDefault(require("axios"));
|
|
9
|
+
class MemoryEngineClient {
|
|
3
10
|
constructor(config) {
|
|
4
11
|
this.config = {
|
|
5
|
-
apiKey: config.apiKey,
|
|
12
|
+
apiKey: config.apiKey || '',
|
|
6
13
|
baseURL: config.baseURL || 'http://localhost:3000',
|
|
7
14
|
timeout: config.timeout || 30000,
|
|
8
15
|
};
|
|
9
|
-
this.client =
|
|
16
|
+
this.client = axios_1.default.create({
|
|
10
17
|
baseURL: this.config.baseURL,
|
|
11
18
|
timeout: this.config.timeout,
|
|
12
19
|
headers: {
|
|
13
20
|
'Content-Type': 'application/json',
|
|
14
21
|
...(this.config.apiKey && {
|
|
15
22
|
'X-API-Key': this.config.apiKey,
|
|
23
|
+
Authorization: `Bearer ${this.config.apiKey}`,
|
|
16
24
|
}),
|
|
17
25
|
},
|
|
18
26
|
});
|
|
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
27
|
this.client.interceptors.response.use((response) => response, (error) => {
|
|
28
28
|
throw this.handleError(error);
|
|
29
29
|
});
|
|
@@ -31,7 +31,7 @@ export class MemoryEngineClient {
|
|
|
31
31
|
handleError(error) {
|
|
32
32
|
if (error.response) {
|
|
33
33
|
const data = error.response.data;
|
|
34
|
-
return new Error(data.error?.message || data.message || `API Error: ${error.response.status}`);
|
|
34
|
+
return new Error(data.error?.message || data.message || data.error || `API Error: ${error.response.status}`);
|
|
35
35
|
}
|
|
36
36
|
else if (error.request) {
|
|
37
37
|
return new Error('No response from server. Please check your connection.');
|
|
@@ -40,6 +40,9 @@ export class MemoryEngineClient {
|
|
|
40
40
|
return new Error(error.message || 'Unknown error occurred');
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
+
// =============================================
|
|
44
|
+
// Core Memory APIs
|
|
45
|
+
// =============================================
|
|
43
46
|
async remember(userId, text, options) {
|
|
44
47
|
const requestBody = {
|
|
45
48
|
userId,
|
|
@@ -47,24 +50,18 @@ export class MemoryEngineClient {
|
|
|
47
50
|
timestamp: options?.timestamp?.toISOString(),
|
|
48
51
|
metadata: options?.metadata,
|
|
49
52
|
};
|
|
50
|
-
if (options?.scope)
|
|
53
|
+
if (options?.scope)
|
|
51
54
|
requestBody.scope = options.scope;
|
|
52
|
-
|
|
53
|
-
if (options?.agentType) {
|
|
55
|
+
if (options?.agentType)
|
|
54
56
|
requestBody.agentType = options.agentType;
|
|
55
|
-
|
|
56
|
-
if (options?.source) {
|
|
57
|
+
if (options?.source)
|
|
57
58
|
requestBody.source = options.source;
|
|
58
|
-
|
|
59
|
-
if (options?.agentId) {
|
|
59
|
+
if (options?.agentId)
|
|
60
60
|
requestBody.agentId = options.agentId;
|
|
61
|
-
|
|
62
|
-
if (options?.confirmed !== undefined) {
|
|
61
|
+
if (options?.confirmed !== undefined)
|
|
63
62
|
requestBody.confirmed = options.confirmed;
|
|
64
|
-
|
|
65
|
-
if (options?.promote !== undefined) {
|
|
63
|
+
if (options?.promote !== undefined)
|
|
66
64
|
requestBody.promote = options.promote;
|
|
67
|
-
}
|
|
68
65
|
const response = await this.client.post('/api/remember', requestBody);
|
|
69
66
|
return response.data;
|
|
70
67
|
}
|
|
@@ -76,15 +73,12 @@ export class MemoryEngineClient {
|
|
|
76
73
|
tokenBudget: options?.tokenBudget,
|
|
77
74
|
filters: options?.filters,
|
|
78
75
|
};
|
|
79
|
-
if (options?.scope)
|
|
76
|
+
if (options?.scope)
|
|
80
77
|
requestBody.scope = options.scope;
|
|
81
|
-
|
|
82
|
-
if (options?.scopes) {
|
|
78
|
+
if (options?.scopes)
|
|
83
79
|
requestBody.scopes = options.scopes;
|
|
84
|
-
|
|
85
|
-
if (options?.agentType) {
|
|
80
|
+
if (options?.agentType)
|
|
86
81
|
requestBody.agentType = options.agentType;
|
|
87
|
-
}
|
|
88
82
|
const response = await this.client.post('/api/recall', requestBody);
|
|
89
83
|
return response.data;
|
|
90
84
|
}
|
|
@@ -97,6 +91,63 @@ export class MemoryEngineClient {
|
|
|
97
91
|
});
|
|
98
92
|
return response.data;
|
|
99
93
|
}
|
|
94
|
+
// =============================================
|
|
95
|
+
// NEW: Universal Context API (Phase 1)
|
|
96
|
+
// =============================================
|
|
97
|
+
/**
|
|
98
|
+
* Get complete memory context for a user query.
|
|
99
|
+
* Returns memories, entities, preferences, and a pre-assembled context block
|
|
100
|
+
* ready for LLM injection.
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* const ctx = await client.context(userId, 'What is the user working on?');
|
|
104
|
+
* console.log(ctx.context.assembledContext); // Ready to inject into system prompt
|
|
105
|
+
*/
|
|
106
|
+
async context(userId, query, options) {
|
|
107
|
+
const response = await this.client.post('/api/context', {
|
|
108
|
+
userId,
|
|
109
|
+
query,
|
|
110
|
+
tokenBudget: options?.tokenBudget,
|
|
111
|
+
scope: options?.scope,
|
|
112
|
+
scopes: options?.scopes,
|
|
113
|
+
includeEntities: options?.includeEntities,
|
|
114
|
+
includePreferences: options?.includePreferences,
|
|
115
|
+
k: options?.k,
|
|
116
|
+
agent: options?.agent,
|
|
117
|
+
});
|
|
118
|
+
return response.data;
|
|
119
|
+
}
|
|
120
|
+
// =============================================
|
|
121
|
+
// NEW: Conversation Memory Extraction (Phase 2)
|
|
122
|
+
// =============================================
|
|
123
|
+
/**
|
|
124
|
+
* Extract and store memories from a full conversation transcript.
|
|
125
|
+
* Automatically filters for user messages, extracts meaningful facts,
|
|
126
|
+
* deduplicates against existing memories, and stores new ones.
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* await client.rememberConversation(userId, [
|
|
130
|
+
* { role: 'user', content: 'I prefer dark mode' },
|
|
131
|
+
* { role: 'assistant', content: 'Noted!' },
|
|
132
|
+
* { role: 'user', content: "I'm building a Next.js app" },
|
|
133
|
+
* ], { scope: { type: 'user', id: userId } });
|
|
134
|
+
*/
|
|
135
|
+
async rememberConversation(userId, conversation, options) {
|
|
136
|
+
const response = await this.client.post('/api/memory/extract', {
|
|
137
|
+
userId,
|
|
138
|
+
conversation,
|
|
139
|
+
scope: options?.scope || { type: 'user', id: userId },
|
|
140
|
+
source: options?.source,
|
|
141
|
+
agentType: options?.agentType,
|
|
142
|
+
agentId: options?.agentId,
|
|
143
|
+
agent: options?.agent,
|
|
144
|
+
metadata: options?.metadata,
|
|
145
|
+
});
|
|
146
|
+
return response.data;
|
|
147
|
+
}
|
|
148
|
+
// =============================================
|
|
149
|
+
// Memory Management
|
|
150
|
+
// =============================================
|
|
100
151
|
async listMemories(userId, options) {
|
|
101
152
|
const params = new URLSearchParams({
|
|
102
153
|
userId,
|
|
@@ -125,6 +176,9 @@ export class MemoryEngineClient {
|
|
|
125
176
|
});
|
|
126
177
|
return response.data;
|
|
127
178
|
}
|
|
179
|
+
// =============================================
|
|
180
|
+
// Knowledge Graph
|
|
181
|
+
// =============================================
|
|
128
182
|
async getGraph(userId, options) {
|
|
129
183
|
const params = new URLSearchParams({
|
|
130
184
|
userId,
|
|
@@ -132,11 +186,16 @@ export class MemoryEngineClient {
|
|
|
132
186
|
...(options?.limit && { limit: options.limit.toString() }),
|
|
133
187
|
...(options?.centerMemoryId && { centerMemoryId: options.centerMemoryId }),
|
|
134
188
|
...(options?.entityTypes && { entityTypes: options.entityTypes.join(',') }),
|
|
135
|
-
...(options?.relationshipTypes && {
|
|
189
|
+
...(options?.relationshipTypes && {
|
|
190
|
+
relationshipTypes: options.relationshipTypes.join(','),
|
|
191
|
+
}),
|
|
136
192
|
});
|
|
137
193
|
const response = await this.client.get(`/api/graph?${params.toString()}`);
|
|
138
194
|
return response.data;
|
|
139
195
|
}
|
|
196
|
+
// =============================================
|
|
197
|
+
// Analytics
|
|
198
|
+
// =============================================
|
|
140
199
|
async getPlatformAnalytics() {
|
|
141
200
|
const response = await this.client.get('/api/analytics/platform');
|
|
142
201
|
return response.data;
|
|
@@ -145,10 +204,16 @@ export class MemoryEngineClient {
|
|
|
145
204
|
const response = await this.client.get(`/api/analytics/user/${userId}`);
|
|
146
205
|
return response.data;
|
|
147
206
|
}
|
|
207
|
+
// =============================================
|
|
208
|
+
// Health
|
|
209
|
+
// =============================================
|
|
148
210
|
async healthCheck() {
|
|
149
211
|
const response = await this.client.get('/health');
|
|
150
212
|
return response.data;
|
|
151
213
|
}
|
|
214
|
+
// =============================================
|
|
215
|
+
// Convenience Methods (backward compatible)
|
|
216
|
+
// =============================================
|
|
152
217
|
async rememberProjectConfig(userId, projectId, config, options) {
|
|
153
218
|
const configText = Object.entries(config)
|
|
154
219
|
.filter(([_, value]) => value)
|
|
@@ -158,9 +223,7 @@ export class MemoryEngineClient {
|
|
|
158
223
|
scope: { type: 'task', id: projectId },
|
|
159
224
|
agentType: options?.agentType || 'coding',
|
|
160
225
|
source: 'user',
|
|
161
|
-
metadata: {
|
|
162
|
-
projectConfig: config,
|
|
163
|
-
},
|
|
226
|
+
metadata: { projectConfig: config },
|
|
164
227
|
});
|
|
165
228
|
}
|
|
166
229
|
async rememberDecision(userId, taskId, decision, options) {
|
|
@@ -206,7 +269,8 @@ export class MemoryEngineClient {
|
|
|
206
269
|
});
|
|
207
270
|
}
|
|
208
271
|
}
|
|
209
|
-
|
|
272
|
+
exports.MemoryEngineClient = MemoryEngineClient;
|
|
273
|
+
function createClient(config) {
|
|
210
274
|
return new MemoryEngineClient(config);
|
|
211
275
|
}
|
|
212
276
|
//# sourceMappingURL=client.js.map
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;;;;AA6bA,oCAEC;AA/bD,kDAA6C;AAkB7C,MAAa,kBAAkB;IAI7B,YAAY,MAA0B;QACpC,IAAI,CAAC,MAAM,GAAG;YACZ,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,EAAE;YAC3B,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,uBAAuB;YAClD,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,KAAK;SACjC,CAAC;QAEF,IAAI,CAAC,MAAM,GAAG,eAAK,CAAC,MAAM,CAAC;YACzB,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO;YAC5B,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO;YAC5B,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI;oBACxB,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM;oBAC/B,aAAa,EAAE,UAAU,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;iBAC9C,CAAC;aACH;SACF,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CACnC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,EACtB,CAAC,KAAK,EAAE,EAAE;YACR,MAAM,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAChC,CAAC,CACF,CAAC;IACJ,CAAC;IAEO,WAAW,CAAC,KAAU;QAC5B,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;Y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MAAc,EACd,UAAkB,EAClB,OAEC;QAED,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,oBAAoB,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;AAzaD,gDAyaC;AAED,SAAgB,YAAY,CAAC,MAA0B;IACrD,OAAO,IAAI,kBAAkB,CAAC,MAAM,CAAC,CAAC;AACxC,CAAC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC5D,cAAc,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.createClient = exports.MemoryEngineClient = void 0;
|
|
18
|
+
var client_1 = require("./client");
|
|
19
|
+
Object.defineProperty(exports, "MemoryEngineClient", { enumerable: true, get: function () { return client_1.MemoryEngineClient; } });
|
|
20
|
+
Object.defineProperty(exports, "createClient", { enumerable: true, get: function () { return client_1.createClient; } });
|
|
21
|
+
__exportStar(require("./types"), exports);
|
|
5
22
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,mCAA4D;AAAnD,4GAAA,kBAAkB,OAAA;AAAE,sGAAA,YAAY,OAAA;AACzC,0CAAwB"}
|
package/dist/types.d.ts
CHANGED
|
@@ -54,6 +54,10 @@ export interface ContextBlock {
|
|
|
54
54
|
tokenCount: number;
|
|
55
55
|
timestamp: string;
|
|
56
56
|
}
|
|
57
|
+
export interface MemoryScope {
|
|
58
|
+
type: 'user' | 'task' | 'session' | 'agent';
|
|
59
|
+
id: string;
|
|
60
|
+
}
|
|
57
61
|
export interface RememberRequest {
|
|
58
62
|
userId: string;
|
|
59
63
|
text: string;
|
|
@@ -70,14 +74,16 @@ export interface RecallRequest {
|
|
|
70
74
|
query: string;
|
|
71
75
|
k?: number;
|
|
72
76
|
tokenBudget?: number;
|
|
73
|
-
filters?:
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
filters?: RecallFilters;
|
|
78
|
+
}
|
|
79
|
+
export interface RecallFilters {
|
|
80
|
+
types?: string[];
|
|
81
|
+
sources?: ('user' | 'system' | 'environment' | 'ai')[];
|
|
82
|
+
dateRange?: {
|
|
83
|
+
start: string;
|
|
84
|
+
end: string;
|
|
80
85
|
};
|
|
86
|
+
tags?: string[];
|
|
81
87
|
}
|
|
82
88
|
export interface RecallResponse {
|
|
83
89
|
success: boolean;
|
|
@@ -191,4 +197,57 @@ export interface UserStats {
|
|
|
191
197
|
count: number;
|
|
192
198
|
}>;
|
|
193
199
|
}
|
|
200
|
+
export interface ContextRequest {
|
|
201
|
+
query: string;
|
|
202
|
+
tokenBudget?: number;
|
|
203
|
+
scope?: MemoryScope;
|
|
204
|
+
scopes?: MemoryScope[];
|
|
205
|
+
includeEntities?: boolean;
|
|
206
|
+
includePreferences?: boolean;
|
|
207
|
+
k?: number;
|
|
208
|
+
agent?: string;
|
|
209
|
+
}
|
|
210
|
+
export interface ContextResponse {
|
|
211
|
+
success: boolean;
|
|
212
|
+
memories: RetrievalResult[];
|
|
213
|
+
entities: any[];
|
|
214
|
+
preferences: Memory[];
|
|
215
|
+
context: {
|
|
216
|
+
assembledContext: string;
|
|
217
|
+
tokenCount: number;
|
|
218
|
+
memoryIds: string[];
|
|
219
|
+
};
|
|
220
|
+
meta: {
|
|
221
|
+
totalMemories: number;
|
|
222
|
+
totalEntities: number;
|
|
223
|
+
totalPreferences: number;
|
|
224
|
+
processingTimeMs: number;
|
|
225
|
+
agent: string | null;
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
export interface ConversationMessage {
|
|
229
|
+
role: 'user' | 'assistant' | 'system';
|
|
230
|
+
content: string;
|
|
231
|
+
timestamp?: string;
|
|
232
|
+
}
|
|
233
|
+
export interface MemoryExtractRequest {
|
|
234
|
+
conversation: ConversationMessage[];
|
|
235
|
+
scope?: MemoryScope;
|
|
236
|
+
source?: 'user' | 'system' | 'environment' | 'ai';
|
|
237
|
+
agentType?: 'coding' | 'healthcare' | 'support' | 'research' | 'general';
|
|
238
|
+
agentId?: string;
|
|
239
|
+
agent?: string;
|
|
240
|
+
metadata?: Record<string, any>;
|
|
241
|
+
}
|
|
242
|
+
export interface MemoryExtractResponse {
|
|
243
|
+
success: boolean;
|
|
244
|
+
count: number;
|
|
245
|
+
memories: Memory[];
|
|
246
|
+
stats: {
|
|
247
|
+
messagesProcessed: number;
|
|
248
|
+
candidatesExtracted: number;
|
|
249
|
+
memoriesStored: number;
|
|
250
|
+
duplicatesSkipped: number;
|
|
251
|
+
};
|
|
252
|
+
}
|
|
194
253
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAID,MAAM,WAAW,MAAM;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;QAC5C,EAAE,EAAE,MAAM,CAAC;KACZ,CAAC;IACF,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,E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AW,mBAAmB;IAClC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,oBAAoB;IACnC,YAAY,EAAE,mBAAmB,EAAE,CAAC;IACpC,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,aAAa,GAAG,IAAI,CAAC;IAClD,SAAS,CAAC,EAAE,QAAQ,GAAG,YAAY,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,CAAC;IACzE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAChC;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,KAAK,EAAE;QACL,iBAAiB,EAAE,MAAM,CAAC;QAC1B,mBAAmB,EAAE,MAAM,CAAC;QAC5B,cAAc,EAAE,MAAM,CAAC;QACvB,iBAAiB,EAAE,MAAM,CAAC;KAC3B,CAAC;CACH"}
|
package/dist/types.js
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
// ============================================================
|
|
3
|
+
// Engrama SDK Types
|
|
4
|
+
// All types for the Engrama AI Memory SDK
|
|
5
|
+
// ============================================================
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
7
|
//# sourceMappingURL=types.js.map
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA,+DAA+D;AAC/D,oBAAoB;AACpB,0CAA0C;AAC1C,+DAA+D"}
|
package/package.json
CHANGED
|
@@ -1,58 +1,20 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@engrama-ai/sdk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
},
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@engrama-ai/sdk",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Engrama AI Memory SDK - Universal memory layer for AI agents",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": ["dist"],
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "tsc",
|
|
10
|
+
"prepublishOnly": "npm run build"
|
|
11
|
+
},
|
|
12
|
+
"keywords": ["engrama", "ai", "memory", "llm", "agent", "context"],
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"axios": "^1.6.2"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"typescript": "^5.3.3"
|
|
19
|
+
}
|
|
20
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,353 +0,0 @@
|
|
|
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
|