@limo-labs/deity 0.1.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +519 -0
- package/dist/src/component.d.ts +19 -0
- package/dist/src/component.d.ts.map +1 -0
- package/dist/src/component.js +2 -0
- package/dist/src/component.js.map +1 -0
- package/dist/src/context/context-scope.d.ts +24 -0
- package/dist/src/context/context-scope.d.ts.map +1 -0
- package/dist/src/context/context-scope.js +19 -0
- package/dist/src/context/context-scope.js.map +1 -0
- package/dist/src/context/memory-view.d.ts +62 -0
- package/dist/src/context/memory-view.d.ts.map +1 -0
- package/dist/src/context/memory-view.js +104 -0
- package/dist/src/context/memory-view.js.map +1 -0
- package/dist/src/context/scoped-context.d.ts +51 -0
- package/dist/src/context/scoped-context.d.ts.map +1 -0
- package/dist/src/context/scoped-context.js +74 -0
- package/dist/src/context/scoped-context.js.map +1 -0
- package/dist/src/context/scoped-execution-context.d.ts +55 -0
- package/dist/src/context/scoped-execution-context.d.ts.map +1 -0
- package/dist/src/context/scoped-execution-context.js +78 -0
- package/dist/src/context/scoped-execution-context.js.map +1 -0
- package/dist/src/conversation/conversation-manager.d.ts +272 -0
- package/dist/src/conversation/conversation-manager.d.ts.map +1 -0
- package/dist/src/conversation/conversation-manager.js +11 -0
- package/dist/src/conversation/conversation-manager.js.map +1 -0
- package/dist/src/conversation/conversation-pruner.d.ts +190 -0
- package/dist/src/conversation/conversation-pruner.d.ts.map +1 -0
- package/dist/src/conversation/conversation-pruner.js +274 -0
- package/dist/src/conversation/conversation-pruner.js.map +1 -0
- package/dist/src/conversation/conversation-tree.d.ts +185 -0
- package/dist/src/conversation/conversation-tree.d.ts.map +1 -0
- package/dist/src/conversation/conversation-tree.js +288 -0
- package/dist/src/conversation/conversation-tree.js.map +1 -0
- package/dist/src/conversation/file-conversation-store.d.ts +93 -0
- package/dist/src/conversation/file-conversation-store.d.ts.map +1 -0
- package/dist/src/conversation/file-conversation-store.js +284 -0
- package/dist/src/conversation/file-conversation-store.js.map +1 -0
- package/dist/src/conversation/in-memory-conversation-store.d.ts +36 -0
- package/dist/src/conversation/in-memory-conversation-store.d.ts.map +1 -0
- package/dist/src/conversation/in-memory-conversation-store.js +146 -0
- package/dist/src/conversation/in-memory-conversation-store.js.map +1 -0
- package/dist/src/copilot-adapter.d.ts +33 -0
- package/dist/src/copilot-adapter.d.ts.map +1 -0
- package/dist/src/copilot-adapter.js +119 -0
- package/dist/src/copilot-adapter.js.map +1 -0
- package/dist/src/file-trace-enhanced.d.ts +123 -0
- package/dist/src/file-trace-enhanced.d.ts.map +1 -0
- package/dist/src/file-trace-enhanced.js +177 -0
- package/dist/src/file-trace-enhanced.js.map +1 -0
- package/dist/src/file-trace.d.ts +24 -0
- package/dist/src/file-trace.d.ts.map +1 -0
- package/dist/src/file-trace.js +60 -0
- package/dist/src/file-trace.js.map +1 -0
- package/dist/src/index.d.ts +63 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +40 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/json-store.d.ts +27 -0
- package/dist/src/json-store.d.ts.map +1 -0
- package/dist/src/json-store.js +93 -0
- package/dist/src/json-store.js.map +1 -0
- package/dist/src/llm.d.ts +35 -0
- package/dist/src/llm.d.ts.map +1 -0
- package/dist/src/llm.js +2 -0
- package/dist/src/llm.js.map +1 -0
- package/dist/src/memory/cold-storage.d.ts +60 -0
- package/dist/src/memory/cold-storage.d.ts.map +1 -0
- package/dist/src/memory/cold-storage.js +132 -0
- package/dist/src/memory/cold-storage.js.map +1 -0
- package/dist/src/memory/compression.d.ts +161 -0
- package/dist/src/memory/compression.d.ts.map +1 -0
- package/dist/src/memory/compression.js +193 -0
- package/dist/src/memory/compression.js.map +1 -0
- package/dist/src/memory/hot-memory.d.ts +69 -0
- package/dist/src/memory/hot-memory.d.ts.map +1 -0
- package/dist/src/memory/hot-memory.js +116 -0
- package/dist/src/memory/hot-memory.js.map +1 -0
- package/dist/src/memory/memory-budget.d.ts +162 -0
- package/dist/src/memory/memory-budget.d.ts.map +1 -0
- package/dist/src/memory/memory-budget.js +241 -0
- package/dist/src/memory/memory-budget.js.map +1 -0
- package/dist/src/memory/memory-config.d.ts +419 -0
- package/dist/src/memory/memory-config.d.ts.map +1 -0
- package/dist/src/memory/memory-config.js +297 -0
- package/dist/src/memory/memory-config.js.map +1 -0
- package/dist/src/memory/prefetcher.d.ts +137 -0
- package/dist/src/memory/prefetcher.d.ts.map +1 -0
- package/dist/src/memory/prefetcher.js +186 -0
- package/dist/src/memory/prefetcher.js.map +1 -0
- package/dist/src/memory/tiered-memory.d.ts +116 -0
- package/dist/src/memory/tiered-memory.d.ts.map +1 -0
- package/dist/src/memory/tiered-memory.js +215 -0
- package/dist/src/memory/tiered-memory.js.map +1 -0
- package/dist/src/memory/warm-storage.d.ts +74 -0
- package/dist/src/memory/warm-storage.d.ts.map +1 -0
- package/dist/src/memory/warm-storage.js +207 -0
- package/dist/src/memory/warm-storage.js.map +1 -0
- package/dist/src/openai-adapter.d.ts +20 -0
- package/dist/src/openai-adapter.d.ts.map +1 -0
- package/dist/src/openai-adapter.js +73 -0
- package/dist/src/openai-adapter.js.map +1 -0
- package/dist/src/parser.d.ts +27 -0
- package/dist/src/parser.d.ts.map +1 -0
- package/dist/src/parser.js +76 -0
- package/dist/src/parser.js.map +1 -0
- package/dist/src/runtime.d.ts +172 -0
- package/dist/src/runtime.d.ts.map +1 -0
- package/dist/src/runtime.js +436 -0
- package/dist/src/runtime.js.map +1 -0
- package/dist/src/schema-utils.d.ts +7 -0
- package/dist/src/schema-utils.d.ts.map +1 -0
- package/dist/src/schema-utils.js +71 -0
- package/dist/src/schema-utils.js.map +1 -0
- package/dist/src/stage.d.ts +139 -0
- package/dist/src/stage.d.ts.map +1 -0
- package/dist/src/stage.js +2 -0
- package/dist/src/stage.js.map +1 -0
- package/dist/src/store.d.ts +51 -0
- package/dist/src/store.d.ts.map +1 -0
- package/dist/src/store.js +2 -0
- package/dist/src/store.js.map +1 -0
- package/dist/src/tool.d.ts +12 -0
- package/dist/src/tool.d.ts.map +1 -0
- package/dist/src/tool.js +2 -0
- package/dist/src/tool.js.map +1 -0
- package/dist/src/trace.d.ts +60 -0
- package/dist/src/trace.d.ts.map +1 -0
- package/dist/src/trace.js +2 -0
- package/dist/src/trace.js.map +1 -0
- package/dist/src/validator.d.ts +17 -0
- package/dist/src/validator.d.ts.map +1 -0
- package/dist/src/validator.js +21 -0
- package/dist/src/validator.js.map +1 -0
- package/dist/src/workflow.d.ts +192 -0
- package/dist/src/workflow.d.ts.map +1 -0
- package/dist/src/workflow.js +50 -0
- package/dist/src/workflow.js.map +1 -0
- package/package.json +62 -0
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { TieredMemoryManager } from "./tiered-memory.js";
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for hot memory (in-memory LRU cache).
|
|
5
|
+
*
|
|
6
|
+
* @since 2.0.0
|
|
7
|
+
*/
|
|
8
|
+
export interface HotMemoryConfig {
|
|
9
|
+
/** Maximum number of items to store in hot memory */
|
|
10
|
+
maxItems: number;
|
|
11
|
+
/** Maximum total size in bytes (optional) */
|
|
12
|
+
maxSize?: number;
|
|
13
|
+
/** Time-to-live in milliseconds (optional) */
|
|
14
|
+
ttl?: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Configuration for warm storage (compressed disk cache).
|
|
18
|
+
*
|
|
19
|
+
* @since 2.0.0
|
|
20
|
+
*/
|
|
21
|
+
export interface WarmStorageConfig {
|
|
22
|
+
/** Whether warm storage is enabled */
|
|
23
|
+
enabled: boolean;
|
|
24
|
+
/** Maximum total size in bytes */
|
|
25
|
+
maxSize: number;
|
|
26
|
+
/** Compression algorithm to use */
|
|
27
|
+
compressionAlgorithm: "gzip" | "lz4" | "none";
|
|
28
|
+
/** Directory for warm cache files */
|
|
29
|
+
directory: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Configuration for cold storage (uncompressed disk archive).
|
|
33
|
+
*
|
|
34
|
+
* @since 2.0.0
|
|
35
|
+
*/
|
|
36
|
+
export interface ColdStorageConfig {
|
|
37
|
+
/** Whether cold storage is enabled */
|
|
38
|
+
enabled: boolean;
|
|
39
|
+
/** Directory for cold archive files */
|
|
40
|
+
directory: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Complete memory configuration for tiered memory system.
|
|
44
|
+
*
|
|
45
|
+
* Defines the behavior of hot memory (LRU cache), warm storage (compressed disk),
|
|
46
|
+
* and cold storage (uncompressed archive).
|
|
47
|
+
*
|
|
48
|
+
* @since 2.0.0
|
|
49
|
+
* @example
|
|
50
|
+
* ```typescript
|
|
51
|
+
* const config: MemoryConfig = {
|
|
52
|
+
* hot: {
|
|
53
|
+
* maxItems: 1000,
|
|
54
|
+
* maxSize: 100 * 1024 * 1024, // 100MB
|
|
55
|
+
* ttl: 3600 * 1000, // 1 hour
|
|
56
|
+
* },
|
|
57
|
+
* warm: {
|
|
58
|
+
* enabled: true,
|
|
59
|
+
* maxSize: 1024 * 1024 * 1024, // 1GB
|
|
60
|
+
* compressionAlgorithm: "gzip",
|
|
61
|
+
* directory: ".deity/cache",
|
|
62
|
+
* },
|
|
63
|
+
* cold: {
|
|
64
|
+
* enabled: true,
|
|
65
|
+
* directory: ".deity/archive",
|
|
66
|
+
* },
|
|
67
|
+
* };
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export interface MemoryConfig {
|
|
71
|
+
/** Hot memory configuration */
|
|
72
|
+
hot: HotMemoryConfig;
|
|
73
|
+
/** Warm storage configuration */
|
|
74
|
+
warm: WarmStorageConfig;
|
|
75
|
+
/** Cold storage configuration */
|
|
76
|
+
cold: ColdStorageConfig;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Zod schema for hot memory configuration validation.
|
|
80
|
+
* @since 2.0.0
|
|
81
|
+
*/
|
|
82
|
+
export declare const HotMemoryConfigSchema: z.ZodObject<{
|
|
83
|
+
maxItems: z.ZodNumber;
|
|
84
|
+
maxSize: z.ZodOptional<z.ZodNumber>;
|
|
85
|
+
ttl: z.ZodOptional<z.ZodNumber>;
|
|
86
|
+
}, "strip", z.ZodTypeAny, {
|
|
87
|
+
maxItems: number;
|
|
88
|
+
maxSize?: number | undefined;
|
|
89
|
+
ttl?: number | undefined;
|
|
90
|
+
}, {
|
|
91
|
+
maxItems: number;
|
|
92
|
+
maxSize?: number | undefined;
|
|
93
|
+
ttl?: number | undefined;
|
|
94
|
+
}>;
|
|
95
|
+
/**
|
|
96
|
+
* Zod schema for warm storage configuration validation.
|
|
97
|
+
* @since 2.0.0
|
|
98
|
+
*/
|
|
99
|
+
export declare const WarmStorageConfigSchema: z.ZodObject<{
|
|
100
|
+
enabled: z.ZodBoolean;
|
|
101
|
+
maxSize: z.ZodNumber;
|
|
102
|
+
compressionAlgorithm: z.ZodEnum<["gzip", "lz4", "none"]>;
|
|
103
|
+
directory: z.ZodString;
|
|
104
|
+
}, "strip", z.ZodTypeAny, {
|
|
105
|
+
maxSize: number;
|
|
106
|
+
directory: string;
|
|
107
|
+
compressionAlgorithm: "gzip" | "lz4" | "none";
|
|
108
|
+
enabled: boolean;
|
|
109
|
+
}, {
|
|
110
|
+
maxSize: number;
|
|
111
|
+
directory: string;
|
|
112
|
+
compressionAlgorithm: "gzip" | "lz4" | "none";
|
|
113
|
+
enabled: boolean;
|
|
114
|
+
}>;
|
|
115
|
+
/**
|
|
116
|
+
* Zod schema for cold storage configuration validation.
|
|
117
|
+
* @since 2.0.0
|
|
118
|
+
*/
|
|
119
|
+
export declare const ColdStorageConfigSchema: z.ZodObject<{
|
|
120
|
+
enabled: z.ZodBoolean;
|
|
121
|
+
directory: z.ZodString;
|
|
122
|
+
}, "strip", z.ZodTypeAny, {
|
|
123
|
+
directory: string;
|
|
124
|
+
enabled: boolean;
|
|
125
|
+
}, {
|
|
126
|
+
directory: string;
|
|
127
|
+
enabled: boolean;
|
|
128
|
+
}>;
|
|
129
|
+
/**
|
|
130
|
+
* Zod schema for complete memory configuration validation.
|
|
131
|
+
* @since 2.0.0
|
|
132
|
+
*/
|
|
133
|
+
export declare const MemoryConfigSchema: z.ZodObject<{
|
|
134
|
+
hot: z.ZodObject<{
|
|
135
|
+
maxItems: z.ZodNumber;
|
|
136
|
+
maxSize: z.ZodOptional<z.ZodNumber>;
|
|
137
|
+
ttl: z.ZodOptional<z.ZodNumber>;
|
|
138
|
+
}, "strip", z.ZodTypeAny, {
|
|
139
|
+
maxItems: number;
|
|
140
|
+
maxSize?: number | undefined;
|
|
141
|
+
ttl?: number | undefined;
|
|
142
|
+
}, {
|
|
143
|
+
maxItems: number;
|
|
144
|
+
maxSize?: number | undefined;
|
|
145
|
+
ttl?: number | undefined;
|
|
146
|
+
}>;
|
|
147
|
+
warm: z.ZodObject<{
|
|
148
|
+
enabled: z.ZodBoolean;
|
|
149
|
+
maxSize: z.ZodNumber;
|
|
150
|
+
compressionAlgorithm: z.ZodEnum<["gzip", "lz4", "none"]>;
|
|
151
|
+
directory: z.ZodString;
|
|
152
|
+
}, "strip", z.ZodTypeAny, {
|
|
153
|
+
maxSize: number;
|
|
154
|
+
directory: string;
|
|
155
|
+
compressionAlgorithm: "gzip" | "lz4" | "none";
|
|
156
|
+
enabled: boolean;
|
|
157
|
+
}, {
|
|
158
|
+
maxSize: number;
|
|
159
|
+
directory: string;
|
|
160
|
+
compressionAlgorithm: "gzip" | "lz4" | "none";
|
|
161
|
+
enabled: boolean;
|
|
162
|
+
}>;
|
|
163
|
+
cold: z.ZodObject<{
|
|
164
|
+
enabled: z.ZodBoolean;
|
|
165
|
+
directory: z.ZodString;
|
|
166
|
+
}, "strip", z.ZodTypeAny, {
|
|
167
|
+
directory: string;
|
|
168
|
+
enabled: boolean;
|
|
169
|
+
}, {
|
|
170
|
+
directory: string;
|
|
171
|
+
enabled: boolean;
|
|
172
|
+
}>;
|
|
173
|
+
}, "strip", z.ZodTypeAny, {
|
|
174
|
+
hot: {
|
|
175
|
+
maxItems: number;
|
|
176
|
+
maxSize?: number | undefined;
|
|
177
|
+
ttl?: number | undefined;
|
|
178
|
+
};
|
|
179
|
+
warm: {
|
|
180
|
+
maxSize: number;
|
|
181
|
+
directory: string;
|
|
182
|
+
compressionAlgorithm: "gzip" | "lz4" | "none";
|
|
183
|
+
enabled: boolean;
|
|
184
|
+
};
|
|
185
|
+
cold: {
|
|
186
|
+
directory: string;
|
|
187
|
+
enabled: boolean;
|
|
188
|
+
};
|
|
189
|
+
}, {
|
|
190
|
+
hot: {
|
|
191
|
+
maxItems: number;
|
|
192
|
+
maxSize?: number | undefined;
|
|
193
|
+
ttl?: number | undefined;
|
|
194
|
+
};
|
|
195
|
+
warm: {
|
|
196
|
+
maxSize: number;
|
|
197
|
+
directory: string;
|
|
198
|
+
compressionAlgorithm: "gzip" | "lz4" | "none";
|
|
199
|
+
enabled: boolean;
|
|
200
|
+
};
|
|
201
|
+
cold: {
|
|
202
|
+
directory: string;
|
|
203
|
+
enabled: boolean;
|
|
204
|
+
};
|
|
205
|
+
}>;
|
|
206
|
+
/**
|
|
207
|
+
* Pre-configured memory settings for development environments.
|
|
208
|
+
*
|
|
209
|
+
* - Generous hot memory limits (2000 items, 200MB)
|
|
210
|
+
* - No compression (fast, no CPU overhead)
|
|
211
|
+
* - Warm and cold storage enabled
|
|
212
|
+
* - Short TTL for fast iteration
|
|
213
|
+
*
|
|
214
|
+
* @since 2.0.0
|
|
215
|
+
*/
|
|
216
|
+
export declare const MemoryPresets: {
|
|
217
|
+
/**
|
|
218
|
+
* Development preset: Fast and generous.
|
|
219
|
+
*
|
|
220
|
+
* Optimized for quick iteration and debugging with minimal overhead.
|
|
221
|
+
* Uses no compression for speed and has generous memory limits.
|
|
222
|
+
*/
|
|
223
|
+
readonly development: {
|
|
224
|
+
hot: {
|
|
225
|
+
maxItems: number;
|
|
226
|
+
maxSize: number;
|
|
227
|
+
ttl: number;
|
|
228
|
+
};
|
|
229
|
+
warm: {
|
|
230
|
+
enabled: true;
|
|
231
|
+
maxSize: number;
|
|
232
|
+
compressionAlgorithm: "none";
|
|
233
|
+
directory: string;
|
|
234
|
+
};
|
|
235
|
+
cold: {
|
|
236
|
+
enabled: true;
|
|
237
|
+
directory: string;
|
|
238
|
+
};
|
|
239
|
+
};
|
|
240
|
+
/**
|
|
241
|
+
* Production preset: Balanced and reliable.
|
|
242
|
+
*
|
|
243
|
+
* Optimized for production use with good balance between performance
|
|
244
|
+
* and resource usage. Uses gzip compression for space efficiency.
|
|
245
|
+
*/
|
|
246
|
+
readonly production: {
|
|
247
|
+
hot: {
|
|
248
|
+
maxItems: number;
|
|
249
|
+
maxSize: number;
|
|
250
|
+
ttl: number;
|
|
251
|
+
};
|
|
252
|
+
warm: {
|
|
253
|
+
enabled: true;
|
|
254
|
+
maxSize: number;
|
|
255
|
+
compressionAlgorithm: "gzip";
|
|
256
|
+
directory: string;
|
|
257
|
+
};
|
|
258
|
+
cold: {
|
|
259
|
+
enabled: true;
|
|
260
|
+
directory: string;
|
|
261
|
+
};
|
|
262
|
+
};
|
|
263
|
+
/**
|
|
264
|
+
* Minimal preset: Lightweight with minimal disk usage.
|
|
265
|
+
*
|
|
266
|
+
* Optimized for resource-constrained environments or simple workflows.
|
|
267
|
+
* Warm storage disabled, only hot memory and cold storage used.
|
|
268
|
+
*/
|
|
269
|
+
readonly minimal: {
|
|
270
|
+
hot: {
|
|
271
|
+
maxItems: number;
|
|
272
|
+
maxSize: number;
|
|
273
|
+
ttl: number;
|
|
274
|
+
};
|
|
275
|
+
warm: {
|
|
276
|
+
enabled: false;
|
|
277
|
+
maxSize: number;
|
|
278
|
+
compressionAlgorithm: "none";
|
|
279
|
+
directory: string;
|
|
280
|
+
};
|
|
281
|
+
cold: {
|
|
282
|
+
enabled: true;
|
|
283
|
+
directory: string;
|
|
284
|
+
};
|
|
285
|
+
};
|
|
286
|
+
};
|
|
287
|
+
/**
|
|
288
|
+
* Validates a memory configuration against the schema.
|
|
289
|
+
*
|
|
290
|
+
* Throws an error if the configuration is invalid.
|
|
291
|
+
*
|
|
292
|
+
* @param config - The configuration to validate
|
|
293
|
+
* @returns The validated configuration (typed)
|
|
294
|
+
* @throws {Error} If the configuration is invalid
|
|
295
|
+
* @since 2.0.0
|
|
296
|
+
* @example
|
|
297
|
+
* ```typescript
|
|
298
|
+
* try {
|
|
299
|
+
* const validated = validateMemoryConfig(userConfig);
|
|
300
|
+
* console.log("Configuration valid!");
|
|
301
|
+
* } catch (error) {
|
|
302
|
+
* console.error("Invalid configuration:", error.message);
|
|
303
|
+
* }
|
|
304
|
+
* ```
|
|
305
|
+
*/
|
|
306
|
+
export declare function validateMemoryConfig(config: unknown): MemoryConfig;
|
|
307
|
+
/**
|
|
308
|
+
* Merges a partial configuration with a base configuration.
|
|
309
|
+
*
|
|
310
|
+
* Useful for applying user overrides on top of a preset.
|
|
311
|
+
* Performs deep merge of nested objects.
|
|
312
|
+
*
|
|
313
|
+
* @param base - The base configuration (preset or default)
|
|
314
|
+
* @param override - The partial configuration to merge
|
|
315
|
+
* @returns The merged configuration
|
|
316
|
+
* @since 2.0.0
|
|
317
|
+
* @example
|
|
318
|
+
* ```typescript
|
|
319
|
+
* const config = mergeMemoryConfig(
|
|
320
|
+
* MemoryPresets.production,
|
|
321
|
+
* {
|
|
322
|
+
* hot: { maxItems: 2000 }, // Override just maxItems
|
|
323
|
+
* }
|
|
324
|
+
* );
|
|
325
|
+
* // Result: production preset with 2000 hot items instead of 1000
|
|
326
|
+
* ```
|
|
327
|
+
*/
|
|
328
|
+
export declare function mergeMemoryConfig(base: MemoryConfig, override: DeepPartial<MemoryConfig>): MemoryConfig;
|
|
329
|
+
/**
|
|
330
|
+
* Creates a memory configuration from a preset or custom config.
|
|
331
|
+
*
|
|
332
|
+
* Supports three modes:
|
|
333
|
+
* 1. Preset name ("development", "production", "minimal")
|
|
334
|
+
* 2. Full custom configuration
|
|
335
|
+
* 3. Preset with overrides
|
|
336
|
+
*
|
|
337
|
+
* @param config - Preset name, full config, or preset with overrides
|
|
338
|
+
* @returns Validated memory configuration
|
|
339
|
+
* @throws {Error} If the configuration is invalid
|
|
340
|
+
* @since 2.0.0
|
|
341
|
+
* @example
|
|
342
|
+
* ```typescript
|
|
343
|
+
* // Use preset
|
|
344
|
+
* const config1 = createMemoryConfig("production");
|
|
345
|
+
*
|
|
346
|
+
* // Use custom config
|
|
347
|
+
* const config2 = createMemoryConfig({
|
|
348
|
+
* hot: { maxItems: 1500 },
|
|
349
|
+
* warm: { enabled: true, maxSize: 1024 * 1024 * 1024, compressionAlgorithm: "gzip", directory: ".cache" },
|
|
350
|
+
* cold: { enabled: true, directory: ".archive" },
|
|
351
|
+
* });
|
|
352
|
+
*
|
|
353
|
+
* // Use preset with overrides
|
|
354
|
+
* const config3 = createMemoryConfig({
|
|
355
|
+
* preset: "production",
|
|
356
|
+
* override: { hot: { maxItems: 2000 } },
|
|
357
|
+
* });
|
|
358
|
+
* ```
|
|
359
|
+
*/
|
|
360
|
+
export declare function createMemoryConfig(config: keyof typeof MemoryPresets | MemoryConfig | {
|
|
361
|
+
preset: keyof typeof MemoryPresets;
|
|
362
|
+
override: DeepPartial<MemoryConfig>;
|
|
363
|
+
}): MemoryConfig;
|
|
364
|
+
/**
|
|
365
|
+
* Helper type for partial configuration (deep partial).
|
|
366
|
+
* @since 2.0.0
|
|
367
|
+
*/
|
|
368
|
+
export type DeepPartial<T> = {
|
|
369
|
+
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
370
|
+
};
|
|
371
|
+
/**
|
|
372
|
+
* Gets the default memory configuration.
|
|
373
|
+
*
|
|
374
|
+
* Uses the production preset by default.
|
|
375
|
+
*
|
|
376
|
+
* @returns Default memory configuration
|
|
377
|
+
* @since 2.0.0
|
|
378
|
+
*/
|
|
379
|
+
export declare function getDefaultMemoryConfig(): MemoryConfig;
|
|
380
|
+
/**
|
|
381
|
+
* Creates a TieredMemoryManager instance from a memory configuration.
|
|
382
|
+
*
|
|
383
|
+
* Converts the user-facing MemoryConfig (with validation and presets) into
|
|
384
|
+
* the internal TieredMemoryConfig format and creates a TieredMemoryManager.
|
|
385
|
+
*
|
|
386
|
+
* This is a synchronous wrapper - it uses require() internally which works
|
|
387
|
+
* because TieredMemoryManager is in the same package.
|
|
388
|
+
*
|
|
389
|
+
* @param config - Memory configuration (preset name, full config, or preset with override)
|
|
390
|
+
* @returns Configured TieredMemoryManager instance (call .init() before use)
|
|
391
|
+
* @throws {Error} If the configuration is invalid
|
|
392
|
+
* @since 2.0.0
|
|
393
|
+
* @example
|
|
394
|
+
* ```typescript
|
|
395
|
+
* // Create from preset name
|
|
396
|
+
* const manager1 = createTieredMemoryManager("production");
|
|
397
|
+
* await manager1.init();
|
|
398
|
+
*
|
|
399
|
+
* // Create from custom config
|
|
400
|
+
* const manager2 = createTieredMemoryManager({
|
|
401
|
+
* hot: { maxItems: 1000 },
|
|
402
|
+
* warm: { enabled: true, maxSize: 1024 * 1024 * 1024, compressionAlgorithm: "gzip", directory: ".cache" },
|
|
403
|
+
* cold: { enabled: true, directory: ".archive" },
|
|
404
|
+
* });
|
|
405
|
+
* await manager2.init();
|
|
406
|
+
*
|
|
407
|
+
* // Create from preset with overrides
|
|
408
|
+
* const manager3 = createTieredMemoryManager({
|
|
409
|
+
* preset: "production",
|
|
410
|
+
* override: { hot: { maxItems: 2000 } },
|
|
411
|
+
* });
|
|
412
|
+
* await manager3.init();
|
|
413
|
+
* ```
|
|
414
|
+
*/
|
|
415
|
+
export declare function createTieredMemoryManager(config: keyof typeof MemoryPresets | MemoryConfig | {
|
|
416
|
+
preset: keyof typeof MemoryPresets;
|
|
417
|
+
override: DeepPartial<MemoryConfig>;
|
|
418
|
+
}): TieredMemoryManager;
|
|
419
|
+
//# sourceMappingURL=memory-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory-config.d.ts","sourceRoot":"","sources":["../../../src/memory/memory-config.ts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