@lanonasis/mem-intel-sdk 2.0.1 → 2.0.3

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.
Files changed (68) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +81 -10
  3. package/dist/core/behavior-types.d.ts +336 -0
  4. package/dist/core/client.d.ts +97 -1
  5. package/dist/core/errors.d.ts +0 -1
  6. package/dist/core/index.cjs +205 -0
  7. package/dist/core/index.cjs.map +1 -1
  8. package/dist/core/index.d.ts +1 -1
  9. package/dist/core/index.js +203 -1
  10. package/dist/core/index.js.map +1 -1
  11. package/dist/core/prediction-types.d.ts +0 -1
  12. package/dist/core/types.d.ts +0 -1
  13. package/dist/index-sdk.d.ts +2 -1
  14. package/dist/index.cjs +245 -0
  15. package/dist/index.cjs.map +1 -1
  16. package/dist/index.js +241 -1
  17. package/dist/index.js.map +1 -1
  18. package/dist/node/client.d.ts +0 -1
  19. package/dist/node/index.cjs +170 -0
  20. package/dist/node/index.cjs.map +1 -1
  21. package/dist/node/index.d.ts +0 -1
  22. package/dist/node/index.js +170 -0
  23. package/dist/node/index.js.map +1 -1
  24. package/dist/react/context/MemoryIntelligenceProvider.d.ts +0 -1
  25. package/dist/react/hooks/useMemoryIntelligence.d.ts +0 -1
  26. package/dist/react/index.cjs +170 -0
  27. package/dist/react/index.cjs.map +1 -1
  28. package/dist/react/index.d.ts +0 -1
  29. package/dist/react/index.js +170 -0
  30. package/dist/react/index.js.map +1 -1
  31. package/dist/server/index.cjs +170 -0
  32. package/dist/server/index.cjs.map +1 -1
  33. package/dist/server/index.d.ts +0 -1
  34. package/dist/server/index.js +170 -0
  35. package/dist/server/index.js.map +1 -1
  36. package/dist/server/mcp-server.d.ts +0 -1
  37. package/dist/utils/embeddings.d.ts +0 -1
  38. package/dist/utils/formatting.d.ts +0 -1
  39. package/dist/utils/http-client.d.ts +0 -1
  40. package/dist/utils/index.d.ts +0 -1
  41. package/dist/utils/prediction-engine.d.ts +0 -1
  42. package/dist/utils/response-adapter.d.ts +0 -1
  43. package/dist/utils/similarity.d.ts +0 -1
  44. package/dist/vue/composables/useMemoryIntelligence.d.ts +0 -1
  45. package/dist/vue/index.d.ts +0 -1
  46. package/package.json +2 -2
  47. package/dist/core/client.d.ts.map +0 -1
  48. package/dist/core/errors.d.ts.map +0 -1
  49. package/dist/core/index.d.ts.map +0 -1
  50. package/dist/core/prediction-types.d.ts.map +0 -1
  51. package/dist/core/types.d.ts.map +0 -1
  52. package/dist/index-sdk.d.ts.map +0 -1
  53. package/dist/node/client.d.ts.map +0 -1
  54. package/dist/node/index.d.ts.map +0 -1
  55. package/dist/react/context/MemoryIntelligenceProvider.d.ts.map +0 -1
  56. package/dist/react/hooks/useMemoryIntelligence.d.ts.map +0 -1
  57. package/dist/react/index.d.ts.map +0 -1
  58. package/dist/server/index.d.ts.map +0 -1
  59. package/dist/server/mcp-server.d.ts.map +0 -1
  60. package/dist/utils/embeddings.d.ts.map +0 -1
  61. package/dist/utils/formatting.d.ts.map +0 -1
  62. package/dist/utils/http-client.d.ts.map +0 -1
  63. package/dist/utils/index.d.ts.map +0 -1
  64. package/dist/utils/prediction-engine.d.ts.map +0 -1
  65. package/dist/utils/response-adapter.d.ts.map +0 -1
  66. package/dist/utils/similarity.d.ts.map +0 -1
  67. package/dist/vue/composables/useMemoryIntelligence.d.ts.map +0 -1
  68. package/dist/vue/index.d.ts.map +0 -1
package/CHANGELOG.md CHANGED
@@ -7,6 +7,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ---
9
9
 
10
+ ## [2.0.3] - 2026-02-25
11
+
12
+ ### Added
13
+
14
+ - **Behavior methods changelog/documentation parity**:
15
+ - `recordBehavior()` - persist successful workflow patterns
16
+ - `recallBehavior()` - retrieve similar patterns by contextual similarity
17
+ - `suggestAction()` - generate next-step suggestions from learned workflows
18
+ - `listBehaviorPatterns()` - enumerate saved behavior patterns for a user
19
+ - Added concrete SDK README usage examples for the behavior method surface above (request shape + expected usage flow).
20
+
21
+ ### Fixed
22
+
23
+ - **Declaration build completeness**: fixed SDK declaration generation so publish artifacts include all expected `.d.ts` entrypoints for `.` / `core` / `node` / `react` / `vue` / `server`.
24
+ - Reduced declaration build pressure by preventing oversized MCP server type inference during declaration emit and disabling declaration/source maps for the declaration-only build step.
25
+
10
26
  ## [2.0.0] - 2026-01-13
11
27
 
12
28
  ### The AI That Anticipates What You Need
package/README.md CHANGED
@@ -39,6 +39,7 @@ const predictions = await client.predictiveRecall({
39
39
  - **Pattern Recognition** - Understand usage trends and productivity patterns
40
40
  - **Smart Organization** - AI-powered tag suggestions and duplicate detection
41
41
  - **Semantic Intelligence** - Find related memories using vector similarity
42
+ - **Behavioral Learning** - Record, recall, and suggest next actions from successful workflows
42
43
  - **Actionable Insights** - Extract key learnings and opportunities from your knowledge base
43
44
  - **Health Monitoring** - Ensure your memory database stays organized and healthy
44
45
 
@@ -155,6 +156,76 @@ onMounted(() => {
155
156
  </script>
156
157
  ```
157
158
 
159
+ ## Behavior Learning APIs
160
+
161
+ Use behavior methods when you want the SDK to learn from successful execution patterns and suggest next actions on future tasks.
162
+
163
+ ### 1) Record a successful workflow
164
+
165
+ ```typescript
166
+ const record = await client.recordBehavior({
167
+ user_id: "user-123",
168
+ trigger: "Need to migrate endpoint auth middleware to bearer-first flow",
169
+ context: {
170
+ project: "lanonasis-cli",
171
+ current_task: "auth transport migration",
172
+ },
173
+ actions: [
174
+ { tool: "read_file", params: { path: "src/utils/api.ts" } },
175
+ { tool: "edit_file", params: { path: "src/utils/api.ts" } },
176
+ { tool: "run_tests", params: { target: "api-client-auth-header.test.ts" } },
177
+ ],
178
+ final_outcome: "Bearer flow migration completed and tests passed",
179
+ confidence: 0.82,
180
+ });
181
+
182
+ console.log(record.data.was_duplicate, record.data.pattern.id);
183
+ ```
184
+
185
+ ### 2) Recall similar behavior for a new task
186
+
187
+ ```typescript
188
+ const recall = await client.recallBehavior({
189
+ user_id: "user-123",
190
+ context: {
191
+ current_task: "Add token refresh to memory command execution path",
192
+ },
193
+ limit: 5,
194
+ similarity_threshold: 0.7,
195
+ });
196
+
197
+ for (const match of recall.data.patterns) {
198
+ console.log(match.similarity_score, match.pattern.trigger);
199
+ }
200
+ ```
201
+
202
+ ### 3) Suggest next actions from learned patterns
203
+
204
+ ```typescript
205
+ const suggestion = await client.suggestAction({
206
+ user_id: "user-123",
207
+ current_state: {
208
+ task_description: "Finalize CLI release notes and dry-run publish",
209
+ completed_steps: [
210
+ { tool: "update_changelog" },
211
+ { tool: "bump_version" },
212
+ ],
213
+ },
214
+ max_suggestions: 3,
215
+ });
216
+
217
+ console.log(suggestion.data.suggestions);
218
+ ```
219
+
220
+ ### 4) List existing behavior patterns
221
+
222
+ ```typescript
223
+ const patterns = await client.listBehaviorPatterns("user-123", {
224
+ limit: 20,
225
+ offset: 0,
226
+ });
227
+ ```
228
+
158
229
  ## Predictive Memory System (v2.0.0)
159
230
 
160
231
  The flagship feature that makes your memory system feel magical.
@@ -336,9 +407,9 @@ Create a `.env` file with your existing LanOnasis credentials:
336
407
 
337
408
  ```env
338
409
  # Required - Same as your @lanonasis/mcp-core
339
- ONASIS_SUPABASE_URL=your_supabase_url
340
- ONASIS_SUPABASE_SERVICE_KEY=your_service_key
341
- OPENAI_API_KEY=your_openai_key
410
+ ONASIS_SUPABASE_URL=https://<project-ref>.supabase.co
411
+ REDACTED_SUPABASE_SERVICE_ROLE_KEY=REDACTED_SUPABASE_SERVICE_ROLE_KEY
412
+ OPENAI_API_KEY=REDACTED_OPENAI_API_KEY
342
413
 
343
414
  # Optional
344
415
  TRANSPORT=stdio # or 'http' for HTTP mode
@@ -585,18 +656,18 @@ Add to your `claude_desktop_config.json`:
585
656
  "command": "node",
586
657
  "args": ["/path/to/mcp-core/dist/index.js"],
587
658
  "env": {
588
- "ONASIS_SUPABASE_URL": "...",
589
- "ONASIS_SUPABASE_SERVICE_KEY": "...",
590
- "OPENAI_API_KEY": "..."
659
+ "ONASIS_SUPABASE_URL=https://<project-ref>.supabase.co
660
+ "ONASIS_SUPABASE_SERVICE_KEY=REDACTED_SUPABASE_SERVICE_ROLE_KEY
661
+ "OPENAI_API_KEY=REDACTED_OPENAI_API_KEY
591
662
  }
592
663
  },
593
664
  "memory-intelligence": {
594
665
  "command": "node",
595
666
  "args": ["/path/to/memory-intelligence-mcp-server/dist/index.js"],
596
667
  "env": {
597
- "ONASIS_SUPABASE_URL": "...",
598
- "ONASIS_SUPABASE_SERVICE_KEY": "...",
599
- "OPENAI_API_KEY": "..."
668
+ "ONASIS_SUPABASE_URL=https://<project-ref>.supabase.co
669
+ "ONASIS_SUPABASE_SERVICE_KEY=REDACTED_SUPABASE_SERVICE_ROLE_KEY
670
+ "OPENAI_API_KEY=REDACTED_OPENAI_API_KEY
600
671
  }
601
672
  }
602
673
  }
@@ -637,7 +708,7 @@ Tools return actionable error messages:
637
708
  "content": [
638
709
  {
639
710
  "type": "text",
640
- "text": "Error analyzing patterns: Database connection failed. Try checking your ONASIS_SUPABASE_URL environment variable."
711
+ "text": "Error analyzing patterns: Database connection failed. Try checking your ONASIS_SUPABASE_URL=https://<project-ref>.supabase.co
641
712
  }
642
713
  ]
643
714
  }
@@ -0,0 +1,336 @@
1
+ /**
2
+ * Behavioral Pattern Learning Types
3
+ *
4
+ * These types support the AI-powered behavioral learning system that:
5
+ * - Records successful workflows and action patterns
6
+ * - Recalls similar patterns based on current context
7
+ * - Suggests next actions based on learned behaviors
8
+ *
9
+ * The system stores trigger embeddings for semantic similarity search,
10
+ * enabling the SDK to anticipate what actions users might want to take.
11
+ */
12
+ import { z } from "zod";
13
+ /**
14
+ * A single action within a behavior pattern
15
+ */
16
+ export interface BehaviorAction {
17
+ /** Tool or action identifier */
18
+ tool: string;
19
+ /** Parameters used with this action */
20
+ params?: Record<string, unknown>;
21
+ /** Timestamp when action occurred */
22
+ timestamp?: string;
23
+ /** Duration in milliseconds (if applicable) */
24
+ duration_ms?: number;
25
+ }
26
+ /**
27
+ * Context that was active when a behavior pattern was recorded
28
+ */
29
+ export interface BehaviorContext {
30
+ /** Current project or workspace */
31
+ project?: string;
32
+ /** Files that were open/active */
33
+ active_files?: string[];
34
+ /** Current task or goal description */
35
+ current_task?: string;
36
+ /** Environment metadata (IDE, terminal, etc.) */
37
+ environment?: string;
38
+ /** Additional custom context */
39
+ [key: string]: unknown;
40
+ }
41
+ /**
42
+ * A recorded behavior pattern with embeddings for similarity search
43
+ */
44
+ export interface BehaviorPattern {
45
+ /** Unique identifier */
46
+ id: string;
47
+ /** User who created this pattern */
48
+ user_id: string;
49
+ /** Natural language description of what triggered this pattern */
50
+ trigger: string;
51
+ /** Vector embedding of the trigger for semantic search (1536 dimensions for text-embedding-3-small) */
52
+ trigger_embedding?: number[];
53
+ /** Context when pattern was recorded */
54
+ context: BehaviorContext;
55
+ /** Ordered list of actions taken */
56
+ actions: BehaviorAction[];
57
+ /** Description of the final outcome/result */
58
+ final_outcome: string;
59
+ /** Confidence score (0-1) indicating pattern reliability */
60
+ confidence: number;
61
+ /** Number of times this pattern has been recalled/used */
62
+ use_count: number;
63
+ /** Similarity score (only present in search results) */
64
+ similarity?: number;
65
+ /** When the pattern was created */
66
+ created_at: string;
67
+ /** When the pattern was last updated/used */
68
+ updated_at: string;
69
+ }
70
+ /**
71
+ * Parameters for recording a new behavior pattern
72
+ */
73
+ export interface RecordBehaviorParams {
74
+ /** User ID (UUID) */
75
+ user_id: string;
76
+ /** Natural language description of what triggered this workflow */
77
+ trigger: string;
78
+ /** Context when the pattern occurred */
79
+ context?: BehaviorContext;
80
+ /** Ordered list of actions taken */
81
+ actions: BehaviorAction[];
82
+ /** Description of the final outcome */
83
+ final_outcome: string;
84
+ /** Confidence in this pattern (0-1, default: 0.7) */
85
+ confidence?: number;
86
+ }
87
+ /** Zod schema for API validation */
88
+ export declare const RecordBehaviorParamsSchema: z.ZodObject<{
89
+ user_id: z.ZodString;
90
+ trigger: z.ZodString;
91
+ context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
92
+ actions: z.ZodArray<z.ZodObject<{
93
+ tool: z.ZodString;
94
+ params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
95
+ timestamp: z.ZodOptional<z.ZodString>;
96
+ duration_ms: z.ZodOptional<z.ZodNumber>;
97
+ }, "strip", z.ZodTypeAny, {
98
+ tool: string;
99
+ params?: Record<string, unknown> | undefined;
100
+ timestamp?: string | undefined;
101
+ duration_ms?: number | undefined;
102
+ }, {
103
+ tool: string;
104
+ params?: Record<string, unknown> | undefined;
105
+ timestamp?: string | undefined;
106
+ duration_ms?: number | undefined;
107
+ }>, "many">;
108
+ final_outcome: z.ZodString;
109
+ confidence: z.ZodDefault<z.ZodNumber>;
110
+ }, "strip", z.ZodTypeAny, {
111
+ actions: {
112
+ tool: string;
113
+ params?: Record<string, unknown> | undefined;
114
+ timestamp?: string | undefined;
115
+ duration_ms?: number | undefined;
116
+ }[];
117
+ user_id: string;
118
+ trigger: string;
119
+ final_outcome: string;
120
+ confidence: number;
121
+ context?: Record<string, unknown> | undefined;
122
+ }, {
123
+ actions: {
124
+ tool: string;
125
+ params?: Record<string, unknown> | undefined;
126
+ timestamp?: string | undefined;
127
+ duration_ms?: number | undefined;
128
+ }[];
129
+ user_id: string;
130
+ trigger: string;
131
+ final_outcome: string;
132
+ context?: Record<string, unknown> | undefined;
133
+ confidence?: number | undefined;
134
+ }>;
135
+ /**
136
+ * Response from recording a behavior pattern
137
+ */
138
+ export interface RecordBehaviorResult {
139
+ /** The created or updated pattern */
140
+ pattern: BehaviorPattern;
141
+ /** Whether a duplicate was updated instead of creating new */
142
+ was_duplicate: boolean;
143
+ /** Message describing what happened */
144
+ message: string;
145
+ }
146
+ /**
147
+ * Parameters for recalling similar behavior patterns
148
+ */
149
+ export interface RecallBehaviorParams {
150
+ /** User ID (UUID) */
151
+ user_id: string;
152
+ /** Current context for similarity matching */
153
+ context: {
154
+ /** Current task description (required for embedding generation) */
155
+ current_task: string;
156
+ /** Optional additional context fields */
157
+ [key: string]: unknown;
158
+ };
159
+ /** Maximum patterns to return (default: 5) */
160
+ limit?: number;
161
+ /** Minimum similarity threshold (0-1, default: 0.7) */
162
+ similarity_threshold?: number;
163
+ }
164
+ /** Zod schema for API validation */
165
+ export declare const RecallBehaviorParamsSchema: z.ZodObject<{
166
+ user_id: z.ZodString;
167
+ context: z.ZodObject<{
168
+ current_task: z.ZodString;
169
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
170
+ current_task: z.ZodString;
171
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
172
+ current_task: z.ZodString;
173
+ }, z.ZodTypeAny, "passthrough">>;
174
+ limit: z.ZodDefault<z.ZodNumber>;
175
+ similarity_threshold: z.ZodDefault<z.ZodNumber>;
176
+ }, "strip", z.ZodTypeAny, {
177
+ context: {
178
+ current_task: string;
179
+ } & {
180
+ [k: string]: unknown;
181
+ };
182
+ limit: number;
183
+ user_id: string;
184
+ similarity_threshold: number;
185
+ }, {
186
+ context: {
187
+ current_task: string;
188
+ } & {
189
+ [k: string]: unknown;
190
+ };
191
+ user_id: string;
192
+ limit?: number | undefined;
193
+ similarity_threshold?: number | undefined;
194
+ }>;
195
+ /**
196
+ * A recalled pattern with similarity information
197
+ */
198
+ export interface RecalledPattern {
199
+ /** The matched pattern */
200
+ pattern: BehaviorPattern;
201
+ /** Similarity score (0-1) */
202
+ similarity_score: number;
203
+ /** Human-readable explanation of why this matched */
204
+ relevance_reason: string;
205
+ }
206
+ /**
207
+ * Response from recalling behavior patterns
208
+ */
209
+ export interface RecallBehaviorResult {
210
+ /** Matched patterns sorted by similarity */
211
+ patterns: RecalledPattern[];
212
+ /** Total patterns found */
213
+ total_found: number;
214
+ }
215
+ /**
216
+ * Parameters for getting action suggestions
217
+ */
218
+ export interface SuggestActionParams {
219
+ /** User ID (UUID) */
220
+ user_id: string;
221
+ /** Current state for action prediction */
222
+ current_state: {
223
+ /** Description of current task */
224
+ task_description: string;
225
+ /** Steps already completed (for predicting next step) */
226
+ completed_steps?: BehaviorAction[];
227
+ /** Optional additional state */
228
+ [key: string]: unknown;
229
+ };
230
+ /** Maximum suggestions to return (default: 3) */
231
+ max_suggestions?: number;
232
+ }
233
+ /** Zod schema for API validation */
234
+ export declare const SuggestActionParamsSchema: z.ZodObject<{
235
+ user_id: z.ZodString;
236
+ current_state: z.ZodObject<{
237
+ task_description: z.ZodString;
238
+ completed_steps: z.ZodOptional<z.ZodArray<z.ZodObject<{
239
+ tool: z.ZodString;
240
+ params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
241
+ }, "strip", z.ZodTypeAny, {
242
+ tool: string;
243
+ params?: Record<string, unknown> | undefined;
244
+ }, {
245
+ tool: string;
246
+ params?: Record<string, unknown> | undefined;
247
+ }>, "many">>;
248
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
249
+ task_description: z.ZodString;
250
+ completed_steps: z.ZodOptional<z.ZodArray<z.ZodObject<{
251
+ tool: z.ZodString;
252
+ params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
253
+ }, "strip", z.ZodTypeAny, {
254
+ tool: string;
255
+ params?: Record<string, unknown> | undefined;
256
+ }, {
257
+ tool: string;
258
+ params?: Record<string, unknown> | undefined;
259
+ }>, "many">>;
260
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
261
+ task_description: z.ZodString;
262
+ completed_steps: z.ZodOptional<z.ZodArray<z.ZodObject<{
263
+ tool: z.ZodString;
264
+ params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
265
+ }, "strip", z.ZodTypeAny, {
266
+ tool: string;
267
+ params?: Record<string, unknown> | undefined;
268
+ }, {
269
+ tool: string;
270
+ params?: Record<string, unknown> | undefined;
271
+ }>, "many">>;
272
+ }, z.ZodTypeAny, "passthrough">>;
273
+ max_suggestions: z.ZodDefault<z.ZodNumber>;
274
+ }, "strip", z.ZodTypeAny, {
275
+ user_id: string;
276
+ current_state: {
277
+ task_description: string;
278
+ completed_steps?: {
279
+ tool: string;
280
+ params?: Record<string, unknown> | undefined;
281
+ }[] | undefined;
282
+ } & {
283
+ [k: string]: unknown;
284
+ };
285
+ max_suggestions: number;
286
+ }, {
287
+ user_id: string;
288
+ current_state: {
289
+ task_description: string;
290
+ completed_steps?: {
291
+ tool: string;
292
+ params?: Record<string, unknown> | undefined;
293
+ }[] | undefined;
294
+ } & {
295
+ [k: string]: unknown;
296
+ };
297
+ max_suggestions?: number | undefined;
298
+ }>;
299
+ /**
300
+ * A suggested next action based on learned patterns
301
+ */
302
+ export interface ActionSuggestion {
303
+ /** Suggested action description */
304
+ action: string;
305
+ /** Tool to use for this action */
306
+ tool: string;
307
+ /** Confidence score (0-1) */
308
+ confidence: number;
309
+ /** Pattern IDs that informed this suggestion */
310
+ based_on_patterns: string[];
311
+ /** Human-readable explanation */
312
+ reasoning: string;
313
+ }
314
+ /**
315
+ * Response from action suggestion endpoint
316
+ */
317
+ export interface SuggestActionResult {
318
+ /** Suggested actions sorted by confidence */
319
+ suggestions: ActionSuggestion[];
320
+ }
321
+ /**
322
+ * Standard response format from behavior edge functions
323
+ */
324
+ export interface BehaviorEdgeFunctionResponse<T> {
325
+ /** Whether the operation succeeded */
326
+ success: boolean;
327
+ /** Response data (present on success) */
328
+ data?: T;
329
+ /** Error information (present on failure) */
330
+ error?: {
331
+ message: string;
332
+ code: string;
333
+ };
334
+ /** Optional message (for duplicate detection, etc.) */
335
+ message?: string;
336
+ }
@@ -4,6 +4,7 @@
4
4
  */
5
5
  import { MemoryIntelligenceConfig, AnalyzePatternsParams, PatternAnalysis, SuggestTagsParams, TagSuggestionsResult, FindRelatedParams, RelatedMemoriesResult, DetectDuplicatesParams, DuplicatesResult, ExtractInsightsParams, InsightsResult, HealthCheckParams, MemoryHealth, QueryMemoriesOptions, MemoryEntry, ProcessingMode } from "./types.js";
6
6
  import { PredictiveRecallParams, PredictiveRecallResult } from "./prediction-types.js";
7
+ import { RecordBehaviorParams, RecordBehaviorResult, RecallBehaviorParams, RecallBehaviorResult, SuggestActionParams, SuggestActionResult, BehaviorPattern } from "./behavior-types.js";
7
8
  import { HttpClient } from "../utils/http-client.js";
8
9
  import { UsageInfo, TierInfo } from "../utils/response-adapter.js";
9
10
  export interface IntelligenceResponse<T> {
@@ -111,5 +112,100 @@ export declare class MemoryIntelligenceClient {
111
112
  action: "clicked" | "saved" | "dismissed" | "ignored";
112
113
  dismissReason?: "not_relevant" | "already_know" | "not_now" | "other";
113
114
  }): Promise<void>;
115
+ /**
116
+ * Record a successful behavior pattern for future recall
117
+ *
118
+ * The system automatically:
119
+ * - Generates an embedding from the trigger description
120
+ * - Detects and updates duplicates (>95% similarity)
121
+ * - Tracks usage counts for pattern prioritization
122
+ *
123
+ * @example
124
+ * ```typescript
125
+ * const result = await client.recordBehavior({
126
+ * user_id: "user-123",
127
+ * trigger: "User wants to refactor a React component to use hooks",
128
+ * context: {
129
+ * project: "dashboard-app",
130
+ * active_files: ["src/components/DataTable.tsx"]
131
+ * },
132
+ * actions: [
133
+ * { tool: "read_file", params: { path: "src/components/DataTable.tsx" } },
134
+ * { tool: "analyze_code", params: { focus: "class_components" } },
135
+ * { tool: "edit_file", params: { path: "src/components/DataTable.tsx" } }
136
+ * ],
137
+ * final_outcome: "Successfully converted class component to functional with hooks"
138
+ * });
139
+ *
140
+ * if (result.data.was_duplicate) {
141
+ * console.log("Updated existing pattern:", result.data.pattern.id);
142
+ * }
143
+ * ```
144
+ */
145
+ recordBehavior(params: RecordBehaviorParams): Promise<IntelligenceResponse<RecordBehaviorResult>>;
146
+ /**
147
+ * Recall similar behavior patterns based on current context
148
+ *
149
+ * Use this to find workflows that match the user's current task,
150
+ * enabling AI assistants to suggest proven approaches.
151
+ *
152
+ * @example
153
+ * ```typescript
154
+ * const result = await client.recallBehavior({
155
+ * user_id: "user-123",
156
+ * context: {
157
+ * current_task: "Need to optimize database queries for user dashboard"
158
+ * },
159
+ * limit: 5,
160
+ * similarity_threshold: 0.7
161
+ * });
162
+ *
163
+ * for (const match of result.data.patterns) {
164
+ * console.log(`[${Math.round(match.similarity_score * 100)}%] ${match.pattern.trigger}`);
165
+ * console.log(` Actions: ${match.pattern.actions.map(a => a.tool).join(" → ")}`);
166
+ * }
167
+ * ```
168
+ */
169
+ recallBehavior(params: RecallBehaviorParams): Promise<IntelligenceResponse<RecallBehaviorResult>>;
170
+ /**
171
+ * Get AI-powered action suggestions based on learned patterns
172
+ *
173
+ * Analyzes the current state and completed steps to predict
174
+ * what action the user should take next based on similar workflows.
175
+ *
176
+ * @example
177
+ * ```typescript
178
+ * const result = await client.suggestAction({
179
+ * user_id: "user-123",
180
+ * current_state: {
181
+ * task_description: "Implementing user authentication with OAuth",
182
+ * completed_steps: [
183
+ * { tool: "create_file", params: { path: "src/auth/oauth.ts" } },
184
+ * { tool: "read_file", params: { path: "package.json" } }
185
+ * ]
186
+ * },
187
+ * max_suggestions: 3
188
+ * });
189
+ *
190
+ * for (const suggestion of result.data.suggestions) {
191
+ * console.log(`[${Math.round(suggestion.confidence * 100)}%] ${suggestion.action}`);
192
+ * console.log(` Tool: ${suggestion.tool}`);
193
+ * console.log(` Why: ${suggestion.reasoning}`);
194
+ * }
195
+ * ```
196
+ */
197
+ suggestAction(params: SuggestActionParams): Promise<IntelligenceResponse<SuggestActionResult>>;
198
+ /**
199
+ * List all behavior patterns for a user
200
+ *
201
+ * @example
202
+ * ```typescript
203
+ * const patterns = await client.listBehaviorPatterns("user-123", { limit: 20 });
204
+ * console.log(`Found ${patterns.length} patterns`);
205
+ * ```
206
+ */
207
+ listBehaviorPatterns(userId: string, options?: {
208
+ limit?: number;
209
+ offset?: number;
210
+ }): Promise<BehaviorPattern[]>;
114
211
  }
115
- //# sourceMappingURL=client.d.ts.map
@@ -21,4 +21,3 @@ export declare class EmbeddingError extends MemoryIntelligenceError {
21
21
  export declare class ValidationError extends MemoryIntelligenceError {
22
22
  constructor(message: string);
23
23
  }
24
- //# sourceMappingURL=errors.d.ts.map