snow-flow 2.0.3 → 2.0.5

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,152 @@
1
+ /**
2
+ * Snow-Flow Memory System
3
+ * SQLite-based persistent memory with caching for agent coordination
4
+ */
5
+ import { EventEmitter } from 'events';
6
+ export interface MemoryOptions {
7
+ dbPath: string;
8
+ schema?: {
9
+ version: string;
10
+ autoMigrate: boolean;
11
+ };
12
+ cache?: {
13
+ enabled: boolean;
14
+ maxSize: number;
15
+ ttl: number;
16
+ };
17
+ ttl?: {
18
+ default: number;
19
+ session: number;
20
+ artifact: number;
21
+ metric: number;
22
+ };
23
+ }
24
+ export interface MemoryEntry {
25
+ key: string;
26
+ value: any;
27
+ ttl?: number;
28
+ createdAt: Date;
29
+ expiresAt?: Date;
30
+ metadata?: Record<string, any>;
31
+ }
32
+ export interface CacheStats {
33
+ hits: number;
34
+ misses: number;
35
+ size: number;
36
+ evictions: number;
37
+ }
38
+ export interface DatabaseStats {
39
+ size: number;
40
+ tableCount: number;
41
+ rowCounts: Record<string, number>;
42
+ }
43
+ export declare class MemorySystem extends EventEmitter {
44
+ private db?;
45
+ private logger;
46
+ private options;
47
+ private cache;
48
+ private cacheStats;
49
+ private cleanupTimer?;
50
+ private initialized;
51
+ constructor(options: MemoryOptions);
52
+ /**
53
+ * 🔧 CRIT-003 FIX: Store data with agent isolation
54
+ * Implements agentId::contextKey namespacing for complete memory isolation
55
+ */
56
+ storeShared(agentId: string, contextKey: string, value: any, ttl?: number): Promise<void>;
57
+ /**
58
+ * 🔧 CRIT-003 FIX: Retrieve data with agent isolation
59
+ * Implements agentId::contextKey namespacing with backward compatibility
60
+ */
61
+ retrieveShared(agentId: string, contextKey: string): Promise<any>;
62
+ /**
63
+ * 🔧 CRIT-003 FIX: Check if agent has specific context
64
+ */
65
+ hasSharedContext(agentId: string, contextKey: string): Promise<boolean>;
66
+ /**
67
+ * 🔧 CRIT-003 FIX: List all context keys for an agent
68
+ */
69
+ listAgentContexts(agentId: string): Promise<string[]>;
70
+ /**
71
+ * 🔧 CRIT-003 FIX: Core store method for memory operations
72
+ */
73
+ store(key: string, value: any, ttl?: number): Promise<void>;
74
+ /**
75
+ * 🔧 CRIT-003 FIX: Core get method for memory operations
76
+ */
77
+ get(key: string): Promise<any>;
78
+ /**
79
+ * 🔧 CRIT-003 FIX: Check if key exists
80
+ */
81
+ exists(key: string): Promise<boolean>;
82
+ /**
83
+ * 🔧 CRIT-003 FIX: List all keys
84
+ */
85
+ listKeys(): Promise<string[]>;
86
+ /**
87
+ * Initialize the memory system
88
+ */
89
+ initialize(): Promise<void>;
90
+ /**
91
+ * Update an existing value
92
+ */
93
+ update(key: string, value: any): Promise<void>;
94
+ /**
95
+ * Execute a raw SQL query
96
+ */
97
+ execute(sql: string, params?: any[]): Promise<void>;
98
+ /**
99
+ * Query the database
100
+ */
101
+ query<T = any>(sql: string, params?: any[]): Promise<T[]>;
102
+ /**
103
+ * Insert data into a table
104
+ */
105
+ insert(table: string, data: Record<string, any>): Promise<void>;
106
+ /**
107
+ * Delete a key from memory
108
+ */
109
+ delete(key: string): Promise<void>;
110
+ /**
111
+ * Upsert data (insert or update)
112
+ */
113
+ upsert(table: string, data: Record<string, any>, uniqueKeys: string[]): Promise<void>;
114
+ /**
115
+ * Create a transaction
116
+ */
117
+ transaction<T>(fn: () => T): T;
118
+ /**
119
+ * Get database statistics
120
+ */
121
+ getDatabaseStats(): Promise<DatabaseStats>;
122
+ /**
123
+ * Get cache statistics
124
+ */
125
+ getCacheStats(): Promise<CacheStats>;
126
+ /**
127
+ * Invalidate cache
128
+ */
129
+ invalidateCache(pattern?: string): Promise<void>;
130
+ /**
131
+ * Create emergency backup
132
+ */
133
+ createEmergencyBackup(): Promise<string>;
134
+ /**
135
+ * Close the memory system
136
+ */
137
+ close(): Promise<void>;
138
+ /**
139
+ * Private helper methods
140
+ */
141
+ private createCoreTables;
142
+ private runMigrations;
143
+ private startCleanupTimer;
144
+ private cleanup;
145
+ /**
146
+ * 🔴 SNOW-003 FIX: Emergency cleanup when memory pressure is high
147
+ */
148
+ private memoryPressureCleanup;
149
+ private checkCacheSize;
150
+ private estimateCacheSize;
151
+ }
152
+ //# sourceMappingURL=memory-system.d.ts.map