mengram-ai 2.3.2 → 2.5.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/index.d.ts +54 -0
- package/index.js +93 -0
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -69,6 +69,49 @@ export interface JobStatus {
|
|
|
69
69
|
error?: string;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
+
export interface CognitiveProfile {
|
|
73
|
+
user_id: string;
|
|
74
|
+
system_prompt: string;
|
|
75
|
+
facts_used: number;
|
|
76
|
+
last_updated: string | null;
|
|
77
|
+
status: 'ok' | 'no_data' | 'no_facts' | 'no_llm_key' | 'error';
|
|
78
|
+
error?: string;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface Episode {
|
|
82
|
+
id: string;
|
|
83
|
+
summary: string;
|
|
84
|
+
context: string | null;
|
|
85
|
+
outcome: string | null;
|
|
86
|
+
participants: string[];
|
|
87
|
+
emotional_valence: 'positive' | 'negative' | 'neutral' | 'mixed';
|
|
88
|
+
importance: number;
|
|
89
|
+
score?: number;
|
|
90
|
+
created_at: string | null;
|
|
91
|
+
memory_type?: 'episodic';
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface Procedure {
|
|
95
|
+
id: string;
|
|
96
|
+
name: string;
|
|
97
|
+
trigger_condition: string | null;
|
|
98
|
+
steps: Array<{ step: number; action: string; detail: string }>;
|
|
99
|
+
entity_names: string[];
|
|
100
|
+
success_count: number;
|
|
101
|
+
fail_count: number;
|
|
102
|
+
score?: number;
|
|
103
|
+
last_used: string | null;
|
|
104
|
+
created_at?: string | null;
|
|
105
|
+
updated_at: string | null;
|
|
106
|
+
memory_type?: 'procedural';
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export interface UnifiedSearchResult {
|
|
110
|
+
semantic: SearchResult[];
|
|
111
|
+
episodic: Episode[];
|
|
112
|
+
procedural: Procedure[];
|
|
113
|
+
}
|
|
114
|
+
|
|
72
115
|
export interface Webhook {
|
|
73
116
|
id: number;
|
|
74
117
|
url: string;
|
|
@@ -98,8 +141,19 @@ export declare class MengramClient {
|
|
|
98
141
|
delete(name: string): Promise<boolean>;
|
|
99
142
|
stats(): Promise<Stats>;
|
|
100
143
|
graph(): Promise<{ nodes: any[]; edges: any[] }>;
|
|
144
|
+
getProfile(userId?: string, options?: { force?: boolean }): Promise<CognitiveProfile>;
|
|
101
145
|
timeline(options?: { after?: string; before?: string; limit?: number }): Promise<any[]>;
|
|
102
146
|
|
|
147
|
+
// Episodic Memory
|
|
148
|
+
episodes(options?: { query?: string; limit?: number; after?: string; before?: string }): Promise<Episode[]>;
|
|
149
|
+
|
|
150
|
+
// Procedural Memory
|
|
151
|
+
procedures(options?: { query?: string; limit?: number }): Promise<Procedure[]>;
|
|
152
|
+
procedureFeedback(procedureId: string, options?: { success?: boolean }): Promise<any>;
|
|
153
|
+
|
|
154
|
+
// Unified Search
|
|
155
|
+
searchAll(query: string, options?: { limit?: number }): Promise<UnifiedSearchResult>;
|
|
156
|
+
|
|
103
157
|
// Agents
|
|
104
158
|
runAgents(options?: { agent?: string; autoFix?: boolean }): Promise<any>;
|
|
105
159
|
agentHistory(options?: { agent?: string; limit?: number }): Promise<any[]>;
|
package/index.js
CHANGED
|
@@ -208,6 +208,99 @@ class MengramClient {
|
|
|
208
208
|
return this._request('GET', '/v1/graph');
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
+
// ---- Cognitive Profile ----
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Generate a Cognitive Profile — a ready-to-use system prompt from user memory.
|
|
215
|
+
* @param {string} userId - User to generate profile for
|
|
216
|
+
* @param {object} [options]
|
|
217
|
+
* @param {boolean} [options.force] - Regenerate even if cached
|
|
218
|
+
* @returns {Promise<{user_id: string, system_prompt: string, facts_used: number, status: string}>}
|
|
219
|
+
*/
|
|
220
|
+
async getProfile(userId = 'default', options = {}) {
|
|
221
|
+
const params = {};
|
|
222
|
+
if (options.force) params.force = 'true';
|
|
223
|
+
return this._request('GET', `/v1/profile/${userId}`, null, params);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// ---- Episodic Memory ----
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Get or search episodic memories (events, interactions, experiences).
|
|
230
|
+
* @param {object} [options]
|
|
231
|
+
* @param {string} [options.query] - Search query (if omitted, returns recent episodes)
|
|
232
|
+
* @param {number} [options.limit] - Max results (default 20)
|
|
233
|
+
* @param {string} [options.after] - ISO datetime filter start
|
|
234
|
+
* @param {string} [options.before] - ISO datetime filter end
|
|
235
|
+
* @returns {Promise<Array>}
|
|
236
|
+
*/
|
|
237
|
+
async episodes(options = {}) {
|
|
238
|
+
if (options.query) {
|
|
239
|
+
const params = { query: options.query, limit: options.limit || 5 };
|
|
240
|
+
if (options.after) params.after = options.after;
|
|
241
|
+
if (options.before) params.before = options.before;
|
|
242
|
+
const data = await this._request('GET', '/v1/episodes/search', null, params);
|
|
243
|
+
return data.results || [];
|
|
244
|
+
} else {
|
|
245
|
+
const params = { limit: options.limit || 20 };
|
|
246
|
+
if (options.after) params.after = options.after;
|
|
247
|
+
if (options.before) params.before = options.before;
|
|
248
|
+
const data = await this._request('GET', '/v1/episodes', null, params);
|
|
249
|
+
return data.episodes || [];
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// ---- Procedural Memory ----
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Get or search procedural memories (learned workflows, skills).
|
|
257
|
+
* @param {object} [options]
|
|
258
|
+
* @param {string} [options.query] - Search query (if omitted, returns all procedures)
|
|
259
|
+
* @param {number} [options.limit] - Max results (default 20)
|
|
260
|
+
* @returns {Promise<Array>}
|
|
261
|
+
*/
|
|
262
|
+
async procedures(options = {}) {
|
|
263
|
+
if (options.query) {
|
|
264
|
+
const params = { query: options.query, limit: options.limit || 5 };
|
|
265
|
+
const data = await this._request('GET', '/v1/procedures/search', null, params);
|
|
266
|
+
return data.results || [];
|
|
267
|
+
} else {
|
|
268
|
+
const params = { limit: options.limit || 20 };
|
|
269
|
+
const data = await this._request('GET', '/v1/procedures', null, params);
|
|
270
|
+
return data.procedures || [];
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Record success/failure feedback for a procedure.
|
|
276
|
+
* @param {string} procedureId - UUID of the procedure
|
|
277
|
+
* @param {object} [options]
|
|
278
|
+
* @param {boolean} [options.success] - true if worked, false if failed (default true)
|
|
279
|
+
* @returns {Promise<object>}
|
|
280
|
+
*/
|
|
281
|
+
async procedureFeedback(procedureId, options = {}) {
|
|
282
|
+
const success = options.success !== false;
|
|
283
|
+
return this._request('PATCH', `/v1/procedures/${procedureId}/feedback`, null, {
|
|
284
|
+
success: success ? 'true' : 'false',
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// ---- Unified Search ----
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Search across all 3 memory types: semantic, episodic, procedural.
|
|
292
|
+
* @param {string} query - Search query
|
|
293
|
+
* @param {object} [options]
|
|
294
|
+
* @param {number} [options.limit] - Max results per type (default 5)
|
|
295
|
+
* @returns {Promise<{semantic: Array, episodic: Array, procedural: Array}>}
|
|
296
|
+
*/
|
|
297
|
+
async searchAll(query, options = {}) {
|
|
298
|
+
return this._request('POST', '/v1/search/all', {
|
|
299
|
+
query,
|
|
300
|
+
limit: options.limit || 5,
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
|
|
211
304
|
/**
|
|
212
305
|
* Timeline search.
|
|
213
306
|
* @param {object} [options]
|