mengram-ai 2.6.1 → 2.7.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/README.md CHANGED
@@ -38,6 +38,15 @@ const all = await m.searchAll('deployment issues');
38
38
  // Procedure feedback — AI learns what works
39
39
  await m.procedureFeedback(procId, { success: true });
40
40
 
41
+ // Experience-driven evolution — procedure improves on failure
42
+ await m.procedureFeedback(procId, {
43
+ success: false, context: 'OOM on step 3', failedAtStep: 3
44
+ });
45
+
46
+ // View procedure version history
47
+ const history = await m.procedureHistory(procId);
48
+ // → { versions: [v1, v2, v3], evolution_log: [...] }
49
+
41
50
  // Cognitive Profile — instant personalization
42
51
  const profile = await m.getProfile('ali');
43
52
  // → { system_prompt: "You are talking to Ali, a developer..." }
@@ -46,7 +55,7 @@ const profile = await m.getProfile('ali');
46
55
  ## TypeScript
47
56
 
48
57
  ```typescript
49
- import { MengramClient, SearchResult, Episode, Procedure, UnifiedSearchResult } from 'mengram-ai';
58
+ import { MengramClient, SearchResult, Episode, Procedure, UnifiedSearchResult, ProcedureHistoryResult } from 'mengram-ai';
50
59
 
51
60
  const m = new MengramClient('om-...');
52
61
 
@@ -66,7 +75,9 @@ const all: UnifiedSearchResult = await m.searchAll('issues');
66
75
  | `searchAll(query, options?)` | **Unified search (all 3 types)** |
67
76
  | `episodes(options?)` | **Search/list episodic memories** |
68
77
  | `procedures(options?)` | **Search/list procedural memories** |
69
- | `procedureFeedback(id, options?)` | **Record success/failure** |
78
+ | `procedureFeedback(id, options?)` | **Record success/failure (triggers evolution on failure)** |
79
+ | `procedureHistory(id)` | **Version history + evolution log** |
80
+ | `procedureEvolution(id)` | **Evolution log (what changed and why)** |
70
81
  | `getProfile(userId?, options?)` | **Cognitive Profile** |
71
82
  | `getAll(options?)` | List all memories |
72
83
  | `get(name)` | Get specific entity |
package/index.d.ts CHANGED
@@ -86,6 +86,8 @@ export interface Episode {
86
86
  participants: string[];
87
87
  emotional_valence: 'positive' | 'negative' | 'neutral' | 'mixed';
88
88
  importance: number;
89
+ linked_procedure_id: string | null;
90
+ failed_at_step: number | null;
89
91
  score?: number;
90
92
  created_at: string | null;
91
93
  memory_type?: 'episodic';
@@ -99,6 +101,10 @@ export interface Procedure {
99
101
  entity_names: string[];
100
102
  success_count: number;
101
103
  fail_count: number;
104
+ version: number;
105
+ parent_version_id?: string | null;
106
+ evolved_from_episode?: string | null;
107
+ is_current?: boolean;
102
108
  score?: number;
103
109
  last_used: string | null;
104
110
  created_at?: string | null;
@@ -106,6 +112,31 @@ export interface Procedure {
106
112
  memory_type?: 'procedural';
107
113
  }
108
114
 
115
+ export interface ProcedureEvolutionEntry {
116
+ id: string;
117
+ procedure_id: string;
118
+ episode_id: string | null;
119
+ change_type: 'step_added' | 'step_removed' | 'step_modified' | 'step_reordered' | 'auto_created';
120
+ diff: Record<string, any>;
121
+ version_before: number;
122
+ version_after: number;
123
+ created_at: string | null;
124
+ }
125
+
126
+ export interface ProcedureHistoryResult {
127
+ versions: Procedure[];
128
+ evolution_log: ProcedureEvolutionEntry[];
129
+ }
130
+
131
+ export interface FeedbackResult {
132
+ id: string;
133
+ name: string;
134
+ success_count: number;
135
+ fail_count: number;
136
+ feedback: 'success' | 'failure';
137
+ evolution_triggered: boolean;
138
+ }
139
+
109
140
  export interface UnifiedSearchResult {
110
141
  semantic: SearchResult[];
111
142
  episodic: Episode[];
@@ -149,7 +180,9 @@ export declare class MengramClient {
149
180
 
150
181
  // Procedural Memory
151
182
  procedures(options?: { query?: string; limit?: number }): Promise<Procedure[]>;
152
- procedureFeedback(procedureId: string, options?: { success?: boolean }): Promise<any>;
183
+ procedureFeedback(procedureId: string, options?: { success?: boolean; context?: string; failedAtStep?: number }): Promise<FeedbackResult>;
184
+ procedureHistory(procedureId: string): Promise<ProcedureHistoryResult>;
185
+ procedureEvolution(procedureId: string): Promise<{ evolution: ProcedureEvolutionEntry[] }>;
153
186
 
154
187
  // Unified Search
155
188
  searchAll(query: string, options?: { limit?: number }): Promise<UnifiedSearchResult>;
package/index.js CHANGED
@@ -273,18 +273,43 @@ class MengramClient {
273
273
 
274
274
  /**
275
275
  * Record success/failure feedback for a procedure.
276
+ * On failure with context, triggers experience-driven evolution.
276
277
  * @param {string} procedureId - UUID of the procedure
277
278
  * @param {object} [options]
278
279
  * @param {boolean} [options.success] - true if worked, false if failed (default true)
280
+ * @param {string} [options.context] - What went wrong (triggers evolution on failure)
281
+ * @param {number} [options.failedAtStep] - Which step number failed
279
282
  * @returns {Promise<object>}
280
283
  */
281
284
  async procedureFeedback(procedureId, options = {}) {
282
285
  const success = options.success !== false;
283
- return this._request('PATCH', `/v1/procedures/${procedureId}/feedback`, null, {
286
+ const body = options.context ? {
287
+ context: options.context,
288
+ ...(options.failedAtStep != null && { failed_at_step: options.failedAtStep }),
289
+ } : null;
290
+ return this._request('PATCH', `/v1/procedures/${procedureId}/feedback`, body, {
284
291
  success: success ? 'true' : 'false',
285
292
  });
286
293
  }
287
294
 
295
+ /**
296
+ * Get version history for a procedure.
297
+ * @param {string} procedureId - UUID of any version of the procedure
298
+ * @returns {Promise<{versions: Array, evolution_log: Array}>}
299
+ */
300
+ async procedureHistory(procedureId) {
301
+ return this._request('GET', `/v1/procedures/${procedureId}/history`);
302
+ }
303
+
304
+ /**
305
+ * Get the evolution log for a procedure.
306
+ * @param {string} procedureId - UUID of any version of the procedure
307
+ * @returns {Promise<{evolution: Array}>}
308
+ */
309
+ async procedureEvolution(procedureId) {
310
+ return this._request('GET', `/v1/procedures/${procedureId}/evolution`);
311
+ }
312
+
288
313
  // ---- Unified Search ----
289
314
 
290
315
  /**
@@ -521,12 +546,13 @@ class MengramClient {
521
546
  * @param {number} [options.limit] - max triggers to return
522
547
  * @returns {Promise<Array>}
523
548
  */
524
- async getTriggers(userId = 'default', options = {}) {
549
+ async getTriggers(userId = null, options = {}) {
525
550
  const params = new URLSearchParams();
526
551
  if (options.includeFired) params.set('include_fired', 'true');
527
552
  if (options.limit) params.set('limit', options.limit);
528
553
  const qs = params.toString() ? `?${params}` : '';
529
- const result = await this._request('GET', `/v1/triggers/${userId}${qs}`);
554
+ const path = userId ? `/v1/triggers/${userId}${qs}` : `/v1/triggers${qs}`;
555
+ const result = await this._request('GET', path);
530
556
  return result.triggers || [];
531
557
  }
532
558
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mengram-ai",
3
- "version": "2.6.1",
4
- "description": "Human-like memory for AI — semantic, episodic & procedural memory. Cognitive Profile, unified search, memory agents. Free Mem0 alternative.",
3
+ "version": "2.7.0",
4
+ "description": "Human-like memory for AI — semantic, episodic & procedural memory. Experience-driven procedures, Cognitive Profile, unified search, memory agents. Free Mem0 alternative.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
7
7
  "license": "Apache-2.0",