chat-agent-toolkit 1.2.1 → 1.2.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.
- package/README.md +6 -6
- package/dist/config/config-manager.d.ts +23 -0
- package/dist/config/config-types.d.ts +58 -0
- package/dist/config/environment-variables.d.ts +6 -0
- package/dist/config/index.d.ts +18 -0
- package/dist/config/language-models-database.d.ts +93 -0
- package/dist/config/mcp-server-registry.d.ts +7 -0
- package/dist/config/model-registry.d.ts +69 -0
- package/dist/config/model-tester.d.ts +51 -0
- package/dist/config/model-utils.d.ts +44 -0
- package/dist/config/provider-ui-config.d.ts +6 -0
- package/dist/index.d.ts +23 -0
- package/dist/memory/agent-memory-manager.d.ts +125 -0
- package/dist/memory/example.d.ts +36 -0
- package/dist/memory/index.d.ts +18 -0
- package/dist/memory/mastra-integration.d.ts +146 -0
- package/dist/memory/storage/drizzle-storage.d.ts +82 -0
- package/dist/memory/storage/in-memory-storage.d.ts +75 -0
- package/dist/memory/storage/storage-interface.d.ts +37 -0
- package/dist/memory/types.d.ts +122 -0
- package/dist/models/providers.d.ts +5 -0
- package/dist/models/registry.d.ts +4 -0
- package/dist/models/types.d.ts +4 -0
- package/dist/research-agent.cjs.js +2 -0
- package/dist/research-agent.cjs.js.map +1 -0
- package/dist/research-agent.es.js +2 -0
- package/dist/research-agent.es.js.map +1 -0
- package/dist/search.d.ts +5 -0
- package/dist/tools/index.d.ts +12 -0
- package/dist/tools/open-connector-mastra.d.ts +137 -0
- package/dist/tools/open-connector-mcp.d.ts +88 -0
- package/dist/tools/qwksearch-api-tools.d.ts +149 -0
- package/dist/tools/search/doc-utils.d.ts +11 -0
- package/dist/tools/search/document.d.ts +14 -0
- package/dist/tools/search/index.d.ts +12 -0
- package/dist/tools/search/link-summarizer.d.ts +7 -0
- package/dist/tools/search/meta-search-types.d.ts +50 -0
- package/dist/tools/search/metaSearchAgent.d.ts +21 -0
- package/dist/tools/search/search-handlers.d.ts +27 -0
- package/dist/tools/search/suggestionGeneratorAgent.d.ts +8 -0
- package/dist/types.d.ts +2 -0
- package/dist/utils/chat-helpers.d.ts +10 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/markdown-to-html.d.ts +5 -0
- package/dist/utils/outputParser.d.ts +22 -0
- package/dist/utils/provider-image-cropper.d.ts +120 -0
- package/package.json +16 -6
- package/src/config/config-manager.ts +0 -8
- package/src/config/environment-variables.ts +11 -3
- package/src/config/language-models-database.ts +50 -42
- package/src/config/model-registry.ts +20 -5
- package/src/config/model-tester.ts +2 -2
- package/src/connectors/{composio.json → open-connector.json} +21 -45
- package/src/index.ts +3 -0
- package/src/memory/ARCHITECTURE.md +1 -1
- package/src/memory/example.ts +6 -6
- package/src/memory/mastra-integration.ts +6 -11
- package/src/memory/storage/drizzle-storage.ts +60 -29
- package/src/memory/storage/in-memory-storage.ts +2 -2
- package/src/memory/storage/storage-interface.ts +1 -1
- package/src/models/types.ts +1 -1
- package/src/tools/{composio-mastra.ts → open-connector-mastra.ts} +58 -93
- package/src/tools/open-connector-mcp.ts +170 -0
- package/src/tools/search/doc-utils.ts +36 -8
- package/src/tools/search/metaSearchAgent.ts +11 -0
- package/src/tools/search/search-handlers.ts +13 -1
- package/src/tools/search/suggestionGeneratorAgent.ts +5 -3
- package/src/tools/composio-mcp.ts +0 -205
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { Mastra } from '@mastra/core';
|
|
2
|
+
import { Agent } from '@mastra/core/agent';
|
|
3
|
+
import { D1Database, KVNamespace } from '@cloudflare/workers-types';
|
|
4
|
+
import { IMemoryStorage } from './storage/storage-interface';
|
|
5
|
+
import { MemoryRecord, MemoryType, MemorySearchOptions, MemoryUpdate } from './types';
|
|
6
|
+
/**
|
|
7
|
+
* Cloudflare Workers environment bindings
|
|
8
|
+
*/
|
|
9
|
+
export interface CloudflareEnv {
|
|
10
|
+
DB?: D1Database;
|
|
11
|
+
KV?: KVNamespace;
|
|
12
|
+
OPENAI_API_KEY?: string;
|
|
13
|
+
ANTHROPIC_API_KEY?: string;
|
|
14
|
+
GROQ_API_KEY?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Storage backend types for Mastra memory
|
|
18
|
+
*/
|
|
19
|
+
export type MastraStorageBackend = 'memory' | 'd1' | 'kv';
|
|
20
|
+
/**
|
|
21
|
+
* Configuration for Mastra memory integration
|
|
22
|
+
*/
|
|
23
|
+
export interface MastraMemoryConfig {
|
|
24
|
+
/** Storage backend (memory, d1, or kv) */
|
|
25
|
+
storage: MastraStorageBackend;
|
|
26
|
+
/** Cloudflare environment bindings */
|
|
27
|
+
env?: CloudflareEnv;
|
|
28
|
+
/** D1 table name (for d1 storage) */
|
|
29
|
+
tableName?: string;
|
|
30
|
+
/** KV key prefix (for kv storage) */
|
|
31
|
+
kvPrefix?: string;
|
|
32
|
+
/** Enable debug logging */
|
|
33
|
+
debug?: boolean;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* D1-based storage adapter for Mastra Memory
|
|
37
|
+
* Implements IMemoryStorage using Cloudflare D1
|
|
38
|
+
*/
|
|
39
|
+
export declare class MastraD1MemoryStorage implements IMemoryStorage {
|
|
40
|
+
private db;
|
|
41
|
+
private tableName;
|
|
42
|
+
constructor(db: D1Database, tableName?: string);
|
|
43
|
+
/**
|
|
44
|
+
* Initialize D1 schema for Mastra memory
|
|
45
|
+
*/
|
|
46
|
+
initSchema(): Promise<void>;
|
|
47
|
+
insertMemory(userId: string, memoryType: MemoryType, content: string, importance: number, metadata?: Record<string, any>): Promise<string>;
|
|
48
|
+
findMemories(userId: string, query?: string, limit?: number, options?: MemorySearchOptions): Promise<MemoryRecord[]>;
|
|
49
|
+
findSimilarMemories(userId: string, content: string, limit?: number): Promise<MemoryRecord[]>;
|
|
50
|
+
updateMemory(id: string, updates: MemoryUpdate): Promise<void>;
|
|
51
|
+
deleteMemory(id: string): Promise<void>;
|
|
52
|
+
getMemoryById(id: string): Promise<MemoryRecord | null>;
|
|
53
|
+
batchUpdateMemories(updates: Array<{
|
|
54
|
+
id: string;
|
|
55
|
+
updates: MemoryUpdate;
|
|
56
|
+
}>): Promise<void>;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* KV-based storage adapter for Mastra Memory
|
|
60
|
+
* Uses Cloudflare KV for simple key-value storage
|
|
61
|
+
*/
|
|
62
|
+
export declare class MastraKVMemoryStorage implements IMemoryStorage {
|
|
63
|
+
private kv;
|
|
64
|
+
private prefix;
|
|
65
|
+
constructor(kv: KVNamespace, prefix?: string);
|
|
66
|
+
private getUserKey;
|
|
67
|
+
private getMemoryKey;
|
|
68
|
+
insertMemory(userId: string, memoryType: MemoryType, content: string, importance: number, metadata?: Record<string, any>): Promise<string>;
|
|
69
|
+
findMemories(userId: string, query?: string, limit?: number, options?: MemorySearchOptions): Promise<MemoryRecord[]>;
|
|
70
|
+
findSimilarMemories(userId: string, content: string, limit?: number): Promise<MemoryRecord[]>;
|
|
71
|
+
updateMemory(id: string, updates: MemoryUpdate): Promise<void>;
|
|
72
|
+
deleteMemory(id: string): Promise<void>;
|
|
73
|
+
getMemoryById(id: string): Promise<MemoryRecord | null>;
|
|
74
|
+
batchUpdateMemories(updates: Array<{
|
|
75
|
+
id: string;
|
|
76
|
+
updates: MemoryUpdate;
|
|
77
|
+
}>): Promise<void>;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Mastra Memory Manager for Cloudflare Workers
|
|
81
|
+
* Wraps Mastra's memory system with Cloudflare-compatible storage
|
|
82
|
+
*/
|
|
83
|
+
export declare class MastraMemoryManager {
|
|
84
|
+
private mastra;
|
|
85
|
+
private storage;
|
|
86
|
+
private config;
|
|
87
|
+
constructor(config: MastraMemoryConfig);
|
|
88
|
+
/**
|
|
89
|
+
* Initialize Mastra instance with memory
|
|
90
|
+
*/
|
|
91
|
+
initialize(): Promise<Mastra>;
|
|
92
|
+
/**
|
|
93
|
+
* Get storage instance (for direct access)
|
|
94
|
+
*/
|
|
95
|
+
getStorage(): IMemoryStorage;
|
|
96
|
+
/**
|
|
97
|
+
* Create an agent with memory
|
|
98
|
+
*/
|
|
99
|
+
createAgent(config: {
|
|
100
|
+
id: string;
|
|
101
|
+
name: string;
|
|
102
|
+
instructions: string;
|
|
103
|
+
model: any;
|
|
104
|
+
tools?: Record<string, any>;
|
|
105
|
+
userId: string;
|
|
106
|
+
threadId?: string;
|
|
107
|
+
resourceId?: string;
|
|
108
|
+
}): Promise<Agent>;
|
|
109
|
+
/**
|
|
110
|
+
* Store a message in memory
|
|
111
|
+
*/
|
|
112
|
+
storeMessage(userId: string, threadId: string, role: 'user' | 'assistant', content: string, metadata?: Record<string, any>): Promise<string>;
|
|
113
|
+
/**
|
|
114
|
+
* Recall conversation history
|
|
115
|
+
*/
|
|
116
|
+
recallConversation(userId: string, threadId: string, limit?: number): Promise<Array<{
|
|
117
|
+
role: 'user' | 'assistant';
|
|
118
|
+
content: string;
|
|
119
|
+
timestamp: Date;
|
|
120
|
+
}>>;
|
|
121
|
+
/**
|
|
122
|
+
* Get relevant context for a query
|
|
123
|
+
*/
|
|
124
|
+
getRelevantContext(userId: string, query: string, limit?: number): Promise<string>;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Quick helper to create Mastra memory manager for Cloudflare Workers
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* ```ts
|
|
131
|
+
* const memoryManager = createMastraMemory({
|
|
132
|
+
* storage: 'd1',
|
|
133
|
+
* env: env, // Cloudflare env bindings
|
|
134
|
+
* });
|
|
135
|
+
*
|
|
136
|
+
* const agent = await memoryManager.createAgent({
|
|
137
|
+
* id: 'assistant',
|
|
138
|
+
* name: 'AI Assistant',
|
|
139
|
+
* instructions: 'Help users with their questions',
|
|
140
|
+
* model: openai('gpt-4o'),
|
|
141
|
+
* userId: 'user-123',
|
|
142
|
+
* threadId: 'conversation-1',
|
|
143
|
+
* });
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
export declare function createMastraMemory(config: MastraMemoryConfig): MastraMemoryManager;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { IMemoryStorage } from './storage-interface';
|
|
2
|
+
import { MemoryRecord, MemoryType, MemorySearchOptions, MemoryUpdate } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* The Drizzle table passed to {@link DrizzleMemoryStorage} must expose these
|
|
5
|
+
* columns (see {@link createMemorySchema} for the expected shape).
|
|
6
|
+
*/
|
|
7
|
+
export interface MemoryTable {
|
|
8
|
+
id: any;
|
|
9
|
+
user_id: any;
|
|
10
|
+
memory_type: any;
|
|
11
|
+
content: any;
|
|
12
|
+
importance: any;
|
|
13
|
+
access_count: any;
|
|
14
|
+
metadata: any;
|
|
15
|
+
created_at: any;
|
|
16
|
+
updated_at: any;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Drizzle-based storage adapter.
|
|
20
|
+
*
|
|
21
|
+
* Pass the Drizzle database instance and the memory table object defined in
|
|
22
|
+
* your schema (not a table-name string) so queries reference real columns:
|
|
23
|
+
*
|
|
24
|
+
* ```ts
|
|
25
|
+
* import { sqliteTable, text, integer, real } from "drizzle-orm/sqlite-core";
|
|
26
|
+
* const userMemories = sqliteTable("user_memories", { ... });
|
|
27
|
+
* const storage = new DrizzleMemoryStorage(db, userMemories);
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare class DrizzleMemoryStorage implements IMemoryStorage {
|
|
31
|
+
private db;
|
|
32
|
+
private table;
|
|
33
|
+
constructor(db: any, table: MemoryTable & Record<string, any>);
|
|
34
|
+
/**
|
|
35
|
+
* Insert a new memory record
|
|
36
|
+
*/
|
|
37
|
+
insertMemory(userId: string, memoryType: MemoryType, content: string, importance: number, metadata?: Record<string, any>): Promise<string>;
|
|
38
|
+
/**
|
|
39
|
+
* Find memories by user ID and optional filters
|
|
40
|
+
*/
|
|
41
|
+
findMemories(userId: string, query?: string, limit?: number, options?: MemorySearchOptions): Promise<MemoryRecord[]>;
|
|
42
|
+
/**
|
|
43
|
+
* Find similar memories based on content
|
|
44
|
+
*/
|
|
45
|
+
findSimilarMemories(userId: string, content: string, limit?: number): Promise<MemoryRecord[]>;
|
|
46
|
+
/**
|
|
47
|
+
* Update a memory record
|
|
48
|
+
*/
|
|
49
|
+
updateMemory(id: string, updates: MemoryUpdate): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Delete a memory record
|
|
52
|
+
*/
|
|
53
|
+
deleteMemory(id: string): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Get memory by ID
|
|
56
|
+
*/
|
|
57
|
+
getMemoryById(id: string): Promise<MemoryRecord | null>;
|
|
58
|
+
/**
|
|
59
|
+
* Batch update memories
|
|
60
|
+
*/
|
|
61
|
+
batchUpdateMemories(updates: Array<{
|
|
62
|
+
id: string;
|
|
63
|
+
updates: MemoryUpdate;
|
|
64
|
+
}>): Promise<void>;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Database schema for memory system
|
|
68
|
+
* This is kept here for reference but should be managed by your migration system
|
|
69
|
+
*/
|
|
70
|
+
export declare function createMemorySchema(db: any): {
|
|
71
|
+
user_memories: {
|
|
72
|
+
id: string;
|
|
73
|
+
user_id: string;
|
|
74
|
+
memory_type: string;
|
|
75
|
+
content: string;
|
|
76
|
+
importance: string;
|
|
77
|
+
access_count: string;
|
|
78
|
+
metadata: string;
|
|
79
|
+
created_at: string;
|
|
80
|
+
updated_at: string;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { IMemoryStorage } from './storage-interface';
|
|
2
|
+
import { MemoryRecord, MemorySearchOptions, MemoryMetrics, MemoryOptions, MemoryContextOptions, MemoryType } from '../types';
|
|
3
|
+
export declare class SimpleMemory {
|
|
4
|
+
private userId;
|
|
5
|
+
private storage;
|
|
6
|
+
private maxMemories;
|
|
7
|
+
private summaryThreshold;
|
|
8
|
+
private cacheExpiry;
|
|
9
|
+
private batchSize;
|
|
10
|
+
private relevanceThreshold;
|
|
11
|
+
private enableVectorSearch;
|
|
12
|
+
private enableAutoSummarization;
|
|
13
|
+
private recentMessages;
|
|
14
|
+
private memoryCache;
|
|
15
|
+
private isProcessing;
|
|
16
|
+
private processingQueue;
|
|
17
|
+
private summarizeTimeout?;
|
|
18
|
+
private metrics;
|
|
19
|
+
/**
|
|
20
|
+
* Initialize memory system for a user
|
|
21
|
+
*/
|
|
22
|
+
constructor(userId: string, storage: IMemoryStorage, options?: MemoryOptions);
|
|
23
|
+
/**
|
|
24
|
+
* Add a message to current session with intelligent deduplication
|
|
25
|
+
*/
|
|
26
|
+
addMessage(role: "user" | "assistant", content: string, metadata?: Record<string, any>): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Debounced summarization to prevent excessive processing
|
|
29
|
+
*/
|
|
30
|
+
private debouncedSummarize;
|
|
31
|
+
/**
|
|
32
|
+
* Store important facts with validation and conflict resolution
|
|
33
|
+
*/
|
|
34
|
+
storeFact(content: string, importance?: number, category?: MemoryType, metadata?: Record<string, any>): Promise<string>;
|
|
35
|
+
/**
|
|
36
|
+
* Find similar facts using content similarity
|
|
37
|
+
*/
|
|
38
|
+
private findSimilarFacts;
|
|
39
|
+
/**
|
|
40
|
+
* Enhanced memory recall with caching and vector search
|
|
41
|
+
*/
|
|
42
|
+
recallRelevantMemories(query?: string, limit?: number, options?: MemorySearchOptions): Promise<MemoryRecord[]>;
|
|
43
|
+
/**
|
|
44
|
+
* Apply vector search to memories
|
|
45
|
+
*/
|
|
46
|
+
private applyVectorSearch;
|
|
47
|
+
/**
|
|
48
|
+
* Update relevance scores for memories
|
|
49
|
+
*/
|
|
50
|
+
private updateRelevanceScores;
|
|
51
|
+
/**
|
|
52
|
+
* Improved summarization with error handling and batch processing
|
|
53
|
+
*/
|
|
54
|
+
summarizeAndStore(): Promise<boolean>;
|
|
55
|
+
/**
|
|
56
|
+
* Extract facts from conversation using LLM
|
|
57
|
+
*/
|
|
58
|
+
private extractFactsFromConversation;
|
|
59
|
+
/**
|
|
60
|
+
* Process facts in batches to avoid overwhelming the database
|
|
61
|
+
*/
|
|
62
|
+
private processFactsInBatches;
|
|
63
|
+
/**
|
|
64
|
+
* Clear cache utility
|
|
65
|
+
*/
|
|
66
|
+
clearCache(): void;
|
|
67
|
+
/**
|
|
68
|
+
* Get memory context with better formatting and relevance
|
|
69
|
+
*/
|
|
70
|
+
getMemoryContext(query?: string, includeRecent?: boolean, options?: MemoryContextOptions): Promise<string>;
|
|
71
|
+
/**
|
|
72
|
+
* Get performance metrics
|
|
73
|
+
*/
|
|
74
|
+
getMetrics(): MemoryMetrics;
|
|
75
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { MemoryRecord, MemoryType, MemorySearchOptions, MemoryUpdate } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Storage interface that any database adapter must implement
|
|
4
|
+
*/
|
|
5
|
+
export interface IMemoryStorage {
|
|
6
|
+
/**
|
|
7
|
+
* Insert a new memory record
|
|
8
|
+
*/
|
|
9
|
+
insertMemory(userId: string, memoryType: MemoryType, content: string, importance: number, metadata?: Record<string, any>): Promise<string>;
|
|
10
|
+
/**
|
|
11
|
+
* Find memories by user ID and optional filters
|
|
12
|
+
*/
|
|
13
|
+
findMemories(userId: string, query?: string, limit?: number, options?: MemorySearchOptions): Promise<MemoryRecord[]>;
|
|
14
|
+
/**
|
|
15
|
+
* Find similar memories based on content
|
|
16
|
+
*/
|
|
17
|
+
findSimilarMemories(userId: string, content: string, limit?: number): Promise<MemoryRecord[]>;
|
|
18
|
+
/**
|
|
19
|
+
* Update a memory record
|
|
20
|
+
*/
|
|
21
|
+
updateMemory(id: string, updates: MemoryUpdate): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Delete a memory record
|
|
24
|
+
*/
|
|
25
|
+
deleteMemory(id: string): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Get memory by ID
|
|
28
|
+
*/
|
|
29
|
+
getMemoryById(id: string): Promise<MemoryRecord | null>;
|
|
30
|
+
/**
|
|
31
|
+
* Batch update memories
|
|
32
|
+
*/
|
|
33
|
+
batchUpdateMemories(updates: Array<{
|
|
34
|
+
id: string;
|
|
35
|
+
updates: MemoryUpdate;
|
|
36
|
+
}>): Promise<void>;
|
|
37
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memory System Types and Constants
|
|
3
|
+
*
|
|
4
|
+
* Defines interfaces and configuration for the memory management system
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Memory types for categorization
|
|
8
|
+
*/
|
|
9
|
+
export declare const MEMORY_TYPES: {
|
|
10
|
+
readonly FACT: "fact";
|
|
11
|
+
readonly CONVERSATION: "conversation";
|
|
12
|
+
readonly PREFERENCE: "preference";
|
|
13
|
+
readonly PERSONAL: "personal";
|
|
14
|
+
readonly WORK: "work";
|
|
15
|
+
readonly MANUAL: "manual";
|
|
16
|
+
};
|
|
17
|
+
export type MemoryType = (typeof MEMORY_TYPES)[keyof typeof MEMORY_TYPES];
|
|
18
|
+
/**
|
|
19
|
+
* Configuration constants for memory management
|
|
20
|
+
*/
|
|
21
|
+
export declare const MEMORY_CONFIG: {
|
|
22
|
+
readonly DEFAULT_MAX_MEMORIES: 100;
|
|
23
|
+
readonly DEFAULT_SUMMARY_THRESHOLD: 10;
|
|
24
|
+
readonly DEFAULT_CACHE_EXPIRY: number;
|
|
25
|
+
readonly DEFAULT_BATCH_SIZE: 5;
|
|
26
|
+
readonly DEFAULT_RELEVANCE_THRESHOLD: 0.3;
|
|
27
|
+
readonly DEFAULT_IMPORTANCE_RANGE: {
|
|
28
|
+
readonly min: 0;
|
|
29
|
+
readonly max: 10;
|
|
30
|
+
};
|
|
31
|
+
readonly DEFAULT_RATE_LIMIT: {
|
|
32
|
+
readonly requests: 10;
|
|
33
|
+
readonly windowMs: 60000;
|
|
34
|
+
};
|
|
35
|
+
readonly DEFAULT_TIMEOUT: 30000;
|
|
36
|
+
readonly VECTOR_SEARCH_ENABLED: true;
|
|
37
|
+
readonly AUTO_SUMMARIZATION_ENABLED: true;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Memory record structure
|
|
41
|
+
*/
|
|
42
|
+
export interface MemoryRecord {
|
|
43
|
+
id: string;
|
|
44
|
+
user_id: string;
|
|
45
|
+
memory_type: MemoryType;
|
|
46
|
+
content: string;
|
|
47
|
+
importance: number;
|
|
48
|
+
access_count: number;
|
|
49
|
+
metadata?: Record<string, any>;
|
|
50
|
+
created_at: Date;
|
|
51
|
+
updated_at: Date;
|
|
52
|
+
relevance_score?: number;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Message structure for conversation tracking
|
|
56
|
+
*/
|
|
57
|
+
export interface Message {
|
|
58
|
+
role: "user" | "assistant";
|
|
59
|
+
content: string;
|
|
60
|
+
timestamp: number;
|
|
61
|
+
metadata?: Record<string, any>;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Memory search options
|
|
65
|
+
*/
|
|
66
|
+
export interface MemorySearchOptions {
|
|
67
|
+
minImportance?: number;
|
|
68
|
+
memoryType?: MemoryType;
|
|
69
|
+
includeMetadata?: boolean;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Memory update payload
|
|
73
|
+
*/
|
|
74
|
+
export interface MemoryUpdate {
|
|
75
|
+
importance?: number;
|
|
76
|
+
access_count?: number | {
|
|
77
|
+
increment: number;
|
|
78
|
+
};
|
|
79
|
+
updated_at?: Date;
|
|
80
|
+
metadata?: Record<string, any>;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Memory context options
|
|
84
|
+
*/
|
|
85
|
+
export interface MemoryContextOptions {
|
|
86
|
+
maxMemories?: number;
|
|
87
|
+
minImportance?: number;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Performance metrics
|
|
91
|
+
*/
|
|
92
|
+
export interface MemoryMetrics {
|
|
93
|
+
cacheHits: number;
|
|
94
|
+
cacheMisses: number;
|
|
95
|
+
vectorSearches: number;
|
|
96
|
+
summarizations: number;
|
|
97
|
+
errors: number;
|
|
98
|
+
cacheSize: number;
|
|
99
|
+
recentMessagesCount: number;
|
|
100
|
+
isProcessing: boolean;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Memory initialization options
|
|
104
|
+
*/
|
|
105
|
+
export interface MemoryOptions {
|
|
106
|
+
maxMemories?: number;
|
|
107
|
+
summaryThreshold?: number;
|
|
108
|
+
cacheExpiry?: number;
|
|
109
|
+
batchSize?: number;
|
|
110
|
+
relevanceThreshold?: number;
|
|
111
|
+
enableVectorSearch?: boolean;
|
|
112
|
+
enableAutoSummarization?: boolean;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Extracted fact structure
|
|
116
|
+
*/
|
|
117
|
+
export interface ExtractedFact {
|
|
118
|
+
content: string;
|
|
119
|
+
importance?: number;
|
|
120
|
+
category?: MemoryType;
|
|
121
|
+
metadata?: Record<string, any>;
|
|
122
|
+
}
|