@gotza02/seq-thinking 1.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.
- package/README.md +149 -0
- package/SYSTEM_INSTRUCTIONS.md +50 -0
- package/agents_test.log +15 -0
- package/dist/__tests__/agents.test.d.ts +2 -0
- package/dist/__tests__/agents.test.d.ts.map +1 -0
- package/dist/__tests__/agents.test.js +673 -0
- package/dist/__tests__/agents.test.js.map +1 -0
- package/dist/__tests__/mcp-server.test.d.ts +2 -0
- package/dist/__tests__/mcp-server.test.d.ts.map +1 -0
- package/dist/__tests__/mcp-server.test.js +315 -0
- package/dist/__tests__/mcp-server.test.js.map +1 -0
- package/dist/__tests__/sequential-thinking.test.d.ts +2 -0
- package/dist/__tests__/sequential-thinking.test.d.ts.map +1 -0
- package/dist/__tests__/sequential-thinking.test.js +545 -0
- package/dist/__tests__/sequential-thinking.test.js.map +1 -0
- package/dist/__tests__/swarm-coordinator.test.d.ts +2 -0
- package/dist/__tests__/swarm-coordinator.test.d.ts.map +1 -0
- package/dist/__tests__/swarm-coordinator.test.js +606 -0
- package/dist/__tests__/swarm-coordinator.test.js.map +1 -0
- package/dist/__tests__/types.test.d.ts +2 -0
- package/dist/__tests__/types.test.d.ts.map +1 -0
- package/dist/__tests__/types.test.js +741 -0
- package/dist/__tests__/types.test.js.map +1 -0
- package/dist/__tests__/utils.test.d.ts +2 -0
- package/dist/__tests__/utils.test.d.ts.map +1 -0
- package/dist/__tests__/utils.test.js +264 -0
- package/dist/__tests__/utils.test.js.map +1 -0
- package/dist/agents/base-agent.d.ts +126 -0
- package/dist/agents/base-agent.d.ts.map +1 -0
- package/dist/agents/base-agent.js +214 -0
- package/dist/agents/base-agent.js.map +1 -0
- package/dist/agents/critic-agent.d.ts +134 -0
- package/dist/agents/critic-agent.d.ts.map +1 -0
- package/dist/agents/critic-agent.js +484 -0
- package/dist/agents/critic-agent.js.map +1 -0
- package/dist/agents/index.d.ts +11 -0
- package/dist/agents/index.d.ts.map +1 -0
- package/dist/agents/index.js +11 -0
- package/dist/agents/index.js.map +1 -0
- package/dist/agents/meta-reasoning-agent.d.ts +143 -0
- package/dist/agents/meta-reasoning-agent.d.ts.map +1 -0
- package/dist/agents/meta-reasoning-agent.js +532 -0
- package/dist/agents/meta-reasoning-agent.js.map +1 -0
- package/dist/agents/reasoner-agent.d.ts +75 -0
- package/dist/agents/reasoner-agent.d.ts.map +1 -0
- package/dist/agents/reasoner-agent.js +226 -0
- package/dist/agents/reasoner-agent.js.map +1 -0
- package/dist/agents/synthesizer-agent.d.ts +174 -0
- package/dist/agents/synthesizer-agent.d.ts.map +1 -0
- package/dist/agents/synthesizer-agent.js +583 -0
- package/dist/agents/synthesizer-agent.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp-server.d.ts +823 -0
- package/dist/mcp-server.d.ts.map +1 -0
- package/dist/mcp-server.js +377 -0
- package/dist/mcp-server.js.map +1 -0
- package/dist/sequential-thinking.d.ts +91 -0
- package/dist/sequential-thinking.d.ts.map +1 -0
- package/dist/sequential-thinking.js +540 -0
- package/dist/sequential-thinking.js.map +1 -0
- package/dist/swarm-coordinator.d.ts +188 -0
- package/dist/swarm-coordinator.d.ts.map +1 -0
- package/dist/swarm-coordinator.js +627 -0
- package/dist/swarm-coordinator.js.map +1 -0
- package/dist/types/index.d.ts +806 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +279 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/index.d.ts +421 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +864 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/llm-adapter.d.ts +23 -0
- package/dist/utils/llm-adapter.d.ts.map +1 -0
- package/dist/utils/llm-adapter.js +68 -0
- package/dist/utils/llm-adapter.js.map +1 -0
- package/dist/utils/persistence.d.ts +33 -0
- package/dist/utils/persistence.d.ts.map +1 -0
- package/dist/utils/persistence.js +108 -0
- package/dist/utils/persistence.js.map +1 -0
- package/package.json +41 -0
- package/src/__tests__/agents.test.ts +858 -0
- package/src/__tests__/mcp-server.test.ts +380 -0
- package/src/__tests__/sequential-thinking.test.ts +687 -0
- package/src/__tests__/swarm-coordinator.test.ts +903 -0
- package/src/__tests__/types.test.ts +839 -0
- package/src/__tests__/utils.test.ts +322 -0
- package/src/agents/base-agent.ts +285 -0
- package/src/agents/critic-agent.ts +582 -0
- package/src/agents/index.ts +11 -0
- package/src/agents/meta-reasoning-agent.ts +672 -0
- package/src/agents/reasoner-agent.ts +312 -0
- package/src/agents/synthesizer-agent.ts +758 -0
- package/src/index.ts +118 -0
- package/src/mcp-server.ts +387 -0
- package/src/sequential-thinking.ts +560 -0
- package/src/swarm-coordinator.ts +744 -0
- package/src/types/index.ts +915 -0
- package/src/utils/index.ts +1004 -0
- package/src/utils/llm-adapter.ts +76 -0
- package/src/utils/persistence.ts +108 -0
- package/test_output.log +0 -0
- package/tsconfig.json +21 -0
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility Functions for MCP Sequential Thinking System
|
|
3
|
+
* @module utils
|
|
4
|
+
* @version 1.0.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Generate a unique ID based on timestamp and random string
|
|
8
|
+
* @returns Unique ID string
|
|
9
|
+
*/
|
|
10
|
+
export declare function generateId(): string;
|
|
11
|
+
/**
|
|
12
|
+
* Generate a UUID v4
|
|
13
|
+
* @returns UUID string
|
|
14
|
+
*/
|
|
15
|
+
export declare function generateUUID(): string;
|
|
16
|
+
/**
|
|
17
|
+
* Generate a short 8-character ID
|
|
18
|
+
* @returns Short ID string
|
|
19
|
+
*/
|
|
20
|
+
export declare function generateShortId(): string;
|
|
21
|
+
/**
|
|
22
|
+
* Clamp a value between min and max
|
|
23
|
+
* @param value - Value to clamp
|
|
24
|
+
* @param min - Minimum value
|
|
25
|
+
* @param max - Maximum value
|
|
26
|
+
* @returns Clamped value
|
|
27
|
+
*/
|
|
28
|
+
export declare function clamp(value: number, min: number, max: number): number;
|
|
29
|
+
/**
|
|
30
|
+
* Clamp a confidence score to [0, 1]
|
|
31
|
+
* @param confidence - Confidence score
|
|
32
|
+
* @returns Clamped confidence
|
|
33
|
+
*/
|
|
34
|
+
export declare function clampConfidence(confidence: number): number;
|
|
35
|
+
/**
|
|
36
|
+
* Linear interpolation between two values
|
|
37
|
+
* @param a - Start value
|
|
38
|
+
* @param b - End value
|
|
39
|
+
* @param t - Interpolation factor (0-1)
|
|
40
|
+
* @returns Interpolated value
|
|
41
|
+
*/
|
|
42
|
+
export declare function lerp(a: number, b: number, t: number): number;
|
|
43
|
+
/**
|
|
44
|
+
* Round a number to specified decimal places
|
|
45
|
+
* @param value - Value to round
|
|
46
|
+
* @param decimals - Number of decimal places
|
|
47
|
+
* @returns Rounded value
|
|
48
|
+
*/
|
|
49
|
+
export declare function roundTo(value: number, decimals: number): number;
|
|
50
|
+
/**
|
|
51
|
+
* Extract words from text
|
|
52
|
+
* @param text - Input text
|
|
53
|
+
* @returns Array of words
|
|
54
|
+
*/
|
|
55
|
+
export declare function extractWords(text: string): string[];
|
|
56
|
+
/**
|
|
57
|
+
* Calculate Jaccard similarity between two sets
|
|
58
|
+
* @param setA - First set
|
|
59
|
+
* @param setB - Second set
|
|
60
|
+
* @returns Jaccard similarity (0-1)
|
|
61
|
+
*/
|
|
62
|
+
export declare function calculateJaccardSimilarity<T>(setA: Set<T>, setB: Set<T>): number;
|
|
63
|
+
/**
|
|
64
|
+
* Calculate Levenshtein distance between two strings
|
|
65
|
+
* @param a - First string
|
|
66
|
+
* @param b - Second string
|
|
67
|
+
* @returns Levenshtein distance
|
|
68
|
+
*/
|
|
69
|
+
export declare function levenshteinDistance(a: string, b: string): number;
|
|
70
|
+
/**
|
|
71
|
+
* Calculate text similarity using Levenshtein distance
|
|
72
|
+
* @param a - First text
|
|
73
|
+
* @param b - Second text
|
|
74
|
+
* @returns Similarity score (0-1)
|
|
75
|
+
*/
|
|
76
|
+
export declare function calculateSimilarity(a: string, b: string): number;
|
|
77
|
+
/**
|
|
78
|
+
* Calculate cosine similarity between two vectors
|
|
79
|
+
* @param a - First vector
|
|
80
|
+
* @param b - Second vector
|
|
81
|
+
* @returns Cosine similarity (-1 to 1)
|
|
82
|
+
*/
|
|
83
|
+
export declare function calculateCosineSimilarity(a: number[], b: number[]): number;
|
|
84
|
+
/**
|
|
85
|
+
* Extract n-grams from text
|
|
86
|
+
* @param text - Input text
|
|
87
|
+
* @param n - N-gram size
|
|
88
|
+
* @returns Array of n-grams
|
|
89
|
+
*/
|
|
90
|
+
export declare function extractNGrams(text: string, n: number): string[];
|
|
91
|
+
/**
|
|
92
|
+
* Calculate n-gram similarity between two texts
|
|
93
|
+
* @param a - First text
|
|
94
|
+
* @param b - Second text
|
|
95
|
+
* @param n - N-gram size (default: 2)
|
|
96
|
+
* @returns Similarity score (0-1)
|
|
97
|
+
*/
|
|
98
|
+
export declare function calculateNGramSimilarity(a: string, b: string, n?: number): number;
|
|
99
|
+
/**
|
|
100
|
+
* Calculate mean of an array of numbers
|
|
101
|
+
* @param values - Array of numbers
|
|
102
|
+
* @returns Mean value
|
|
103
|
+
*/
|
|
104
|
+
export declare function calculateMean(values: number[]): number;
|
|
105
|
+
/**
|
|
106
|
+
* Calculate weighted average
|
|
107
|
+
* @param values - Array of values
|
|
108
|
+
* @param weights - Array of weights
|
|
109
|
+
* @returns Weighted average
|
|
110
|
+
*/
|
|
111
|
+
export declare function calculateWeightedAverage(values: number[], weights: number[]): number;
|
|
112
|
+
/**
|
|
113
|
+
* Calculate median of an array of numbers
|
|
114
|
+
* @param values - Array of numbers
|
|
115
|
+
* @returns Median value
|
|
116
|
+
*/
|
|
117
|
+
export declare function calculateMedian(values: number[]): number;
|
|
118
|
+
/**
|
|
119
|
+
* Calculate standard deviation
|
|
120
|
+
* @param values - Array of numbers
|
|
121
|
+
* @returns Standard deviation
|
|
122
|
+
*/
|
|
123
|
+
export declare function calculateStandardDeviation(values: number[]): number;
|
|
124
|
+
/**
|
|
125
|
+
* Calculate variance
|
|
126
|
+
* @param values - Array of numbers
|
|
127
|
+
* @returns Variance
|
|
128
|
+
*/
|
|
129
|
+
export declare function calculateVariance(values: number[]): number;
|
|
130
|
+
/**
|
|
131
|
+
* Find minimum value
|
|
132
|
+
* @param values - Array of numbers
|
|
133
|
+
* @returns Minimum value
|
|
134
|
+
*/
|
|
135
|
+
export declare function findMin(values: number[]): number;
|
|
136
|
+
/**
|
|
137
|
+
* Find maximum value
|
|
138
|
+
* @param values - Array of numbers
|
|
139
|
+
* @returns Maximum value
|
|
140
|
+
*/
|
|
141
|
+
export declare function findMax(values: number[]): number;
|
|
142
|
+
/**
|
|
143
|
+
* Normalize values to [0, 1] range
|
|
144
|
+
* @param values - Array of numbers
|
|
145
|
+
* @returns Normalized values
|
|
146
|
+
*/
|
|
147
|
+
export declare function normalizeValues(values: number[]): number[];
|
|
148
|
+
/**
|
|
149
|
+
* Calculate percentile
|
|
150
|
+
* @param values - Array of numbers
|
|
151
|
+
* @param percentile - Percentile (0-100)
|
|
152
|
+
* @returns Percentile value
|
|
153
|
+
*/
|
|
154
|
+
export declare function calculatePercentile(values: number[], percentile: number): number;
|
|
155
|
+
/**
|
|
156
|
+
* Format duration in milliseconds to human-readable string
|
|
157
|
+
* @param ms - Duration in milliseconds
|
|
158
|
+
* @returns Formatted string
|
|
159
|
+
*/
|
|
160
|
+
export declare function formatDuration(ms: number): string;
|
|
161
|
+
/**
|
|
162
|
+
* Format timestamp to ISO string
|
|
163
|
+
* @param timestamp - Timestamp (Date or number)
|
|
164
|
+
* @returns ISO string
|
|
165
|
+
*/
|
|
166
|
+
export declare function formatTimestamp(timestamp: Date | number): string;
|
|
167
|
+
/**
|
|
168
|
+
* Format relative time (e.g., "2m ago")
|
|
169
|
+
* @param timestamp - Timestamp (Date or number)
|
|
170
|
+
* @returns Relative time string
|
|
171
|
+
*/
|
|
172
|
+
export declare function formatRelativeTime(timestamp: Date | number): string;
|
|
173
|
+
/**
|
|
174
|
+
* Deep clone an object
|
|
175
|
+
* @param obj - Object to clone
|
|
176
|
+
* @returns Cloned object
|
|
177
|
+
*/
|
|
178
|
+
export declare function deepClone<T>(obj: T): T;
|
|
179
|
+
/**
|
|
180
|
+
* Deep clone with Date support
|
|
181
|
+
* @param obj - Object to clone
|
|
182
|
+
* @returns Cloned object with Dates preserved
|
|
183
|
+
*/
|
|
184
|
+
export declare function deepCloneWithDates<T>(obj: T): T;
|
|
185
|
+
/**
|
|
186
|
+
* Deep merge two objects
|
|
187
|
+
* @param target - Target object
|
|
188
|
+
* @param source - Source object
|
|
189
|
+
* @returns Merged object
|
|
190
|
+
*/
|
|
191
|
+
export declare function deepMerge<T extends Record<string, unknown>>(target: T, source: Partial<T>): T;
|
|
192
|
+
/**
|
|
193
|
+
* Deep equality check
|
|
194
|
+
* @param a - First object
|
|
195
|
+
* @param b - Second object
|
|
196
|
+
* @returns True if equal
|
|
197
|
+
*/
|
|
198
|
+
export declare function deepEqual(a: unknown, b: unknown): boolean;
|
|
199
|
+
/**
|
|
200
|
+
* Pick specific keys from an object
|
|
201
|
+
* @param obj - Source object
|
|
202
|
+
* @param keys - Keys to pick
|
|
203
|
+
* @returns Object with picked keys
|
|
204
|
+
*/
|
|
205
|
+
export declare function pick<T extends Record<string, unknown>, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>;
|
|
206
|
+
/**
|
|
207
|
+
* Omit specific keys from an object
|
|
208
|
+
* @param obj - Source object
|
|
209
|
+
* @param keys - Keys to omit
|
|
210
|
+
* @returns Object without omitted keys
|
|
211
|
+
*/
|
|
212
|
+
export declare function omit<T extends Record<string, unknown>, K extends keyof T>(obj: T, keys: K[]): Omit<T, K>;
|
|
213
|
+
/**
|
|
214
|
+
* Validate UUID format
|
|
215
|
+
* @param uuid - String to validate
|
|
216
|
+
* @returns True if valid UUID
|
|
217
|
+
*/
|
|
218
|
+
export declare function validateUUID(uuid: string): boolean;
|
|
219
|
+
/**
|
|
220
|
+
* Check if value is a non-empty string
|
|
221
|
+
* @param value - Value to check
|
|
222
|
+
* @returns True if non-empty string
|
|
223
|
+
*/
|
|
224
|
+
export declare function isNonEmptyString(value: unknown): value is string;
|
|
225
|
+
/**
|
|
226
|
+
* Check if value is a positive number
|
|
227
|
+
* @param value - Value to check
|
|
228
|
+
* @returns True if positive number
|
|
229
|
+
*/
|
|
230
|
+
export declare function isPositiveNumber(value: unknown): value is number;
|
|
231
|
+
/**
|
|
232
|
+
* Check if value is in range
|
|
233
|
+
* @param value - Value to check
|
|
234
|
+
* @param min - Minimum value
|
|
235
|
+
* @param max - Maximum value
|
|
236
|
+
* @returns True if in range
|
|
237
|
+
*/
|
|
238
|
+
export declare function isInRange(value: number, min: number, max: number): boolean;
|
|
239
|
+
/**
|
|
240
|
+
* Check if value is a non-empty array
|
|
241
|
+
* @param value - Value to check
|
|
242
|
+
* @returns True if non-empty array
|
|
243
|
+
*/
|
|
244
|
+
export declare function isNonEmptyArray<T>(value: unknown): value is T[];
|
|
245
|
+
/**
|
|
246
|
+
* Check if value is a plain object
|
|
247
|
+
* @param value - Value to check
|
|
248
|
+
* @returns True if plain object
|
|
249
|
+
*/
|
|
250
|
+
export declare function isPlainObject(value: unknown): value is Record<string, unknown>;
|
|
251
|
+
/**
|
|
252
|
+
* Sanitize input string (remove special characters)
|
|
253
|
+
* @param input - Input string
|
|
254
|
+
* @returns Sanitized string
|
|
255
|
+
*/
|
|
256
|
+
export declare function sanitizeString(input: string): string;
|
|
257
|
+
/**
|
|
258
|
+
* Truncate string with ellipsis
|
|
259
|
+
* @param str - String to truncate
|
|
260
|
+
* @param maxLength - Maximum length
|
|
261
|
+
* @returns Truncated string
|
|
262
|
+
*/
|
|
263
|
+
export declare function truncateString(str: string, maxLength: number): string;
|
|
264
|
+
/**
|
|
265
|
+
* Convert string to camelCase
|
|
266
|
+
* @param str - Input string
|
|
267
|
+
* @returns camelCase string
|
|
268
|
+
*/
|
|
269
|
+
export declare function toCamelCase(str: string): string;
|
|
270
|
+
/**
|
|
271
|
+
* Convert string to PascalCase
|
|
272
|
+
* @param str - Input string
|
|
273
|
+
* @returns PascalCase string
|
|
274
|
+
*/
|
|
275
|
+
export declare function toPascalCase(str: string): string;
|
|
276
|
+
/**
|
|
277
|
+
* Convert string to snake_case
|
|
278
|
+
* @param str - Input string
|
|
279
|
+
* @returns snake_case string
|
|
280
|
+
*/
|
|
281
|
+
export declare function toSnakeCase(str: string): string;
|
|
282
|
+
/**
|
|
283
|
+
* Convert string to kebab-case
|
|
284
|
+
* @param str - Input string
|
|
285
|
+
* @returns kebab-case string
|
|
286
|
+
*/
|
|
287
|
+
export declare function toKebabCase(str: string): string;
|
|
288
|
+
/**
|
|
289
|
+
* Escape regex special characters
|
|
290
|
+
* @param str - Input string
|
|
291
|
+
* @returns Escaped string
|
|
292
|
+
*/
|
|
293
|
+
export declare function escapeRegExp(str: string): string;
|
|
294
|
+
/**
|
|
295
|
+
* Remove duplicates from array
|
|
296
|
+
* @param arr - Input array
|
|
297
|
+
* @returns Array without duplicates
|
|
298
|
+
*/
|
|
299
|
+
export declare function unique<T>(arr: T[]): T[];
|
|
300
|
+
/**
|
|
301
|
+
* Remove duplicates by key function
|
|
302
|
+
* @param arr - Input array
|
|
303
|
+
* @param keyFn - Key function
|
|
304
|
+
* @returns Array without duplicates
|
|
305
|
+
*/
|
|
306
|
+
export declare function uniqueBy<T>(arr: T[], keyFn: (item: T) => unknown): T[];
|
|
307
|
+
/**
|
|
308
|
+
* Group array by key function
|
|
309
|
+
* @param arr - Input array
|
|
310
|
+
* @param keyFn - Key function
|
|
311
|
+
* @returns Grouped object
|
|
312
|
+
*/
|
|
313
|
+
export declare function groupBy<T>(arr: T[], keyFn: (item: T) => string): Record<string, T[]>;
|
|
314
|
+
/**
|
|
315
|
+
* Partition array by predicate
|
|
316
|
+
* @param arr - Input array
|
|
317
|
+
* @param predicate - Predicate function
|
|
318
|
+
* @returns [passing, failing] arrays
|
|
319
|
+
*/
|
|
320
|
+
export declare function partition<T>(arr: T[], predicate: (item: T) => boolean): [T[], T[]];
|
|
321
|
+
/**
|
|
322
|
+
* Shuffle array (Fisher-Yates algorithm)
|
|
323
|
+
* @param arr - Input array
|
|
324
|
+
* @returns Shuffled array
|
|
325
|
+
*/
|
|
326
|
+
export declare function shuffle<T>(arr: T[]): T[];
|
|
327
|
+
/**
|
|
328
|
+
* Sample random element from array
|
|
329
|
+
* @param arr - Input array
|
|
330
|
+
* @returns Random element
|
|
331
|
+
*/
|
|
332
|
+
export declare function sample<T>(arr: T[]): T | undefined;
|
|
333
|
+
/**
|
|
334
|
+
* Split array into chunks
|
|
335
|
+
* @param arr - Input array
|
|
336
|
+
* @param size - Chunk size
|
|
337
|
+
* @returns Array of chunks
|
|
338
|
+
*/
|
|
339
|
+
export declare function chunk<T>(arr: T[], size: number): T[][];
|
|
340
|
+
/**
|
|
341
|
+
* Flatten array one level
|
|
342
|
+
* @param arr - Input array
|
|
343
|
+
* @returns Flattened array
|
|
344
|
+
*/
|
|
345
|
+
export declare function flatten<T>(arr: T[][]): T[];
|
|
346
|
+
/**
|
|
347
|
+
* Deep flatten array
|
|
348
|
+
* @param arr - Input array
|
|
349
|
+
* @returns Deeply flattened array
|
|
350
|
+
*/
|
|
351
|
+
export declare function deepFlatten<T>(arr: unknown[]): T[];
|
|
352
|
+
/**
|
|
353
|
+
* Sleep for specified milliseconds
|
|
354
|
+
* @param ms - Milliseconds to sleep
|
|
355
|
+
* @returns Promise that resolves after ms
|
|
356
|
+
*/
|
|
357
|
+
export declare function sleep(ms: number): Promise<void>;
|
|
358
|
+
/**
|
|
359
|
+
* Create a timeout promise
|
|
360
|
+
* @param ms - Timeout in milliseconds
|
|
361
|
+
* @param message - Error message
|
|
362
|
+
* @returns Promise that rejects after ms
|
|
363
|
+
*/
|
|
364
|
+
export declare function createTimeoutPromise(ms: number, message?: string): Promise<never>;
|
|
365
|
+
/**
|
|
366
|
+
* Wrap promise with timeout
|
|
367
|
+
* @param promise - Promise to wrap
|
|
368
|
+
* @param ms - Timeout in milliseconds
|
|
369
|
+
* @returns Promise with timeout
|
|
370
|
+
*/
|
|
371
|
+
export declare function withTimeout<T>(promise: Promise<T>, ms: number): Promise<T>;
|
|
372
|
+
/**
|
|
373
|
+
* Retry a function with exponential backoff
|
|
374
|
+
* @param fn - Function to retry
|
|
375
|
+
* @param maxRetries - Maximum retries
|
|
376
|
+
* @param delayMs - Initial delay
|
|
377
|
+
* @returns Function result
|
|
378
|
+
*/
|
|
379
|
+
export declare function retry<T>(fn: () => Promise<T>, maxRetries?: number, delayMs?: number): Promise<T>;
|
|
380
|
+
/**
|
|
381
|
+
* Debounce a function
|
|
382
|
+
* @param fn - Function to debounce
|
|
383
|
+
* @param ms - Debounce delay
|
|
384
|
+
* @returns Debounced function
|
|
385
|
+
*/
|
|
386
|
+
export declare function debounce<T extends (...args: unknown[]) => unknown>(fn: T, ms: number): (...args: Parameters<T>) => void;
|
|
387
|
+
/**
|
|
388
|
+
* Throttle a function
|
|
389
|
+
* @param fn - Function to throttle
|
|
390
|
+
* @param ms - Throttle interval
|
|
391
|
+
* @returns Throttled function
|
|
392
|
+
*/
|
|
393
|
+
export declare function throttle<T extends (...args: unknown[]) => unknown>(fn: T, ms: number): (...args: Parameters<T>) => void;
|
|
394
|
+
/**
|
|
395
|
+
* Try-catch wrapper for synchronous functions
|
|
396
|
+
* @param fn - Function to wrap
|
|
397
|
+
* @returns Result object
|
|
398
|
+
*/
|
|
399
|
+
export declare function tryCatch<T, E = Error>(fn: () => T): Result<T, E>;
|
|
400
|
+
/**
|
|
401
|
+
* Try-catch wrapper for async functions
|
|
402
|
+
* @param fn - Async function to wrap
|
|
403
|
+
* @returns Result object
|
|
404
|
+
*/
|
|
405
|
+
export declare function tryCatchAsync<T, E = Error>(fn: () => Promise<T>): Promise<Result<T, E>>;
|
|
406
|
+
/**
|
|
407
|
+
* Create enhanced error with context
|
|
408
|
+
* @param message - Error message
|
|
409
|
+
* @param context - Error context
|
|
410
|
+
* @returns Enhanced error
|
|
411
|
+
*/
|
|
412
|
+
export declare function createError(message: string, context?: Record<string, unknown>): Error;
|
|
413
|
+
/** Result type */
|
|
414
|
+
export type Result<T, E = Error> = {
|
|
415
|
+
success: true;
|
|
416
|
+
data: T;
|
|
417
|
+
} | {
|
|
418
|
+
success: false;
|
|
419
|
+
error: E;
|
|
420
|
+
};
|
|
421
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH;;;GAGG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAInC;AAED;;;GAGG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAErC;AAED;;;GAGG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAMD;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAErE;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED;;;;;;GAMG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAE5D;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAG/D;AAMD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAEnD;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE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