@igniter-js/agents 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.
@@ -0,0 +1,2181 @@
1
+ import { LanguageModel } from 'ai';
2
+
3
+ /**
4
+ * @fileoverview Memory-related type definitions for the IgniterAgent library.
5
+ * This module contains all types, interfaces, and configurations for agent memory management.
6
+ *
7
+ * @description
8
+ * The memory system in IgniterAgent provides:
9
+ * - **Working Memory**: Persistent learned facts and context that agents maintain across conversations
10
+ * - **Conversation History**: Message storage for analytics, retrieval, and cross-session context
11
+ * - **Chat Sessions**: Metadata management for organizing conversations
12
+ * - **Auto-generation**: Automatic title and suggestion generation for enhanced UX
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * import {
17
+ * IgniterAgentMemoryProvider,
18
+ * IgniterAgentMemoryConfig
19
+ * } from '@igniter-js/agents';
20
+ *
21
+ * // Implement a custom memory provider
22
+ * const customProvider: IgniterAgentMemoryProvider = {
23
+ * getWorkingMemory: async ({ scope, identifier }) => {
24
+ * // Fetch from your database
25
+ * return { content: '...', updatedAt: new Date() };
26
+ * },
27
+ * updateWorkingMemory: async ({ scope, identifier, content }) => {
28
+ * // Save to your database
29
+ * }
30
+ * };
31
+ *
32
+ * // Configure memory for your agent
33
+ * const memoryConfig: IgniterAgentMemoryConfig = {
34
+ * provider: customProvider,
35
+ * working: { enabled: true, scope: 'chat' },
36
+ * history: { enabled: true, limit: 100 },
37
+ * chats: { enabled: true }
38
+ * };
39
+ * ```
40
+ *
41
+ * @module types/memory
42
+ * @packageDocumentation
43
+ */
44
+
45
+ /**
46
+ * Type alias for UI messages compatible with Vercel AI SDK.
47
+ *
48
+ * @description
49
+ * This type serves as a placeholder for the UIMessage type from the Vercel AI SDK.
50
+ * Users can override this type when calling `getMessages<T>()` to use their own
51
+ * message type that matches their application's needs.
52
+ *
53
+ * @remarks
54
+ * The default `any` type allows flexibility when integrating with different
55
+ * frontend frameworks or message formats. For type safety, consider creating
56
+ * your own message interface that matches your UI requirements.
57
+ *
58
+ * @example
59
+ * ```typescript
60
+ * // Using with default type
61
+ * const messages = await provider.getMessages({ chatId: '123' });
62
+ *
63
+ * // Using with custom type
64
+ * interface CustomMessage {
65
+ * id: string;
66
+ * role: 'user' | 'assistant';
67
+ * content: string;
68
+ * timestamp: Date;
69
+ * }
70
+ * const typedMessages = await provider.getMessages<CustomMessage>({ chatId: '123' });
71
+ * ```
72
+ *
73
+ * @see {@link https://sdk.vercel.ai/docs/reference/ai-sdk-ui/use-chat | Vercel AI SDK useChat}
74
+ * @public
75
+ */
76
+ type IgniterAgentUIMessage = unknown;
77
+ /**
78
+ * Defines the role of a message in a conversation.
79
+ *
80
+ * @description
81
+ * Standard roles used in chat-based AI applications:
82
+ * - `user`: Messages from the human user
83
+ * - `assistant`: Messages from the AI agent
84
+ * - `system`: System-level instructions or context
85
+ *
86
+ * @public
87
+ */
88
+ type IgniterAgentMessageRole = "user" | "assistant" | "system";
89
+ /**
90
+ * Defines the scope at which memory is stored and retrieved.
91
+ *
92
+ * @description
93
+ * Memory scope determines the isolation level for stored data:
94
+ *
95
+ * - **`chat`** (Recommended): Memory is scoped per conversation/chat session.
96
+ * Each chat has its own isolated memory that doesn't affect other chats.
97
+ * Best for most use cases where context should be conversation-specific.
98
+ *
99
+ * - **`user`**: Memory is scoped per user across all their chats.
100
+ * Useful for storing persistent user preferences or learned facts that
101
+ * should carry over between different conversations.
102
+ *
103
+ * @example
104
+ * ```typescript
105
+ * // Chat-scoped memory: Each conversation is independent
106
+ * const chatMemory: IgniterAgentMemoryScope = 'chat';
107
+ *
108
+ * // User-scoped memory: Shared across all user's conversations
109
+ * const userMemory: IgniterAgentMemoryScope = 'user';
110
+ * ```
111
+ *
112
+ * @public
113
+ */
114
+ type IgniterAgentMemoryScope = "chat" | "user";
115
+ /**
116
+ * Represents persistent working memory that agents maintain.
117
+ *
118
+ * @description
119
+ * Working memory stores learned facts, preferences, and context that the agent
120
+ * accumulates over time. Unlike conversation history, working memory is a
121
+ * curated, summarized representation of important information.
122
+ *
123
+ * @property content - The textual content of the working memory
124
+ * @property updatedAt - Timestamp of the last update
125
+ *
126
+ * @example
127
+ * ```typescript
128
+ * const workingMemory: IgniterAgentWorkingMemory = {
129
+ * content: `
130
+ * ## User Preferences
131
+ * - Prefers TypeScript over JavaScript
132
+ * - Uses Vim keybindings
133
+ * - Works on React projects primarily
134
+ *
135
+ * ## Project Context
136
+ * - Current project: E-commerce platform
137
+ * - Tech stack: Next.js, Prisma, PostgreSQL
138
+ * `,
139
+ * updatedAt: new Date('2024-01-15T10:30:00Z')
140
+ * };
141
+ * ```
142
+ *
143
+ * @see {@link IgniterAgentWorkingMemoryConfig} for configuration options
144
+ * @public
145
+ */
146
+ interface IgniterAgentWorkingMemory {
147
+ /**
148
+ * The textual content of the working memory.
149
+ *
150
+ * @description
151
+ * This is typically formatted as structured text (e.g., Markdown) containing
152
+ * organized information the agent has learned. The format is flexible and
153
+ * can be customized via the `template` configuration option.
154
+ */
155
+ content: string;
156
+ /**
157
+ * Timestamp of when the working memory was last updated.
158
+ *
159
+ * @description
160
+ * Used for tracking staleness and implementing cache invalidation strategies.
161
+ */
162
+ updatedAt: Date;
163
+ }
164
+ /**
165
+ * Represents a single message in a conversation history.
166
+ *
167
+ * @description
168
+ * Conversation messages are used for analytics, retrieval-augmented generation (RAG),
169
+ * and cross-session context. This is different from the real-time messages array
170
+ * passed to the agent, which comes directly from the frontend.
171
+ *
172
+ * @remarks
173
+ * The `content` field can be either a string or a parsed JSON object to support
174
+ * multimodal content (text, images, tool calls, etc.).
175
+ *
176
+ * @example
177
+ * ```typescript
178
+ * // Simple text message
179
+ * const textMessage: IgniterAgentConversationMessage = {
180
+ * chatId: 'chat_123',
181
+ * userId: 'user_456',
182
+ * role: 'user',
183
+ * content: 'How do I implement authentication in Next.js?',
184
+ * timestamp: new Date()
185
+ * };
186
+ *
187
+ * // Multimodal message with structured content
188
+ * const multimodalMessage: IgniterAgentConversationMessage = {
189
+ * chatId: 'chat_123',
190
+ * role: 'assistant',
191
+ * content: {
192
+ * type: 'text',
193
+ * text: 'Here is how to implement authentication...',
194
+ * toolCalls: [{ name: 'searchDocs', result: '...' }]
195
+ * },
196
+ * timestamp: new Date()
197
+ * };
198
+ * ```
199
+ *
200
+ * @public
201
+ */
202
+ interface IgniterAgentConversationMessage {
203
+ /**
204
+ * Unique identifier for the chat session this message belongs to.
205
+ *
206
+ * @description
207
+ * Used to group messages by conversation for retrieval and analytics.
208
+ */
209
+ chatId: string;
210
+ /**
211
+ * Optional identifier for the user who sent/received this message.
212
+ *
213
+ * @description
214
+ * Useful for multi-user applications or when implementing user-scoped
215
+ * memory and analytics.
216
+ */
217
+ userId?: string;
218
+ /**
219
+ * The role of the message sender.
220
+ *
221
+ * @see {@link IgniterAgentMessageRole}
222
+ */
223
+ role: IgniterAgentMessageRole;
224
+ /**
225
+ * The content of the message.
226
+ *
227
+ * @description
228
+ * Can be a simple string for text messages, or a complex object
229
+ * for multimodal content including images, tool calls, etc.
230
+ */
231
+ content: string | unknown;
232
+ /**
233
+ * When the message was created.
234
+ *
235
+ * @description
236
+ * Used for ordering messages and implementing time-based queries.
237
+ */
238
+ timestamp: Date;
239
+ }
240
+ /**
241
+ * Represents metadata for a chat session.
242
+ *
243
+ * @description
244
+ * Chat sessions provide organizational structure for conversations.
245
+ * They track metadata like titles, timestamps, and message counts
246
+ * without storing the actual message content.
247
+ *
248
+ * @example
249
+ * ```typescript
250
+ * const session: IgniterAgentChatSession = {
251
+ * chatId: 'chat_abc123',
252
+ * userId: 'user_xyz789',
253
+ * title: 'Next.js Authentication Discussion',
254
+ * createdAt: new Date('2024-01-15T09:00:00Z'),
255
+ * updatedAt: new Date('2024-01-15T10:30:00Z'),
256
+ * messageCount: 24
257
+ * };
258
+ * ```
259
+ *
260
+ * @public
261
+ */
262
+ interface IgniterAgentChatSession {
263
+ /**
264
+ * Unique identifier for the chat session.
265
+ *
266
+ * @description
267
+ * This ID is used to reference the chat in all related operations
268
+ * like retrieving messages, updating titles, or deleting the chat.
269
+ */
270
+ chatId: string;
271
+ /**
272
+ * Optional identifier for the user who owns this chat.
273
+ *
274
+ * @description
275
+ * Used for filtering chats by user and implementing access control.
276
+ */
277
+ userId?: string;
278
+ /**
279
+ * Human-readable title for the chat.
280
+ *
281
+ * @description
282
+ * Can be automatically generated from the first message or set manually.
283
+ * Used in chat lists and navigation.
284
+ */
285
+ title?: string;
286
+ /**
287
+ * When the chat session was created.
288
+ */
289
+ createdAt: Date;
290
+ /**
291
+ * When the chat session was last updated.
292
+ *
293
+ * @description
294
+ * Updated whenever a new message is added to the chat.
295
+ */
296
+ updatedAt: Date;
297
+ /**
298
+ * Total number of messages in this chat.
299
+ *
300
+ * @description
301
+ * Useful for displaying chat statistics without loading all messages.
302
+ */
303
+ messageCount: number;
304
+ }
305
+ /**
306
+ * Configuration for automatic chat title generation.
307
+ *
308
+ * @description
309
+ * When enabled, the system automatically generates descriptive titles
310
+ * for new chat sessions based on the initial conversation content.
311
+ *
312
+ * @example
313
+ * ```typescript
314
+ * const titleConfig: IgniterAgentGenerateTitleConfig = {
315
+ * enabled: true,
316
+ * model: openai('gpt-4'),
317
+ * instructions: `
318
+ * Generate a concise, descriptive title (max 50 chars)
319
+ * based on the conversation topic.
320
+ * `
321
+ * };
322
+ * ```
323
+ *
324
+ * @public
325
+ */
326
+ interface IgniterAgentGenerateTitleConfig {
327
+ /**
328
+ * Whether automatic title generation is enabled.
329
+ *
330
+ * @defaultValue false
331
+ */
332
+ enabled: boolean;
333
+ /**
334
+ * The language model to use for title generation.
335
+ *
336
+ * @description
337
+ * If not specified, falls back to the agent's default model.
338
+ * Consider using a smaller, faster model for title generation.
339
+ */
340
+ model?: LanguageModel;
341
+ /**
342
+ * Custom instructions for the title generation prompt.
343
+ *
344
+ * @description
345
+ * Override the default title generation prompt with custom instructions.
346
+ * Useful for enforcing specific title formats or styles.
347
+ */
348
+ instructions?: string;
349
+ }
350
+ /**
351
+ * Configuration for automatic prompt suggestions generation.
352
+ *
353
+ * @description
354
+ * When enabled, the system generates follow-up prompt suggestions
355
+ * after the assistant responds. These suggestions help guide users
356
+ * toward productive next steps in the conversation.
357
+ *
358
+ * @example
359
+ * ```typescript
360
+ * const suggestionsConfig: IgniterAgentGenerateSuggestionsConfig = {
361
+ * enabled: true,
362
+ * model: openai('gpt-3.5-turbo'),
363
+ * limit: 3,
364
+ * minResponseLength: 100,
365
+ * contextWindow: 2,
366
+ * instructions: `
367
+ * Generate helpful follow-up questions that dive deeper
368
+ * into the topic or explore related areas.
369
+ * `
370
+ * };
371
+ * ```
372
+ *
373
+ * @public
374
+ */
375
+ interface IgniterAgentGenerateSuggestionsConfig {
376
+ /**
377
+ * Whether automatic suggestion generation is enabled.
378
+ *
379
+ * @defaultValue false
380
+ */
381
+ enabled: boolean;
382
+ /**
383
+ * The language model to use for suggestion generation.
384
+ *
385
+ * @description
386
+ * If not specified, falls back to the agent's default model.
387
+ * Consider using a smaller, faster model for suggestions.
388
+ */
389
+ model?: LanguageModel;
390
+ /**
391
+ * Custom instructions for the suggestion generation prompt.
392
+ *
393
+ * @description
394
+ * Override the default suggestion prompt with custom instructions.
395
+ * Useful for generating domain-specific or styled suggestions.
396
+ */
397
+ instructions?: string;
398
+ /**
399
+ * Maximum number of suggestions to generate.
400
+ *
401
+ * @description
402
+ * Limits the number of follow-up prompts returned.
403
+ *
404
+ * @defaultValue 5
405
+ */
406
+ limit?: number;
407
+ /**
408
+ * Minimum assistant response length to trigger suggestion generation.
409
+ *
410
+ * @description
411
+ * Suggestions are only generated when the assistant's response
412
+ * exceeds this character count. Short responses (like confirmations)
413
+ * typically don't need follow-up suggestions.
414
+ *
415
+ * @defaultValue 100
416
+ */
417
+ minResponseLength?: number;
418
+ /**
419
+ * Number of recent message exchanges to use as context.
420
+ *
421
+ * @description
422
+ * Determines how many previous user-assistant exchanges are included
423
+ * when generating suggestions. Higher values provide more context
424
+ * but increase token usage.
425
+ *
426
+ * @defaultValue 1
427
+ */
428
+ contextWindow?: number;
429
+ }
430
+ /**
431
+ * Configuration for working memory features.
432
+ *
433
+ * @description
434
+ * Controls how the agent manages persistent learned facts and context.
435
+ *
436
+ * @example
437
+ * ```typescript
438
+ * const workingConfig: IgniterAgentWorkingMemoryConfig = {
439
+ * enabled: true,
440
+ * scope: 'chat',
441
+ * template: `
442
+ * ## Learned Facts
443
+ * {{facts}}
444
+ *
445
+ * ## User Preferences
446
+ * {{preferences}}
447
+ * `
448
+ * };
449
+ * ```
450
+ *
451
+ * @public
452
+ */
453
+ interface IgniterAgentWorkingMemoryConfig {
454
+ /**
455
+ * Whether working memory is enabled.
456
+ *
457
+ * @description
458
+ * When enabled, the agent will store and retrieve persistent context.
459
+ */
460
+ enabled: boolean;
461
+ /**
462
+ * The scope at which working memory is stored.
463
+ *
464
+ * @see {@link IgniterAgentMemoryScope}
465
+ */
466
+ scope: IgniterAgentMemoryScope;
467
+ /**
468
+ * Optional template for formatting working memory content.
469
+ *
470
+ * @description
471
+ * Defines the structure of how working memory is organized and stored.
472
+ * Supports template variables that can be replaced at runtime.
473
+ */
474
+ template?: string;
475
+ }
476
+ /**
477
+ * Configuration for conversation history features.
478
+ *
479
+ * @description
480
+ * Controls how the agent stores and retrieves conversation messages.
481
+ * Note that history storage is separate from the real-time messages
482
+ * passed to the agent from the frontend.
483
+ *
484
+ * @example
485
+ * ```typescript
486
+ * const historyConfig: IgniterAgentHistoryConfig = {
487
+ * enabled: true,
488
+ * limit: 50 // Load last 50 messages for context
489
+ * };
490
+ * ```
491
+ *
492
+ * @public
493
+ */
494
+ interface IgniterAgentHistoryConfig {
495
+ /**
496
+ * Whether conversation history storage is enabled.
497
+ *
498
+ * @description
499
+ * When enabled, messages are persisted for analytics and retrieval.
500
+ */
501
+ enabled: boolean;
502
+ /**
503
+ * Maximum number of messages to load from history.
504
+ *
505
+ * @description
506
+ * Limits how many historical messages are retrieved when building context.
507
+ * Lower values reduce token usage but may lose important context.
508
+ */
509
+ limit?: number;
510
+ }
511
+ /**
512
+ * Configuration for chat session management features.
513
+ *
514
+ * @description
515
+ * Controls chat session metadata, title generation, and suggestions.
516
+ *
517
+ * @example
518
+ * ```typescript
519
+ * const chatsConfig: IgniterAgentChatsConfig = {
520
+ * enabled: true,
521
+ * generateTitle: {
522
+ * enabled: true,
523
+ * model: openai('gpt-3.5-turbo')
524
+ * },
525
+ * generateSuggestions: {
526
+ * enabled: true,
527
+ * limit: 3
528
+ * }
529
+ * };
530
+ * ```
531
+ *
532
+ * @public
533
+ */
534
+ interface IgniterAgentChatsConfig {
535
+ /**
536
+ * Whether chat session management is enabled.
537
+ */
538
+ enabled: boolean;
539
+ /**
540
+ * Configuration for automatic title generation.
541
+ *
542
+ * @see {@link IgniterAgentGenerateTitleConfig}
543
+ */
544
+ generateTitle?: IgniterAgentGenerateTitleConfig;
545
+ /**
546
+ * Configuration for automatic suggestion generation.
547
+ *
548
+ * @see {@link IgniterAgentGenerateSuggestionsConfig}
549
+ */
550
+ generateSuggestions?: IgniterAgentGenerateSuggestionsConfig;
551
+ }
552
+ /**
553
+ * Parameters for working memory operations.
554
+ *
555
+ * @description
556
+ * Used when getting or updating working memory through the provider.
557
+ *
558
+ * @typeParam TScope - The memory scope type
559
+ * @typeParam TIdentifier - The identifier type
560
+ *
561
+ * @public
562
+ */
563
+ interface IgniterAgentWorkingMemoryParams<TScope extends string = string, TIdentifier extends string = string> {
564
+ /**
565
+ * The scope at which to access memory.
566
+ *
567
+ * @see {@link IgniterAgentMemoryScope}
568
+ */
569
+ scope: TScope;
570
+ /**
571
+ * The unique identifier for the memory (e.g., chatId or userId).
572
+ */
573
+ identifier: TIdentifier;
574
+ }
575
+ /**
576
+ * Parameters for updating working memory.
577
+ *
578
+ * @typeParam TScope - The memory scope type
579
+ * @typeParam TIdentifier - The identifier type
580
+ *
581
+ * @public
582
+ */
583
+ interface IgniterAgentUpdateWorkingMemoryParams<TScope extends string = string, TIdentifier extends string = string> extends IgniterAgentWorkingMemoryParams<TScope, TIdentifier> {
584
+ /**
585
+ * The new content to store in working memory.
586
+ */
587
+ content: string;
588
+ }
589
+ /**
590
+ * Parameters for retrieving messages from history.
591
+ *
592
+ * @public
593
+ */
594
+ interface IgniterAgentGetMessagesParams {
595
+ /**
596
+ * The chat session ID to retrieve messages from.
597
+ */
598
+ chatId: string;
599
+ /**
600
+ * Optional user ID to filter messages.
601
+ */
602
+ userId?: string;
603
+ /**
604
+ * Maximum number of messages to retrieve.
605
+ */
606
+ limit?: number;
607
+ }
608
+ /**
609
+ * Parameters for retrieving chat sessions.
610
+ *
611
+ * @public
612
+ */
613
+ interface IgniterAgentGetChatsParams {
614
+ /**
615
+ * Optional user ID to filter chats.
616
+ */
617
+ userId?: string;
618
+ /**
619
+ * Optional search query to filter chats by title.
620
+ */
621
+ search?: string;
622
+ /**
623
+ * Maximum number of chats to retrieve.
624
+ */
625
+ limit?: number;
626
+ }
627
+ /**
628
+ * Memory Provider Interface for implementing custom storage backends.
629
+ *
630
+ * @description
631
+ * This interface defines the contract for any storage backend that can be used
632
+ * with the IgniterAgent memory system. Implement this interface to create
633
+ * custom providers for Redis, PostgreSQL, MongoDB, or any other storage solution.
634
+ *
635
+ * The interface has two required methods for working memory, and several
636
+ * optional methods for extended functionality like conversation history
637
+ * and chat session management.
638
+ *
639
+ * @typeParam TScope - The memory scope type (defaults to string)
640
+ * @typeParam TIdentifier - The identifier type (defaults to string)
641
+ *
642
+ * @example
643
+ * ```typescript
644
+ * import { IgniterAgentMemoryProvider } from '@igniter-js/agents';
645
+ * import { Redis } from 'ioredis';
646
+ *
647
+ * class RedisMemoryProvider implements IgniterAgentMemoryProvider {
648
+ * private redis: Redis;
649
+ *
650
+ * constructor(redis: Redis) {
651
+ * this.redis = redis;
652
+ * }
653
+ *
654
+ * async getWorkingMemory({ scope, identifier }) {
655
+ * const key = `memory:${scope}:${identifier}`;
656
+ * const data = await this.redis.get(key);
657
+ * if (!data) return null;
658
+ *
659
+ * const parsed = JSON.parse(data);
660
+ * return {
661
+ * content: parsed.content,
662
+ * updatedAt: new Date(parsed.updatedAt)
663
+ * };
664
+ * }
665
+ *
666
+ * async updateWorkingMemory({ scope, identifier, content }) {
667
+ * const key = `memory:${scope}:${identifier}`;
668
+ * await this.redis.set(key, JSON.stringify({
669
+ * content,
670
+ * updatedAt: new Date().toISOString()
671
+ * }));
672
+ * }
673
+ *
674
+ * // Implement optional methods as needed...
675
+ * }
676
+ * ```
677
+ *
678
+ * @see {@link IgniterAgentWorkingMemory} for the working memory structure
679
+ * @see {@link IgniterAgentConversationMessage} for message structure
680
+ * @see {@link IgniterAgentChatSession} for chat session structure
681
+ *
682
+ * @public
683
+ */
684
+ interface IgniterAgentMemoryProvider<TScope extends string = string, TIdentifier extends string = string> {
685
+ /**
686
+ * Retrieves persistent working memory for the given scope and identifier.
687
+ *
688
+ * @description
689
+ * Fetches the accumulated working memory content. Returns null if no
690
+ * memory exists yet for the given scope/identifier combination.
691
+ *
692
+ * @param params - The scope and identifier to retrieve memory for
693
+ * @returns The working memory object, or null if not found
694
+ *
695
+ * @example
696
+ * ```typescript
697
+ * const memory = await provider.getWorkingMemory({
698
+ * scope: 'chat',
699
+ * identifier: 'chat_123'
700
+ * });
701
+ *
702
+ * if (memory) {
703
+ * console.log('Last updated:', memory.updatedAt);
704
+ * console.log('Content:', memory.content);
705
+ * }
706
+ * ```
707
+ */
708
+ getWorkingMemory(params: IgniterAgentWorkingMemoryParams<TScope, TIdentifier>): Promise<IgniterAgentWorkingMemory | null>;
709
+ /**
710
+ * Updates persistent working memory for the given scope and identifier.
711
+ *
712
+ * @description
713
+ * Stores or updates the working memory content. This should create
714
+ * a new entry if one doesn't exist, or update the existing entry.
715
+ *
716
+ * @param params - The scope, identifier, and new content
717
+ *
718
+ * @example
719
+ * ```typescript
720
+ * await provider.updateWorkingMemory({
721
+ * scope: 'chat',
722
+ * identifier: 'chat_123',
723
+ * content: `
724
+ * ## Learned Facts
725
+ * - User prefers TypeScript
726
+ * - Working on a Next.js project
727
+ * `
728
+ * });
729
+ * ```
730
+ */
731
+ updateWorkingMemory(params: IgniterAgentUpdateWorkingMemoryParams<TScope, TIdentifier>): Promise<void>;
732
+ /**
733
+ * Saves a message to the conversation history.
734
+ *
735
+ * @description
736
+ * Persists a single conversation message for analytics and retrieval.
737
+ * This is separate from the real-time messages array and is used for
738
+ * long-term storage and cross-session context.
739
+ *
740
+ * @remarks
741
+ * This method is optional. If not implemented, conversation history
742
+ * features will be unavailable.
743
+ *
744
+ * @param message - The message to save
745
+ *
746
+ * @example
747
+ * ```typescript
748
+ * await provider.saveMessage?.({
749
+ * chatId: 'chat_123',
750
+ * userId: 'user_456',
751
+ * role: 'user',
752
+ * content: 'How do I deploy to Vercel?',
753
+ * timestamp: new Date()
754
+ * });
755
+ * ```
756
+ */
757
+ saveMessage?(message: IgniterAgentConversationMessage): Promise<void>;
758
+ /**
759
+ * Retrieves recent messages from conversation history.
760
+ *
761
+ * @description
762
+ * Fetches messages for a given chat, optionally filtered by user
763
+ * and limited to a specific count. Returns messages in UIMessage
764
+ * format compatible with the Vercel AI SDK.
765
+ *
766
+ * @remarks
767
+ * This method is optional. If not implemented, message retrieval
768
+ * features will be unavailable.
769
+ *
770
+ * @typeParam T - The message type to return (defaults to UIMessage)
771
+ * @param params - Query parameters for message retrieval
772
+ * @returns Array of messages in the specified format
773
+ *
774
+ * @example
775
+ * ```typescript
776
+ * // Get last 50 messages
777
+ * const messages = await provider.getMessages?.({
778
+ * chatId: 'chat_123',
779
+ * limit: 50
780
+ * });
781
+ *
782
+ * // Get with custom type
783
+ * interface MyMessage { id: string; text: string; }
784
+ * const typed = await provider.getMessages?.<MyMessage>({ chatId: '123' });
785
+ * ```
786
+ */
787
+ getMessages?<T = IgniterAgentUIMessage>(params: IgniterAgentGetMessagesParams): Promise<T[]>;
788
+ /**
789
+ * Saves or updates a chat session.
790
+ *
791
+ * @description
792
+ * Creates a new chat session or updates an existing one.
793
+ * Used for organizing conversations and tracking metadata.
794
+ *
795
+ * @remarks
796
+ * This method is optional. If not implemented, chat session
797
+ * management features will be unavailable.
798
+ *
799
+ * @param chat - The chat session to save
800
+ *
801
+ * @example
802
+ * ```typescript
803
+ * await provider.saveChat?.({
804
+ * chatId: 'chat_123',
805
+ * userId: 'user_456',
806
+ * title: 'Vercel Deployment Help',
807
+ * createdAt: new Date(),
808
+ * updatedAt: new Date(),
809
+ * messageCount: 1
810
+ * });
811
+ * ```
812
+ */
813
+ saveChat?(chat: IgniterAgentChatSession): Promise<void>;
814
+ /**
815
+ * Retrieves chat sessions for a user.
816
+ *
817
+ * @description
818
+ * Fetches a list of chat sessions, optionally filtered by user
819
+ * and/or search query. Returns all chats if no userId is provided.
820
+ *
821
+ * @remarks
822
+ * This method is optional. If not implemented, chat listing
823
+ * features will be unavailable.
824
+ *
825
+ * @param params - Query parameters for chat retrieval
826
+ * @returns Array of chat sessions matching the criteria
827
+ *
828
+ * @example
829
+ * ```typescript
830
+ * // Get all chats for a user
831
+ * const userChats = await provider.getChats?.({
832
+ * userId: 'user_456',
833
+ * limit: 20
834
+ * });
835
+ *
836
+ * // Search chats by title
837
+ * const searchResults = await provider.getChats?.({
838
+ * userId: 'user_456',
839
+ * search: 'deployment',
840
+ * limit: 10
841
+ * });
842
+ * ```
843
+ */
844
+ getChats?(params: IgniterAgentGetChatsParams): Promise<IgniterAgentChatSession[]>;
845
+ /**
846
+ * Retrieves a specific chat session by ID.
847
+ *
848
+ * @description
849
+ * Fetches a single chat session's metadata by its unique identifier.
850
+ *
851
+ * @remarks
852
+ * This method is optional. If not implemented, single chat retrieval
853
+ * will be unavailable.
854
+ *
855
+ * @param chatId - The unique chat session ID
856
+ * @returns The chat session, or null if not found
857
+ *
858
+ * @example
859
+ * ```typescript
860
+ * const chat = await provider.getChat?.('chat_123');
861
+ * if (chat) {
862
+ * console.log('Title:', chat.title);
863
+ * console.log('Messages:', chat.messageCount);
864
+ * }
865
+ * ```
866
+ */
867
+ getChat?(chatId: string): Promise<IgniterAgentChatSession | null>;
868
+ /**
869
+ * Updates the title of a chat session.
870
+ *
871
+ * @description
872
+ * Changes the title of an existing chat session. Useful for
873
+ * user-initiated title changes or auto-generated title updates.
874
+ *
875
+ * @remarks
876
+ * This method is optional. If not implemented, title updates
877
+ * will be unavailable.
878
+ *
879
+ * @param chatId - The unique chat session ID
880
+ * @param title - The new title for the chat
881
+ *
882
+ * @example
883
+ * ```typescript
884
+ * await provider.updateChatTitle?.(
885
+ * 'chat_123',
886
+ * 'Updated: Vercel & AWS Deployment Guide'
887
+ * );
888
+ * ```
889
+ */
890
+ updateChatTitle?(chatId: string, title: string): Promise<void>;
891
+ /**
892
+ * Deletes a chat session and all its associated messages.
893
+ *
894
+ * @description
895
+ * Permanently removes a chat session and all related data.
896
+ * This operation should be irreversible.
897
+ *
898
+ * @remarks
899
+ * This method is optional. If not implemented, chat deletion
900
+ * will be unavailable.
901
+ *
902
+ * @param chatId - The unique chat session ID to delete
903
+ *
904
+ * @example
905
+ * ```typescript
906
+ * // Delete a chat and all its messages
907
+ * await provider.deleteChat?.('chat_123');
908
+ * ```
909
+ */
910
+ deleteChat?(chatId: string): Promise<void>;
911
+ }
912
+ /**
913
+ * Complete memory configuration for an IgniterAgent.
914
+ *
915
+ * @description
916
+ * This is the main configuration object for setting up memory features
917
+ * in an agent. It combines provider configuration with feature-specific
918
+ * settings for working memory, history, and chat management.
919
+ *
920
+ * @example
921
+ * ```typescript
922
+ * import {
923
+ * IgniterAgentMemoryConfig,
924
+ * IgniterAgentMemoryProvider
925
+ * } from '@igniter-js/agents';
926
+ *
927
+ * const memoryConfig: IgniterAgentMemoryConfig = {
928
+ * // Required: Storage provider implementation
929
+ * provider: myRedisProvider,
930
+ *
931
+ * // Optional: Working memory configuration
932
+ * working: {
933
+ * enabled: true,
934
+ * scope: 'chat',
935
+ * template: '## Context\n{{content}}'
936
+ * },
937
+ *
938
+ * // Optional: Conversation history
939
+ * history: {
940
+ * enabled: true,
941
+ * limit: 100
942
+ * },
943
+ *
944
+ * // Optional: Chat session management
945
+ * chats: {
946
+ * enabled: true,
947
+ * generateTitle: {
948
+ * enabled: true,
949
+ * model: openai('gpt-3.5-turbo')
950
+ * },
951
+ * generateSuggestions: {
952
+ * enabled: true,
953
+ * limit: 3,
954
+ * minResponseLength: 100
955
+ * }
956
+ * }
957
+ * };
958
+ * ```
959
+ *
960
+ * @see {@link IgniterAgentMemoryProvider} for implementing custom providers
961
+ * @see {@link IgniterAgentWorkingMemoryConfig} for working memory options
962
+ * @see {@link IgniterAgentHistoryConfig} for history options
963
+ * @see {@link IgniterAgentChatsConfig} for chat management options
964
+ *
965
+ * @public
966
+ */
967
+ interface IgniterAgentMemoryConfig {
968
+ /**
969
+ * The storage provider implementation.
970
+ *
971
+ * @description
972
+ * Must implement the {@link IgniterAgentMemoryProvider} interface.
973
+ * This is the only required field in the configuration.
974
+ *
975
+ * @see {@link IgniterAgentMemoryProvider}
976
+ */
977
+ provider: IgniterAgentMemoryProvider;
978
+ /**
979
+ * Configuration for working memory (learned facts).
980
+ *
981
+ * @description
982
+ * Controls how the agent stores and retrieves persistent context
983
+ * across conversations.
984
+ *
985
+ * @see {@link IgniterAgentWorkingMemoryConfig}
986
+ */
987
+ working?: IgniterAgentWorkingMemoryConfig;
988
+ /**
989
+ * Configuration for conversation history.
990
+ *
991
+ * @description
992
+ * Controls message persistence for analytics and retrieval.
993
+ * Note that the agent still receives messages from the frontend;
994
+ * this is for additional persistence and cross-session context.
995
+ *
996
+ * @see {@link IgniterAgentHistoryConfig}
997
+ */
998
+ history?: IgniterAgentHistoryConfig;
999
+ /**
1000
+ * Configuration for chat session management.
1001
+ *
1002
+ * @description
1003
+ * Controls chat metadata, title generation, and prompt suggestions.
1004
+ *
1005
+ * @see {@link IgniterAgentChatsConfig}
1006
+ */
1007
+ chats?: IgniterAgentChatsConfig;
1008
+ }
1009
+ /**
1010
+ * Runtime interface exposed by IgniterAgent for memory operations.
1011
+ *
1012
+ * @public
1013
+ */
1014
+ interface IgniterAgentMemoryRuntime {
1015
+ getWorkingMemory(params: IgniterAgentWorkingMemoryParams): Promise<IgniterAgentWorkingMemory | null>;
1016
+ updateWorkingMemory(params: IgniterAgentUpdateWorkingMemoryParams): Promise<void>;
1017
+ saveMessage(message: IgniterAgentConversationMessage): Promise<void>;
1018
+ getMessages<T = IgniterAgentUIMessage>(params: IgniterAgentGetMessagesParams): Promise<T[]>;
1019
+ saveChat(chat: IgniterAgentChatSession): Promise<void>;
1020
+ getChats(params: IgniterAgentGetChatsParams): Promise<IgniterAgentChatSession[]>;
1021
+ getChat(chatId: string): Promise<IgniterAgentChatSession | null>;
1022
+ updateChatTitle(chatId: string, title: string): Promise<void>;
1023
+ deleteChat(chatId: string): Promise<void>;
1024
+ }
1025
+
1026
+ /**
1027
+ * @fileoverview Type definitions for IgniterAgent memory adapters.
1028
+ * This module contains interfaces for implementing storage backends.
1029
+ *
1030
+ * @module types/adapter
1031
+ * @packageDocumentation
1032
+ */
1033
+
1034
+ /**
1035
+ * Base options for adapter configuration.
1036
+ *
1037
+ * @description
1038
+ * Common configuration options shared by all adapter implementations.
1039
+ *
1040
+ * @example
1041
+ * ```typescript
1042
+ * const baseOptions: IgniterAgentAdapterOptions = {
1043
+ * namespace: 'myapp',
1044
+ * };
1045
+ * ```
1046
+ *
1047
+ * @public
1048
+ */
1049
+ interface IgniterAgentAdapterOptions {
1050
+ /**
1051
+ * Optional namespace prefix for all keys.
1052
+ *
1053
+ * @description
1054
+ * Useful for multi-tenant applications or to avoid key collisions.
1055
+ * The namespace is prepended to all storage keys.
1056
+ *
1057
+ * @example
1058
+ * ```typescript
1059
+ * // With namespace 'myapp', keys become:
1060
+ * // 'myapp:memory:chat:123'
1061
+ * // 'myapp:messages:chat:123'
1062
+ * ```
1063
+ */
1064
+ namespace?: string;
1065
+ }
1066
+ /**
1067
+ * Configuration options for the in-memory adapter.
1068
+ *
1069
+ * @description
1070
+ * The in-memory adapter stores all data in JavaScript Maps.
1071
+ * Useful for development, testing, or short-lived applications.
1072
+ *
1073
+ * @remarks
1074
+ * Data is lost when the process restarts. For production use,
1075
+ * consider using a persistent adapter like Redis or PostgreSQL.
1076
+ *
1077
+ * @example
1078
+ * ```typescript
1079
+ * const options: IgniterAgentInMemoryAdapterOptions = {
1080
+ * namespace: 'test',
1081
+ * debug: true,
1082
+ * maxMessages: 1000,
1083
+ * maxChats: 100
1084
+ * };
1085
+ *
1086
+ * const adapter = new IgniterAgentInMemoryAdapter(options);
1087
+ * ```
1088
+ *
1089
+ * @public
1090
+ */
1091
+ interface IgniterAgentInMemoryAdapterOptions extends IgniterAgentAdapterOptions {
1092
+ /**
1093
+ * Maximum number of messages to store per chat.
1094
+ *
1095
+ * @description
1096
+ * Limits memory usage by capping the number of messages.
1097
+ * Oldest messages are removed when the limit is exceeded.
1098
+ *
1099
+ * @defaultValue 1000
1100
+ */
1101
+ maxMessages?: number;
1102
+ /**
1103
+ * Maximum number of chat sessions to store.
1104
+ *
1105
+ * @description
1106
+ * Limits memory usage by capping the number of chats.
1107
+ * Oldest chats are removed when the limit is exceeded.
1108
+ *
1109
+ * @defaultValue 100
1110
+ */
1111
+ maxChats?: number;
1112
+ }
1113
+ /**
1114
+ * Configuration options for the Redis adapter.
1115
+ *
1116
+ * @description
1117
+ * The Redis adapter provides persistent, high-performance storage
1118
+ * suitable for production deployments.
1119
+ *
1120
+ * @example
1121
+ * ```typescript
1122
+ * import Redis from 'ioredis';
1123
+ *
1124
+ * const redis = new Redis({
1125
+ * host: 'localhost',
1126
+ * port: 6379
1127
+ * });
1128
+ *
1129
+ * const options: IgniterAgentRedisAdapterOptions = {
1130
+ * client: redis,
1131
+ * namespace: 'igniter',
1132
+ * ttl: 86400 * 30, // 30 days
1133
+ * debug: false
1134
+ * };
1135
+ * ```
1136
+ *
1137
+ * @public
1138
+ */
1139
+ interface IgniterAgentRedisAdapterOptions extends IgniterAgentAdapterOptions {
1140
+ /**
1141
+ * Redis client instance.
1142
+ *
1143
+ * @description
1144
+ * An initialized Redis client (e.g., from ioredis or redis package).
1145
+ * The adapter expects the client to be already connected.
1146
+ */
1147
+ client: unknown;
1148
+ /**
1149
+ * Time-to-live for stored data in seconds.
1150
+ *
1151
+ * @description
1152
+ * Sets an expiration time for all stored data. Useful for
1153
+ * automatic cleanup of old conversations.
1154
+ *
1155
+ * @defaultValue undefined (no expiration)
1156
+ */
1157
+ ttl?: number;
1158
+ /**
1159
+ * Redis key prefix.
1160
+ *
1161
+ * @description
1162
+ * All keys are prefixed with this value. If not specified,
1163
+ * falls back to the namespace option.
1164
+ *
1165
+ * @defaultValue 'igniter:agent'
1166
+ */
1167
+ keyPrefix?: string;
1168
+ }
1169
+ /**
1170
+ * Abstract base class interface for memory adapters.
1171
+ *
1172
+ * @description
1173
+ * Defines the contract that all memory adapters must implement.
1174
+ * Extends the MemoryProvider interface with additional lifecycle methods.
1175
+ *
1176
+ * @typeParam TOptions - The adapter-specific options type
1177
+ *
1178
+ * @example
1179
+ * ```typescript
1180
+ * class CustomAdapter implements IgniterAgentMemoryAdapter<CustomAdapterOptions> {
1181
+ * private options: CustomAdapterOptions;
1182
+ *
1183
+ * constructor(options: CustomAdapterOptions) {
1184
+ * this.options = options;
1185
+ * }
1186
+ *
1187
+ * async connect(): Promise<void> {
1188
+ * // Initialize connection
1189
+ * }
1190
+ *
1191
+ * async disconnect(): Promise<void> {
1192
+ * // Cleanup
1193
+ * }
1194
+ *
1195
+ * // ... implement MemoryProvider methods
1196
+ * }
1197
+ * ```
1198
+ *
1199
+ * @public
1200
+ */
1201
+ interface IgniterAgentMemoryAdapter<TOptions extends IgniterAgentAdapterOptions = IgniterAgentAdapterOptions> extends IgniterAgentMemoryProvider {
1202
+ /**
1203
+ * The adapter configuration options.
1204
+ */
1205
+ readonly options: TOptions;
1206
+ /**
1207
+ * Establishes connection to the storage backend.
1208
+ *
1209
+ * @description
1210
+ * Called during adapter initialization. For adapters that
1211
+ * maintain persistent connections (e.g., Redis), this establishes
1212
+ * the connection. For in-memory adapters, this may be a no-op.
1213
+ *
1214
+ * @throws {IgniterAgentAdapterConnectionError} If connection fails
1215
+ *
1216
+ * @example
1217
+ * ```typescript
1218
+ * const adapter = new RedisAdapter(options);
1219
+ * await adapter.connect();
1220
+ * console.log('Connected to Redis');
1221
+ * ```
1222
+ */
1223
+ connect?(): Promise<void>;
1224
+ /**
1225
+ * Closes connection to the storage backend.
1226
+ *
1227
+ * @description
1228
+ * Called during cleanup. Should release all resources and
1229
+ * close any open connections.
1230
+ *
1231
+ * @example
1232
+ * ```typescript
1233
+ * await adapter.disconnect();
1234
+ * console.log('Disconnected from Redis');
1235
+ * ```
1236
+ */
1237
+ disconnect?(): Promise<void>;
1238
+ /**
1239
+ * Checks if the adapter is connected and ready.
1240
+ *
1241
+ * @description
1242
+ * Returns true if the adapter is ready to handle operations.
1243
+ *
1244
+ * @returns Whether the adapter is connected
1245
+ */
1246
+ isConnected?(): boolean;
1247
+ /**
1248
+ * Clears all data from the adapter.
1249
+ *
1250
+ * @description
1251
+ * Removes all stored data. Use with caution in production.
1252
+ * Primarily useful for testing and development.
1253
+ *
1254
+ * @example
1255
+ * ```typescript
1256
+ * // Clear all test data
1257
+ * await adapter.clear();
1258
+ * ```
1259
+ */
1260
+ clear?(): Promise<void>;
1261
+ }
1262
+ /**
1263
+ * Factory function type for creating memory adapters.
1264
+ *
1265
+ * @description
1266
+ * Used for dependency injection and adapter configuration.
1267
+ *
1268
+ * @typeParam TOptions - The adapter options type
1269
+ * @typeParam TAdapter - The adapter type returned
1270
+ *
1271
+ * @example
1272
+ * ```typescript
1273
+ * const createRedisAdapter: IgniterAgentAdapterFactory<
1274
+ * IgniterAgentRedisAdapterOptions,
1275
+ * RedisAdapter
1276
+ * > = (options) => {
1277
+ * return new RedisAdapter(options);
1278
+ * };
1279
+ * ```
1280
+ *
1281
+ * @public
1282
+ */
1283
+ type IgniterAgentAdapterFactory<TOptions extends IgniterAgentAdapterOptions = IgniterAgentAdapterOptions, TAdapter extends IgniterAgentMemoryAdapter<TOptions> = IgniterAgentMemoryAdapter<TOptions>> = (options: TOptions) => TAdapter;
1284
+ /**
1285
+ * Result of a batch operation.
1286
+ *
1287
+ * @description
1288
+ * Used when performing operations that affect multiple records.
1289
+ *
1290
+ * @example
1291
+ * ```typescript
1292
+ * const result: IgniterAgentAdapterBatchResult = {
1293
+ * success: true,
1294
+ * affected: 42,
1295
+ * errors: []
1296
+ * };
1297
+ * ```
1298
+ *
1299
+ * @public
1300
+ */
1301
+ interface IgniterAgentAdapterBatchResult {
1302
+ /**
1303
+ * Whether the batch operation completed successfully.
1304
+ */
1305
+ success: boolean;
1306
+ /**
1307
+ * Number of records affected by the operation.
1308
+ */
1309
+ affected: number;
1310
+ /**
1311
+ * Any errors that occurred during the batch operation.
1312
+ */
1313
+ errors: Error[];
1314
+ }
1315
+ /**
1316
+ * Statistics about adapter storage usage.
1317
+ *
1318
+ * @description
1319
+ * Provides insight into the adapter's current state and usage.
1320
+ *
1321
+ * @example
1322
+ * ```typescript
1323
+ * const stats = await adapter.getStats();
1324
+ * console.log(`Storing ${stats.messageCount} messages`);
1325
+ * console.log(`Across ${stats.chatCount} chats`);
1326
+ * ```
1327
+ *
1328
+ * @public
1329
+ */
1330
+ interface IgniterAgentAdapterStats {
1331
+ /**
1332
+ * Total number of working memory entries.
1333
+ */
1334
+ workingMemoryCount: number;
1335
+ /**
1336
+ * Total number of stored messages.
1337
+ */
1338
+ messageCount: number;
1339
+ /**
1340
+ * Total number of chat sessions.
1341
+ */
1342
+ chatCount: number;
1343
+ /**
1344
+ * Storage size in bytes (if available).
1345
+ */
1346
+ storageBytes?: number;
1347
+ /**
1348
+ * When the stats were collected.
1349
+ */
1350
+ timestamp: Date;
1351
+ }
1352
+
1353
+ /**
1354
+ * @fileoverview In-memory adapter for IgniterAgent memory storage.
1355
+ * This module provides a simple in-memory implementation of the memory provider.
1356
+ *
1357
+ * @description
1358
+ * The IgniterAgentInMemoryAdapter stores all data in JavaScript Maps,
1359
+ * making it ideal for:
1360
+ * - Development and testing
1361
+ * - Short-lived applications
1362
+ * - Prototyping
1363
+ * - Demos
1364
+ *
1365
+ * **Important:** Data is lost when the process restarts. For production use,
1366
+ * consider using a persistent adapter like Redis or PostgreSQL.
1367
+ *
1368
+ * @example
1369
+ * ```typescript
1370
+ * import { IgniterAgentInMemoryAdapter } from '@igniter-js/agents/adapters';
1371
+ *
1372
+ * // Create adapter
1373
+ * const adapter = new IgniterAgentInMemoryAdapter({
1374
+ * namespace: 'myapp',
1375
+ * debug: true
1376
+ * });
1377
+ *
1378
+ * // Use with memory config
1379
+ * const memoryConfig: IgniterAgentMemoryConfig = {
1380
+ * provider: adapter,
1381
+ * working: { enabled: true, scope: 'chat' },
1382
+ * history: { enabled: true, limit: 100 }
1383
+ * };
1384
+ * ```
1385
+ *
1386
+ * @module adapters/memory
1387
+ * @packageDocumentation
1388
+ */
1389
+
1390
+ /**
1391
+ * In-memory implementation of the IgniterAgent memory provider.
1392
+ *
1393
+ * @description
1394
+ * Stores all memory data in JavaScript Maps. Provides a complete implementation
1395
+ * of the memory provider interface for development and testing purposes.
1396
+ *
1397
+ * **Features:**
1398
+ * - Full implementation of all memory provider methods
1399
+ * - Optional message/chat limits to control memory usage
1400
+ * - Debug logging
1401
+ * - Namespace support for multi-tenant applications
1402
+ *
1403
+ * **Limitations:**
1404
+ * - Data is not persisted across process restarts
1405
+ * - Not suitable for production with high availability requirements
1406
+ * - No horizontal scaling support
1407
+ *
1408
+ * @example
1409
+ * ```typescript
1410
+ * import { IgniterAgentInMemoryAdapter } from '@igniter-js/agents/adapters';
1411
+ *
1412
+ * const adapter = new IgniterAgentInMemoryAdapter({
1413
+ * namespace: 'test',
1414
+ * debug: process.env.NODE_ENV === 'development',
1415
+ * maxMessages: 500,
1416
+ * maxChats: 50
1417
+ * });
1418
+ *
1419
+ * // Store working memory
1420
+ * await adapter.updateWorkingMemory({
1421
+ * scope: 'chat',
1422
+ * identifier: 'chat_123',
1423
+ * content: 'User prefers TypeScript'
1424
+ * });
1425
+ *
1426
+ * // Retrieve working memory
1427
+ * const memory = await adapter.getWorkingMemory({
1428
+ * scope: 'chat',
1429
+ * identifier: 'chat_123'
1430
+ * });
1431
+ *
1432
+ * console.log(memory?.content); // 'User prefers TypeScript'
1433
+ * ```
1434
+ *
1435
+ * @public
1436
+ */
1437
+ declare class IgniterAgentInMemoryAdapter implements IgniterAgentMemoryAdapter<IgniterAgentInMemoryAdapterOptions> {
1438
+ /**
1439
+ * The adapter configuration options.
1440
+ */
1441
+ readonly options: Required<IgniterAgentInMemoryAdapterOptions>;
1442
+ /**
1443
+ * Storage for working memory.
1444
+ * Key format: `{namespace}:{scope}:{identifier}`
1445
+ * @internal
1446
+ */
1447
+ private readonly _workingMemory;
1448
+ /**
1449
+ * Storage for conversation messages.
1450
+ * Key format: `{namespace}:{chatId}`
1451
+ * @internal
1452
+ */
1453
+ private readonly _messages;
1454
+ /**
1455
+ * Storage for chat sessions.
1456
+ * Key format: `{namespace}:{chatId}`
1457
+ * @internal
1458
+ */
1459
+ private readonly _chats;
1460
+ /**
1461
+ * Creates a new IgniterAgentInMemoryAdapter.
1462
+ *
1463
+ * @param options - Adapter configuration
1464
+ *
1465
+ * @example
1466
+ * ```typescript
1467
+ * const adapter = new IgniterAgentInMemoryAdapter({
1468
+ * namespace: 'myapp',
1469
+ * maxMessages: 1000,
1470
+ * maxChats: 100
1471
+ * });
1472
+ * ```
1473
+ */
1474
+ constructor(options?: IgniterAgentInMemoryAdapterOptions);
1475
+ /**
1476
+ * Factory method to create a new adapter instance.
1477
+ * @param options - Adapter configuration
1478
+ * @returns A new IgniterAgentInMemoryAdapter instance
1479
+ *
1480
+ * @example
1481
+ * ```typescript
1482
+ * const adapter = IgniterAgentInMemoryAdapter.create({
1483
+ * namespace: 'test',
1484
+ * });
1485
+ * ```
1486
+ */
1487
+ static create(options?: IgniterAgentInMemoryAdapterOptions): IgniterAgentInMemoryAdapter;
1488
+ /**
1489
+ * Generates a storage key with namespace prefix.
1490
+ * @internal
1491
+ */
1492
+ private _key;
1493
+ /**
1494
+ * Connects to the storage backend (no-op for in-memory).
1495
+ *
1496
+ * @description
1497
+ * In-memory adapter doesn't require connection setup.
1498
+ * This method exists for interface compatibility.
1499
+ */
1500
+ connect(): Promise<void>;
1501
+ /**
1502
+ * Disconnects from the storage backend (no-op for in-memory).
1503
+ *
1504
+ * @description
1505
+ * In-memory adapter doesn't require disconnection.
1506
+ * This method exists for interface compatibility.
1507
+ */
1508
+ disconnect(): Promise<void>;
1509
+ /**
1510
+ * Checks if the adapter is connected.
1511
+ *
1512
+ * @returns Always true for in-memory adapter
1513
+ */
1514
+ isConnected(): boolean;
1515
+ /**
1516
+ * Clears all stored data.
1517
+ *
1518
+ * @description
1519
+ * Removes all working memory, messages, and chat sessions.
1520
+ * Use with caution.
1521
+ *
1522
+ * @example
1523
+ * ```typescript
1524
+ * // Clear all data (useful for testing)
1525
+ * await adapter.clear();
1526
+ * ```
1527
+ */
1528
+ clear(): Promise<void>;
1529
+ /**
1530
+ * Gets working memory for a scope and identifier.
1531
+ *
1532
+ * @param params - The scope and identifier
1533
+ * @returns The working memory or null if not found
1534
+ *
1535
+ * @example
1536
+ * ```typescript
1537
+ * const memory = await adapter.getWorkingMemory({
1538
+ * scope: 'chat',
1539
+ * identifier: 'chat_123'
1540
+ * });
1541
+ *
1542
+ * if (memory) {
1543
+ * console.log('Content:', memory.content);
1544
+ * console.log('Updated:', memory.updatedAt);
1545
+ * }
1546
+ * ```
1547
+ */
1548
+ getWorkingMemory(params: IgniterAgentWorkingMemoryParams): Promise<IgniterAgentWorkingMemory | null>;
1549
+ /**
1550
+ * Updates working memory for a scope and identifier.
1551
+ *
1552
+ * @param params - The scope, identifier, and new content
1553
+ *
1554
+ * @example
1555
+ * ```typescript
1556
+ * await adapter.updateWorkingMemory({
1557
+ * scope: 'chat',
1558
+ * identifier: 'chat_123',
1559
+ * content: `
1560
+ * ## User Preferences
1561
+ * - Prefers TypeScript
1562
+ * - Uses VS Code
1563
+ * `
1564
+ * });
1565
+ * ```
1566
+ */
1567
+ updateWorkingMemory(params: IgniterAgentUpdateWorkingMemoryParams): Promise<void>;
1568
+ /**
1569
+ * Saves a message to the conversation history.
1570
+ *
1571
+ * @param message - The message to save
1572
+ *
1573
+ * @example
1574
+ * ```typescript
1575
+ * await adapter.saveMessage({
1576
+ * chatId: 'chat_123',
1577
+ * userId: 'user_456',
1578
+ * role: 'user',
1579
+ * content: 'How do I use TypeScript?',
1580
+ * timestamp: new Date()
1581
+ * });
1582
+ * ```
1583
+ */
1584
+ saveMessage(message: IgniterAgentConversationMessage): Promise<void>;
1585
+ /**
1586
+ * Gets messages from the conversation history.
1587
+ *
1588
+ * @typeParam T - The message type to return
1589
+ * @param params - Query parameters
1590
+ * @returns Array of messages
1591
+ *
1592
+ * @example
1593
+ * ```typescript
1594
+ * const messages = await adapter.getMessages({
1595
+ * chatId: 'chat_123',
1596
+ * limit: 50
1597
+ * });
1598
+ *
1599
+ * for (const msg of messages) {
1600
+ * console.log(`[${msg.role}]: ${msg.content}`);
1601
+ * }
1602
+ * ```
1603
+ */
1604
+ getMessages<T = unknown>(params: IgniterAgentGetMessagesParams): Promise<T[]>;
1605
+ /**
1606
+ * Saves or updates a chat session.
1607
+ *
1608
+ * @param chat - The chat session to save
1609
+ *
1610
+ * @example
1611
+ * ```typescript
1612
+ * await adapter.saveChat({
1613
+ * chatId: 'chat_123',
1614
+ * userId: 'user_456',
1615
+ * title: 'TypeScript Help',
1616
+ * createdAt: new Date(),
1617
+ * updatedAt: new Date(),
1618
+ * messageCount: 0
1619
+ * });
1620
+ * ```
1621
+ */
1622
+ saveChat(chat: IgniterAgentChatSession): Promise<void>;
1623
+ /**
1624
+ * Gets chat sessions matching the query parameters.
1625
+ *
1626
+ * @param params - Query parameters
1627
+ * @returns Array of chat sessions
1628
+ *
1629
+ * @example
1630
+ * ```typescript
1631
+ * const chats = await adapter.getChats({
1632
+ * userId: 'user_456',
1633
+ * search: 'typescript',
1634
+ * limit: 10
1635
+ * });
1636
+ *
1637
+ * for (const chat of chats) {
1638
+ * console.log(`${chat.title} (${chat.messageCount} messages)`);
1639
+ * }
1640
+ * ```
1641
+ */
1642
+ getChats(params: IgniterAgentGetChatsParams): Promise<IgniterAgentChatSession[]>;
1643
+ /**
1644
+ * Gets a specific chat session by ID.
1645
+ *
1646
+ * @param chatId - The chat ID
1647
+ * @returns The chat session or null if not found
1648
+ *
1649
+ * @example
1650
+ * ```typescript
1651
+ * const chat = await adapter.getChat('chat_123');
1652
+ *
1653
+ * if (chat) {
1654
+ * console.log('Title:', chat.title);
1655
+ * console.log('Messages:', chat.messageCount);
1656
+ * }
1657
+ * ```
1658
+ */
1659
+ getChat(chatId: string): Promise<IgniterAgentChatSession | null>;
1660
+ /**
1661
+ * Updates the title of a chat session.
1662
+ *
1663
+ * @param chatId - The chat ID
1664
+ * @param title - The new title
1665
+ *
1666
+ * @example
1667
+ * ```typescript
1668
+ * await adapter.updateChatTitle('chat_123', 'New Title');
1669
+ * ```
1670
+ */
1671
+ updateChatTitle(chatId: string, title: string): Promise<void>;
1672
+ /**
1673
+ * Deletes a chat session and its messages.
1674
+ *
1675
+ * @param chatId - The chat ID to delete
1676
+ *
1677
+ * @example
1678
+ * ```typescript
1679
+ * await adapter.deleteChat('chat_123');
1680
+ * ```
1681
+ */
1682
+ deleteChat(chatId: string): Promise<void>;
1683
+ /**
1684
+ * Gets storage statistics.
1685
+ *
1686
+ * @returns Current storage stats
1687
+ *
1688
+ * @example
1689
+ * ```typescript
1690
+ * const stats = await adapter.getStats();
1691
+ * console.log(`Storing ${stats.messageCount} messages`);
1692
+ * console.log(`Across ${stats.chatCount} chats`);
1693
+ * ```
1694
+ */
1695
+ getStats(): Promise<IgniterAgentAdapterStats>;
1696
+ }
1697
+
1698
+ /**
1699
+ * @fileoverview JSON file-based adapter for IgniterAgent memory storage.
1700
+ * This module provides a simple file-based implementation of the memory provider.
1701
+ *
1702
+ * @description
1703
+ * The IgniterAgentJSONFileAdapter stores all data in JSON files on the local filesystem,
1704
+ * making it ideal for:
1705
+ * - Development and testing
1706
+ * - Single-machine deployments
1707
+ * - Offline-first applications
1708
+ * - Simple persistence without external databases
1709
+ *
1710
+ * **Directory Structure:**
1711
+ * ```
1712
+ * {dataDir}/
1713
+ * ├── working-memory.json # All working memory entries
1714
+ * ├── chats.json # All chat sessions
1715
+ * └── messages/
1716
+ * ├── {chatId}.json # Messages for specific chat
1717
+ * └── ...
1718
+ * ```
1719
+ *
1720
+ * @example
1721
+ * ```typescript
1722
+ * import { IgniterAgentJSONFileAdapter } from '@igniter-js/agents/adapters';
1723
+ *
1724
+ * // Create adapter
1725
+ * const adapter = new IgniterAgentJSONFileAdapter({
1726
+ * dataDir: './data/agent-memory',
1727
+ * namespace: 'myapp',
1728
+ * autoSync: true
1729
+ * });
1730
+ *
1731
+ * // Use with memory config
1732
+ * const memoryConfig: IgniterAgentMemoryConfig = {
1733
+ * provider: adapter,
1734
+ * working: { enabled: true, scope: 'chat' },
1735
+ * history: { enabled: true, limit: 100 }
1736
+ * };
1737
+ * ```
1738
+ *
1739
+ * @module adapters/json-file
1740
+ * @packageDocumentation
1741
+ */
1742
+
1743
+ /**
1744
+ * Options for IgniterAgentJSONFileAdapter.
1745
+ *
1746
+ * @public
1747
+ */
1748
+ interface IgniterAgentJSONFileAdapterOptions {
1749
+ /**
1750
+ * Directory path where JSON files will be stored.
1751
+ * Will be created if it doesn't exist.
1752
+ *
1753
+ * @default './igniter-agent-memory'
1754
+ */
1755
+ dataDir?: string;
1756
+ /**
1757
+ * Namespace prefix for keys in the JSON files.
1758
+ * Allows storing data for multiple apps/instances in the same directory.
1759
+ *
1760
+ * @default 'igniter'
1761
+ */
1762
+ namespace?: string;
1763
+ /**
1764
+ * Whether to automatically sync changes to disk.
1765
+ * If false, call `sync()` manually after modifications.
1766
+ *
1767
+ * @default true
1768
+ */
1769
+ autoSync?: boolean;
1770
+ /**
1771
+ * Whether to enable debug logging.
1772
+ *
1773
+ * @default false
1774
+ */
1775
+ debug?: boolean;
1776
+ /**
1777
+ * Maximum number of messages to store per chat.
1778
+ * Older messages are removed when limit is exceeded.
1779
+ *
1780
+ * @default 1000
1781
+ */
1782
+ maxMessages?: number;
1783
+ /**
1784
+ * Maximum number of chat sessions to store.
1785
+ * Older chats are removed when limit is exceeded.
1786
+ *
1787
+ * @default 100
1788
+ */
1789
+ maxChats?: number;
1790
+ }
1791
+ /**
1792
+ * File-based (JSON) implementation of the IgniterAgent memory provider.
1793
+ *
1794
+ * @description
1795
+ * Stores all memory data in JSON files on the local filesystem. Provides a complete
1796
+ * implementation of the memory provider interface for development and testing purposes.
1797
+ *
1798
+ * **Features:**
1799
+ * - Full implementation of all memory provider methods
1800
+ * - Persistent storage across process restarts
1801
+ * - Namespace support for multi-tenant applications
1802
+ * - Optional automatic file synchronization
1803
+ * - Message/chat limits to control storage
1804
+ * - Debug logging
1805
+ *
1806
+ * **Limitations:**
1807
+ * - Not suitable for concurrent access from multiple processes
1808
+ * - Performance degrades with large numbers of messages/chats
1809
+ * - Not suitable for high-frequency writes
1810
+ *
1811
+ * **File Format:**
1812
+ * All data is stored in JSON format with ISO 8601 timestamps.
1813
+ *
1814
+ * @example
1815
+ * ```typescript
1816
+ * import { IgniterAgentJSONFileAdapter } from '@igniter-js/agents/adapters';
1817
+ *
1818
+ * const adapter = new IgniterAgentJSONFileAdapter({
1819
+ * dataDir: './memory',
1820
+ * namespace: 'myapp',
1821
+ * debug: true
1822
+ * });
1823
+ *
1824
+ * // Connect to initialize directories
1825
+ * await adapter.connect();
1826
+ *
1827
+ * // Store working memory
1828
+ * await adapter.updateWorkingMemory({
1829
+ * scope: 'chat',
1830
+ * identifier: 'chat_123',
1831
+ * content: 'User prefers TypeScript'
1832
+ * });
1833
+ *
1834
+ * // Retrieve working memory
1835
+ * const memory = await adapter.getWorkingMemory({
1836
+ * scope: 'chat',
1837
+ * identifier: 'chat_123'
1838
+ * });
1839
+ *
1840
+ * console.log(memory?.content); // 'User prefers TypeScript'
1841
+ * ```
1842
+ *
1843
+ * @public
1844
+ */
1845
+ declare class IgniterAgentJSONFileAdapter implements IgniterAgentMemoryAdapter<IgniterAgentJSONFileAdapterOptions> {
1846
+ /**
1847
+ * The adapter configuration options.
1848
+ */
1849
+ readonly options: Required<IgniterAgentJSONFileAdapterOptions>;
1850
+ /**
1851
+ * Whether the adapter is currently connected and ready to use.
1852
+ * @internal
1853
+ */
1854
+ private _connected;
1855
+ /**
1856
+ * In-memory cache of working memory entries.
1857
+ * @internal
1858
+ */
1859
+ private _workingMemoryCache;
1860
+ /**
1861
+ * In-memory cache of messages.
1862
+ * @internal
1863
+ */
1864
+ private _messagesCache;
1865
+ /**
1866
+ * In-memory cache of chat sessions.
1867
+ * @internal
1868
+ */
1869
+ private _chatsCache;
1870
+ /**
1871
+ * Creates a new IgniterAgentJSONFileAdapter.
1872
+ *
1873
+ * @param options - Adapter configuration
1874
+ *
1875
+ * @example
1876
+ * ```typescript
1877
+ * const adapter = new IgniterAgentJSONFileAdapter({
1878
+ * dataDir: './memory',
1879
+ * namespace: 'myapp'
1880
+ * });
1881
+ * ```
1882
+ */
1883
+ constructor(options?: IgniterAgentJSONFileAdapterOptions);
1884
+ /**
1885
+ * Factory method to create a new adapter instance.
1886
+ * @param options - Adapter configuration
1887
+ * @returns A new IgniterAgentJSONFileAdapter instance
1888
+ *
1889
+ * @example
1890
+ * ```typescript
1891
+ * const adapter = IgniterAgentJSONFileAdapter.create({
1892
+ * dataDir: './data',
1893
+ * });
1894
+ * ```
1895
+ */
1896
+ static create(options?: IgniterAgentJSONFileAdapterOptions): IgniterAgentJSONFileAdapter;
1897
+ /**
1898
+ * Logs debug messages if debug mode is enabled.
1899
+ * @internal
1900
+ */
1901
+ private _log;
1902
+ /**
1903
+ * Gets the path for the working memory JSON file.
1904
+ * @internal
1905
+ */
1906
+ private _getWorkingMemoryPath;
1907
+ /**
1908
+ * Gets the path for the chats JSON file.
1909
+ * @internal
1910
+ */
1911
+ private _getChatsPath;
1912
+ /**
1913
+ * Gets the directory for message files.
1914
+ * @internal
1915
+ */
1916
+ private _getMessagesDir;
1917
+ /**
1918
+ * Gets the path for a specific chat's messages JSON file.
1919
+ * @internal
1920
+ */
1921
+ private _getMessagesPath;
1922
+ /**
1923
+ * Generates a cache key with namespace prefix.
1924
+ * @internal
1925
+ */
1926
+ private _key;
1927
+ /**
1928
+ * Loads working memory from disk.
1929
+ * @internal
1930
+ */
1931
+ private _loadWorkingMemory;
1932
+ /**
1933
+ * Loads chats from disk.
1934
+ * @internal
1935
+ */
1936
+ private _loadChats;
1937
+ /**
1938
+ * Loads a specific chat's messages from disk.
1939
+ * @internal
1940
+ */
1941
+ private _loadMessages;
1942
+ /**
1943
+ * Saves working memory to disk.
1944
+ * @internal
1945
+ */
1946
+ private _saveWorkingMemory;
1947
+ /**
1948
+ * Saves chats to disk.
1949
+ * @internal
1950
+ */
1951
+ private _saveChats;
1952
+ /**
1953
+ * Saves messages for a specific chat to disk.
1954
+ * @internal
1955
+ */
1956
+ private _saveMessages;
1957
+ /**
1958
+ * Connects to the storage backend and loads data from disk.
1959
+ *
1960
+ * @description
1961
+ * Creates necessary directories and loads all data into memory cache.
1962
+ * Must be called before using the adapter.
1963
+ *
1964
+ * @throws {Error} If directory creation fails
1965
+ *
1966
+ * @example
1967
+ * ```typescript
1968
+ * const adapter = new IgniterAgentJSONFileAdapter();
1969
+ * await adapter.connect();
1970
+ * ```
1971
+ */
1972
+ connect(): Promise<void>;
1973
+ /**
1974
+ * Disconnects from the storage backend.
1975
+ *
1976
+ * @description
1977
+ * Syncs any pending changes to disk before disconnecting.
1978
+ *
1979
+ * @example
1980
+ * ```typescript
1981
+ * await adapter.disconnect();
1982
+ * ```
1983
+ */
1984
+ disconnect(): Promise<void>;
1985
+ /**
1986
+ * Checks if the adapter is connected and ready to use.
1987
+ *
1988
+ * @returns True if connected, false otherwise
1989
+ */
1990
+ isConnected(): boolean;
1991
+ /**
1992
+ * Manually syncs all in-memory data to disk.
1993
+ *
1994
+ * @description
1995
+ * Called automatically if autoSync is enabled. Can be called manually
1996
+ * to ensure data is persisted to disk.
1997
+ *
1998
+ * @example
1999
+ * ```typescript
2000
+ * await adapter.updateWorkingMemory({ ... });
2001
+ * await adapter.sync(); // Ensure written to disk
2002
+ * ```
2003
+ */
2004
+ sync(): Promise<void>;
2005
+ /**
2006
+ * Clears all stored data from disk and memory.
2007
+ *
2008
+ * @description
2009
+ * Removes all working memory, messages, and chat sessions.
2010
+ * Use with caution.
2011
+ *
2012
+ * @example
2013
+ * ```typescript
2014
+ * await adapter.clear();
2015
+ * ```
2016
+ */
2017
+ clear(): Promise<void>;
2018
+ /**
2019
+ * Gets working memory for a scope and identifier.
2020
+ *
2021
+ * @param params - The scope and identifier
2022
+ * @returns The working memory or null if not found
2023
+ *
2024
+ * @example
2025
+ * ```typescript
2026
+ * const memory = await adapter.getWorkingMemory({
2027
+ * scope: 'chat',
2028
+ * identifier: 'chat_123'
2029
+ * });
2030
+ *
2031
+ * if (memory) {
2032
+ * console.log('Content:', memory.content);
2033
+ * }
2034
+ * ```
2035
+ */
2036
+ getWorkingMemory(params: IgniterAgentWorkingMemoryParams): Promise<IgniterAgentWorkingMemory | null>;
2037
+ /**
2038
+ * Updates working memory for a scope and identifier.
2039
+ *
2040
+ * @param params - The scope, identifier, and new content
2041
+ *
2042
+ * @example
2043
+ * ```typescript
2044
+ * await adapter.updateWorkingMemory({
2045
+ * scope: 'chat',
2046
+ * identifier: 'chat_123',
2047
+ * content: 'User prefers TypeScript'
2048
+ * });
2049
+ * ```
2050
+ */
2051
+ updateWorkingMemory(params: IgniterAgentUpdateWorkingMemoryParams): Promise<void>;
2052
+ /**
2053
+ * Saves a message to the conversation history.
2054
+ *
2055
+ * @param message - The message to save
2056
+ *
2057
+ * @example
2058
+ * ```typescript
2059
+ * await adapter.saveMessage({
2060
+ * chatId: 'chat_123',
2061
+ * userId: 'user_456',
2062
+ * role: 'user',
2063
+ * content: 'How do I use TypeScript?',
2064
+ * timestamp: new Date()
2065
+ * });
2066
+ * ```
2067
+ */
2068
+ saveMessage(message: IgniterAgentConversationMessage): Promise<void>;
2069
+ /**
2070
+ * Gets messages from the conversation history.
2071
+ *
2072
+ * @typeParam T - The message type to return
2073
+ * @param params - Query parameters
2074
+ * @returns Array of messages
2075
+ *
2076
+ * @example
2077
+ * ```typescript
2078
+ * const messages = await adapter.getMessages({
2079
+ * chatId: 'chat_123',
2080
+ * limit: 50
2081
+ * });
2082
+ *
2083
+ * for (const msg of messages) {
2084
+ * console.log(`[${msg.role}]: ${msg.content}`);
2085
+ * }
2086
+ * ```
2087
+ */
2088
+ getMessages<T = unknown>(params: IgniterAgentGetMessagesParams): Promise<T[]>;
2089
+ /**
2090
+ * Saves or updates a chat session.
2091
+ *
2092
+ * @param chat - The chat session to save
2093
+ *
2094
+ * @example
2095
+ * ```typescript
2096
+ * await adapter.saveChat({
2097
+ * chatId: 'chat_123',
2098
+ * userId: 'user_456',
2099
+ * title: 'TypeScript Help',
2100
+ * createdAt: new Date(),
2101
+ * updatedAt: new Date(),
2102
+ * messageCount: 0
2103
+ * });
2104
+ * ```
2105
+ */
2106
+ saveChat(chat: IgniterAgentChatSession): Promise<void>;
2107
+ /**
2108
+ * Gets chat sessions matching the query parameters.
2109
+ *
2110
+ * @param params - Query parameters
2111
+ * @returns Array of chat sessions
2112
+ *
2113
+ * @example
2114
+ * ```typescript
2115
+ * const chats = await adapter.getChats({
2116
+ * userId: 'user_456',
2117
+ * search: 'typescript',
2118
+ * limit: 10
2119
+ * });
2120
+ *
2121
+ * for (const chat of chats) {
2122
+ * console.log(`${chat.title} (${chat.messageCount} messages)`);
2123
+ * }
2124
+ * ```
2125
+ */
2126
+ getChats(params: IgniterAgentGetChatsParams): Promise<IgniterAgentChatSession[]>;
2127
+ /**
2128
+ * Gets a specific chat session by ID.
2129
+ *
2130
+ * @param chatId - The chat ID
2131
+ * @returns The chat session or null if not found
2132
+ *
2133
+ * @example
2134
+ * ```typescript
2135
+ * const chat = await adapter.getChat('chat_123');
2136
+ *
2137
+ * if (chat) {
2138
+ * console.log('Title:', chat.title);
2139
+ * }
2140
+ * ```
2141
+ */
2142
+ getChat(chatId: string): Promise<IgniterAgentChatSession | null>;
2143
+ /**
2144
+ * Updates the title of a chat session.
2145
+ *
2146
+ * @param chatId - The chat ID
2147
+ * @param title - The new title
2148
+ *
2149
+ * @example
2150
+ * ```typescript
2151
+ * await adapter.updateChatTitle('chat_123', 'New Title');
2152
+ * ```
2153
+ */
2154
+ updateChatTitle(chatId: string, title: string): Promise<void>;
2155
+ /**
2156
+ * Deletes a chat session and its messages.
2157
+ *
2158
+ * @param chatId - The chat ID to delete
2159
+ *
2160
+ * @example
2161
+ * ```typescript
2162
+ * await adapter.deleteChat('chat_123');
2163
+ * ```
2164
+ */
2165
+ deleteChat(chatId: string): Promise<void>;
2166
+ /**
2167
+ * Gets storage statistics.
2168
+ *
2169
+ * @returns Current storage stats
2170
+ *
2171
+ * @example
2172
+ * ```typescript
2173
+ * const stats = await adapter.getStats();
2174
+ * console.log(`Storing ${stats.messageCount} messages`);
2175
+ * console.log(`Across ${stats.chatCount} chats`);
2176
+ * ```
2177
+ */
2178
+ getStats(): Promise<IgniterAgentAdapterStats>;
2179
+ }
2180
+
2181
+ export { type IgniterAgentAdapterStats as A, type IgniterAgentMemoryConfig as I, type IgniterAgentMemoryRuntime as a, type IgniterAgentWorkingMemoryParams as b, type IgniterAgentWorkingMemory as c, type IgniterAgentUpdateWorkingMemoryParams as d, type IgniterAgentConversationMessage as e, type IgniterAgentUIMessage as f, type IgniterAgentGetMessagesParams as g, type IgniterAgentChatSession as h, type IgniterAgentGetChatsParams as i, IgniterAgentInMemoryAdapter as j, type IgniterAgentJSONFileAdapterOptions as k, IgniterAgentJSONFileAdapter as l, type IgniterAgentMessageRole as m, type IgniterAgentMemoryScope as n, type IgniterAgentGenerateTitleConfig as o, type IgniterAgentGenerateSuggestionsConfig as p, type IgniterAgentWorkingMemoryConfig as q, type IgniterAgentHistoryConfig as r, type IgniterAgentChatsConfig as s, type IgniterAgentMemoryProvider as t, type IgniterAgentAdapterOptions as u, type IgniterAgentInMemoryAdapterOptions as v, type IgniterAgentRedisAdapterOptions as w, type IgniterAgentMemoryAdapter as x, type IgniterAgentAdapterFactory as y, type IgniterAgentAdapterBatchResult as z };