@backendkit-labs/auto-learning 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.
- package/dist/index-DnQ9xssn.d.cts +208 -0
- package/dist/index-DnQ9xssn.d.ts +208 -0
- package/dist/index.cjs +857 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +84 -0
- package/dist/index.d.ts +84 -0
- package/dist/index.js +822 -0
- package/dist/index.js.map +1 -0
- package/dist/nestjs/index.cjs +837 -0
- package/dist/nestjs/index.cjs.map +1 -0
- package/dist/nestjs/index.d.cts +3 -0
- package/dist/nestjs/index.d.ts +3 -0
- package/dist/nestjs/index.js +812 -0
- package/dist/nestjs/index.js.map +1 -0
- package/package.json +96 -0
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { LoggerService, DynamicModule } from '@nestjs/common';
|
|
2
|
+
import { Result } from '@backendkit-labs/result';
|
|
3
|
+
|
|
4
|
+
type EndpointPattern = {
|
|
5
|
+
method: string;
|
|
6
|
+
path: string;
|
|
7
|
+
statusCode: number;
|
|
8
|
+
durationMs: number;
|
|
9
|
+
timestamp: Date;
|
|
10
|
+
correlationId?: string;
|
|
11
|
+
metadata?: Record<string, unknown>;
|
|
12
|
+
};
|
|
13
|
+
type AggregatePattern = {
|
|
14
|
+
method: string;
|
|
15
|
+
path: string;
|
|
16
|
+
windowStart: Date;
|
|
17
|
+
windowEnd: Date;
|
|
18
|
+
count: number;
|
|
19
|
+
avgDurationMs: number;
|
|
20
|
+
p50Ms: number;
|
|
21
|
+
p95Ms: number;
|
|
22
|
+
p99Ms: number;
|
|
23
|
+
errorCount: number;
|
|
24
|
+
errorRate: number;
|
|
25
|
+
};
|
|
26
|
+
type AnomalySeverity = 'low' | 'medium' | 'high' | 'critical';
|
|
27
|
+
type AnomalyReport$1 = {
|
|
28
|
+
id: string;
|
|
29
|
+
endpoint: string;
|
|
30
|
+
method: string;
|
|
31
|
+
severity: AnomalySeverity;
|
|
32
|
+
metric: 'latency' | 'error_rate' | 'frequency' | 'unknown_endpoint';
|
|
33
|
+
expectedValue: number;
|
|
34
|
+
actualValue: number;
|
|
35
|
+
deviation: number;
|
|
36
|
+
detectedAt: Date;
|
|
37
|
+
};
|
|
38
|
+
type TunableConfig = {
|
|
39
|
+
timeoutMs: number;
|
|
40
|
+
maxRetries: number;
|
|
41
|
+
circuitBreakerThreshold: number;
|
|
42
|
+
circuitBreakerHalfOpenAfterMs: number;
|
|
43
|
+
bulkheadMaxConcurrent: number;
|
|
44
|
+
};
|
|
45
|
+
type LearningCycleEvent = {
|
|
46
|
+
cycleId: string;
|
|
47
|
+
timestamp: Date;
|
|
48
|
+
patternsProcessed: number;
|
|
49
|
+
anomaliesFound: number;
|
|
50
|
+
configChanges: Partial<TunableConfig>;
|
|
51
|
+
durationMs: number;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
type LearningErrorTag = 'STORAGE_ERROR' | 'INSUFFICIENT_DATA' | 'INVALID_CONFIG' | 'ANOMALY_DETECTION_FAILED' | 'FEEDBACK_LOOP_ALREADY_RUNNING' | 'FEEDBACK_LOOP_NOT_RUNNING';
|
|
55
|
+
type LearningError = {
|
|
56
|
+
readonly tag: LearningErrorTag;
|
|
57
|
+
readonly message: string;
|
|
58
|
+
readonly cause?: unknown;
|
|
59
|
+
readonly required?: number;
|
|
60
|
+
readonly actual?: number;
|
|
61
|
+
readonly key?: string;
|
|
62
|
+
readonly value?: unknown;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
interface IPatternRegistry {
|
|
66
|
+
record(pattern: EndpointPattern): Result<void, LearningError>;
|
|
67
|
+
getAggregates(windowMinutes: number): Result<AggregatePattern[], LearningError>;
|
|
68
|
+
getHistory(endpoint: string, method: string, limit: number): Result<EndpointPattern[], LearningError>;
|
|
69
|
+
getStats(): Result<RegistryStats, LearningError>;
|
|
70
|
+
}
|
|
71
|
+
type RegistryStats = {
|
|
72
|
+
totalPatterns: number;
|
|
73
|
+
uniqueEndpoints: number;
|
|
74
|
+
oldestPattern: Date;
|
|
75
|
+
newestPattern: Date;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
interface StorageAdapter {
|
|
79
|
+
savePattern(pattern: EndpointPattern): Result<void, LearningError>;
|
|
80
|
+
getPatterns(windowStart: Date, windowEnd: Date): Result<EndpointPattern[], LearningError>;
|
|
81
|
+
getAggregates(windowMinutes: number): Result<AggregatePattern[], LearningError>;
|
|
82
|
+
saveAnomaly(report: AnomalyReport$1): Result<void, LearningError>;
|
|
83
|
+
getRecentAnomalies(limit: number): Result<AnomalyReport$1[], LearningError>;
|
|
84
|
+
saveConfig(config: TunableConfig): Result<void, LearningError>;
|
|
85
|
+
loadConfig(): Result<TunableConfig | null, LearningError>;
|
|
86
|
+
saveCycleEvent(event: LearningCycleEvent): Result<void, LearningError>;
|
|
87
|
+
getLastCycleTime(): Result<Date | null, LearningError>;
|
|
88
|
+
prune(before: Date): Result<number, LearningError>;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
interface ObservabilityAdapter {
|
|
92
|
+
info(msg: string, meta?: Record<string, unknown>): void;
|
|
93
|
+
warn(msg: string, meta?: Record<string, unknown>): void;
|
|
94
|
+
error(msg: string, meta?: Record<string, unknown>): void;
|
|
95
|
+
debug(msg: string, meta?: Record<string, unknown>): void;
|
|
96
|
+
incrementMetric(name: string, value?: number, tags?: Record<string, string>): void;
|
|
97
|
+
gaugeMetric(name: string, value: number, tags?: Record<string, string>): void;
|
|
98
|
+
histogramMetric(name: string, value: number, tags?: Record<string, string>): void;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
interface IAnomalyDetector {
|
|
102
|
+
analyze(current: EndpointPattern, baseline: AggregatePattern): Result<AnomalyReport | null, LearningError>;
|
|
103
|
+
batchAnalyze(windowPatterns: EndpointPattern[], baselines: AggregatePattern[]): Result<AnomalyReport[], LearningError>;
|
|
104
|
+
}
|
|
105
|
+
type AnomalyReport = {
|
|
106
|
+
id: string;
|
|
107
|
+
endpoint: string;
|
|
108
|
+
method: string;
|
|
109
|
+
severity: AnomalySeverity;
|
|
110
|
+
metric: 'latency' | 'error_rate' | 'frequency' | 'unknown_endpoint';
|
|
111
|
+
expectedValue: number;
|
|
112
|
+
actualValue: number;
|
|
113
|
+
deviation: number;
|
|
114
|
+
detectedAt: Date;
|
|
115
|
+
};
|
|
116
|
+
type AnomalyDetectorConfig = {
|
|
117
|
+
latencyStdDevThreshold: number;
|
|
118
|
+
errorRateThreshold: number;
|
|
119
|
+
frequencyDeviationThreshold: number;
|
|
120
|
+
enableUnknownEndpointDetection: boolean;
|
|
121
|
+
};
|
|
122
|
+
declare const DEFAULT_ANOMALY_CONFIG: AnomalyDetectorConfig;
|
|
123
|
+
|
|
124
|
+
interface IConfigTuner {
|
|
125
|
+
getCurrentConfig(): TunableConfig;
|
|
126
|
+
tune(aggregates: AggregatePattern[], anomalies: AnomalyReport$1[]): Result<TunableConfig, LearningError>;
|
|
127
|
+
reset(): Result<TunableConfig, LearningError>;
|
|
128
|
+
onConfigChange(callback: (config: TunableConfig) => void): void;
|
|
129
|
+
}
|
|
130
|
+
type ConfigTunerConfig = {
|
|
131
|
+
minTimeoutMs: number;
|
|
132
|
+
maxTimeoutMs: number;
|
|
133
|
+
smoothingFactor: number;
|
|
134
|
+
adjustmentStepMs: number;
|
|
135
|
+
};
|
|
136
|
+
declare const DEFAULT_TUNER_CONFIG: ConfigTunerConfig;
|
|
137
|
+
|
|
138
|
+
interface IFeedbackLoop {
|
|
139
|
+
start(intervalMs?: number): void;
|
|
140
|
+
stop(): void;
|
|
141
|
+
isRunning(): boolean;
|
|
142
|
+
runOnce(): Promise<Result<LearningCycleEvent, LearningError>>;
|
|
143
|
+
onCycle(callback: (event: LearningCycleEvent) => void): void;
|
|
144
|
+
}
|
|
145
|
+
type FeedbackLoopConfig = {
|
|
146
|
+
defaultIntervalMs: number;
|
|
147
|
+
windowSizeMinutes: number;
|
|
148
|
+
minSamplesBeforeTuning: number;
|
|
149
|
+
cooldownBetweenChangesMs: number;
|
|
150
|
+
};
|
|
151
|
+
declare const DEFAULT_LOOP_CONFIG: FeedbackLoopConfig;
|
|
152
|
+
|
|
153
|
+
type AutoLearningCoreOptions = {
|
|
154
|
+
storage?: StorageAdapter;
|
|
155
|
+
observability?: ObservabilityAdapter;
|
|
156
|
+
anomalyConfig?: Partial<AnomalyDetectorConfig>;
|
|
157
|
+
tunerConfig?: Partial<ConfigTunerConfig>;
|
|
158
|
+
loopConfig?: Partial<FeedbackLoopConfig>;
|
|
159
|
+
};
|
|
160
|
+
declare class AutoLearningCore {
|
|
161
|
+
readonly patternRegistry: IPatternRegistry;
|
|
162
|
+
readonly anomalyDetector: IAnomalyDetector;
|
|
163
|
+
readonly configTuner: IConfigTuner;
|
|
164
|
+
readonly feedbackLoop: IFeedbackLoop;
|
|
165
|
+
readonly storage: StorageAdapter;
|
|
166
|
+
readonly observability: ObservabilityAdapter;
|
|
167
|
+
private constructor();
|
|
168
|
+
static create(options?: AutoLearningCoreOptions): AutoLearningCore;
|
|
169
|
+
recordPattern(pattern: EndpointPattern): Result<void, LearningError>;
|
|
170
|
+
getCurrentConfig(): TunableConfig;
|
|
171
|
+
startFeedbackLoop(intervalMs?: number): void;
|
|
172
|
+
stopFeedbackLoop(): void;
|
|
173
|
+
isFeedbackLoopRunning(): boolean;
|
|
174
|
+
runOnce(): Promise<Result<LearningCycleEvent, LearningError>>;
|
|
175
|
+
onConfigChange(callback: (config: TunableConfig) => void): void;
|
|
176
|
+
onCycle(callback: (event: LearningCycleEvent) => void): void;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
type AutoLearningModuleOptions = {
|
|
180
|
+
intervalMs?: number;
|
|
181
|
+
storage?: 'memory' | 'redis' | 'sql';
|
|
182
|
+
redisUrl?: string;
|
|
183
|
+
observability?: {
|
|
184
|
+
logger?: LoggerService;
|
|
185
|
+
metrics?: {
|
|
186
|
+
increment?: (name: string, value?: number, tags?: Record<string, string>) => void;
|
|
187
|
+
gauge?: (name: string, value: number, tags?: Record<string, string>) => void;
|
|
188
|
+
histogram?: (name: string, value: number, tags?: Record<string, string>) => void;
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
coreOptions?: Omit<AutoLearningCoreOptions, 'storage' | 'observability'>;
|
|
192
|
+
};
|
|
193
|
+
declare class AutoLearningModule {
|
|
194
|
+
static forRoot(options?: AutoLearningModuleOptions): DynamicModule;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
type AutoLearnOptions = {
|
|
198
|
+
trackParams?: boolean;
|
|
199
|
+
trackBody?: boolean;
|
|
200
|
+
customMetadata?: (req: any) => Record<string, unknown>;
|
|
201
|
+
};
|
|
202
|
+
declare const AutoLearn: (options?: AutoLearnOptions) => MethodDecorator;
|
|
203
|
+
|
|
204
|
+
declare const AUTO_LEARNING_OPTIONS: unique symbol;
|
|
205
|
+
declare const AUTO_LEARNING_INSTANCE: unique symbol;
|
|
206
|
+
declare const AUTO_LEARN_METADATA = "auto_learn_metadata";
|
|
207
|
+
|
|
208
|
+
export { type AggregatePattern as A, type ConfigTunerConfig as C, DEFAULT_ANOMALY_CONFIG as D, type EndpointPattern as E, type FeedbackLoopConfig as F, type IPatternRegistry as I, type LearningError as L, type ObservabilityAdapter as O, type RegistryStats as R, type StorageAdapter as S, type TunableConfig as T, type IAnomalyDetector as a, type AnomalyDetectorConfig as b, type AnomalyReport as c, type IConfigTuner as d, type AnomalyReport$1 as e, type IFeedbackLoop as f, type LearningCycleEvent as g, AUTO_LEARNING_INSTANCE as h, AUTO_LEARNING_OPTIONS as i, AUTO_LEARN_METADATA as j, type AnomalySeverity as k, AutoLearn as l, type AutoLearnOptions as m, AutoLearningCore as n, type AutoLearningCoreOptions as o, AutoLearningModule as p, type AutoLearningModuleOptions as q, DEFAULT_LOOP_CONFIG as r, DEFAULT_TUNER_CONFIG as s };
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { LoggerService, DynamicModule } from '@nestjs/common';
|
|
2
|
+
import { Result } from '@backendkit-labs/result';
|
|
3
|
+
|
|
4
|
+
type EndpointPattern = {
|
|
5
|
+
method: string;
|
|
6
|
+
path: string;
|
|
7
|
+
statusCode: number;
|
|
8
|
+
durationMs: number;
|
|
9
|
+
timestamp: Date;
|
|
10
|
+
correlationId?: string;
|
|
11
|
+
metadata?: Record<string, unknown>;
|
|
12
|
+
};
|
|
13
|
+
type AggregatePattern = {
|
|
14
|
+
method: string;
|
|
15
|
+
path: string;
|
|
16
|
+
windowStart: Date;
|
|
17
|
+
windowEnd: Date;
|
|
18
|
+
count: number;
|
|
19
|
+
avgDurationMs: number;
|
|
20
|
+
p50Ms: number;
|
|
21
|
+
p95Ms: number;
|
|
22
|
+
p99Ms: number;
|
|
23
|
+
errorCount: number;
|
|
24
|
+
errorRate: number;
|
|
25
|
+
};
|
|
26
|
+
type AnomalySeverity = 'low' | 'medium' | 'high' | 'critical';
|
|
27
|
+
type AnomalyReport$1 = {
|
|
28
|
+
id: string;
|
|
29
|
+
endpoint: string;
|
|
30
|
+
method: string;
|
|
31
|
+
severity: AnomalySeverity;
|
|
32
|
+
metric: 'latency' | 'error_rate' | 'frequency' | 'unknown_endpoint';
|
|
33
|
+
expectedValue: number;
|
|
34
|
+
actualValue: number;
|
|
35
|
+
deviation: number;
|
|
36
|
+
detectedAt: Date;
|
|
37
|
+
};
|
|
38
|
+
type TunableConfig = {
|
|
39
|
+
timeoutMs: number;
|
|
40
|
+
maxRetries: number;
|
|
41
|
+
circuitBreakerThreshold: number;
|
|
42
|
+
circuitBreakerHalfOpenAfterMs: number;
|
|
43
|
+
bulkheadMaxConcurrent: number;
|
|
44
|
+
};
|
|
45
|
+
type LearningCycleEvent = {
|
|
46
|
+
cycleId: string;
|
|
47
|
+
timestamp: Date;
|
|
48
|
+
patternsProcessed: number;
|
|
49
|
+
anomaliesFound: number;
|
|
50
|
+
configChanges: Partial<TunableConfig>;
|
|
51
|
+
durationMs: number;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
type LearningErrorTag = 'STORAGE_ERROR' | 'INSUFFICIENT_DATA' | 'INVALID_CONFIG' | 'ANOMALY_DETECTION_FAILED' | 'FEEDBACK_LOOP_ALREADY_RUNNING' | 'FEEDBACK_LOOP_NOT_RUNNING';
|
|
55
|
+
type LearningError = {
|
|
56
|
+
readonly tag: LearningErrorTag;
|
|
57
|
+
readonly message: string;
|
|
58
|
+
readonly cause?: unknown;
|
|
59
|
+
readonly required?: number;
|
|
60
|
+
readonly actual?: number;
|
|
61
|
+
readonly key?: string;
|
|
62
|
+
readonly value?: unknown;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
interface IPatternRegistry {
|
|
66
|
+
record(pattern: EndpointPattern): Result<void, LearningError>;
|
|
67
|
+
getAggregates(windowMinutes: number): Result<AggregatePattern[], LearningError>;
|
|
68
|
+
getHistory(endpoint: string, method: string, limit: number): Result<EndpointPattern[], LearningError>;
|
|
69
|
+
getStats(): Result<RegistryStats, LearningError>;
|
|
70
|
+
}
|
|
71
|
+
type RegistryStats = {
|
|
72
|
+
totalPatterns: number;
|
|
73
|
+
uniqueEndpoints: number;
|
|
74
|
+
oldestPattern: Date;
|
|
75
|
+
newestPattern: Date;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
interface StorageAdapter {
|
|
79
|
+
savePattern(pattern: EndpointPattern): Result<void, LearningError>;
|
|
80
|
+
getPatterns(windowStart: Date, windowEnd: Date): Result<EndpointPattern[], LearningError>;
|
|
81
|
+
getAggregates(windowMinutes: number): Result<AggregatePattern[], LearningError>;
|
|
82
|
+
saveAnomaly(report: AnomalyReport$1): Result<void, LearningError>;
|
|
83
|
+
getRecentAnomalies(limit: number): Result<AnomalyReport$1[], LearningError>;
|
|
84
|
+
saveConfig(config: TunableConfig): Result<void, LearningError>;
|
|
85
|
+
loadConfig(): Result<TunableConfig | null, LearningError>;
|
|
86
|
+
saveCycleEvent(event: LearningCycleEvent): Result<void, LearningError>;
|
|
87
|
+
getLastCycleTime(): Result<Date | null, LearningError>;
|
|
88
|
+
prune(before: Date): Result<number, LearningError>;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
interface ObservabilityAdapter {
|
|
92
|
+
info(msg: string, meta?: Record<string, unknown>): void;
|
|
93
|
+
warn(msg: string, meta?: Record<string, unknown>): void;
|
|
94
|
+
error(msg: string, meta?: Record<string, unknown>): void;
|
|
95
|
+
debug(msg: string, meta?: Record<string, unknown>): void;
|
|
96
|
+
incrementMetric(name: string, value?: number, tags?: Record<string, string>): void;
|
|
97
|
+
gaugeMetric(name: string, value: number, tags?: Record<string, string>): void;
|
|
98
|
+
histogramMetric(name: string, value: number, tags?: Record<string, string>): void;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
interface IAnomalyDetector {
|
|
102
|
+
analyze(current: EndpointPattern, baseline: AggregatePattern): Result<AnomalyReport | null, LearningError>;
|
|
103
|
+
batchAnalyze(windowPatterns: EndpointPattern[], baselines: AggregatePattern[]): Result<AnomalyReport[], LearningError>;
|
|
104
|
+
}
|
|
105
|
+
type AnomalyReport = {
|
|
106
|
+
id: string;
|
|
107
|
+
endpoint: string;
|
|
108
|
+
method: string;
|
|
109
|
+
severity: AnomalySeverity;
|
|
110
|
+
metric: 'latency' | 'error_rate' | 'frequency' | 'unknown_endpoint';
|
|
111
|
+
expectedValue: number;
|
|
112
|
+
actualValue: number;
|
|
113
|
+
deviation: number;
|
|
114
|
+
detectedAt: Date;
|
|
115
|
+
};
|
|
116
|
+
type AnomalyDetectorConfig = {
|
|
117
|
+
latencyStdDevThreshold: number;
|
|
118
|
+
errorRateThreshold: number;
|
|
119
|
+
frequencyDeviationThreshold: number;
|
|
120
|
+
enableUnknownEndpointDetection: boolean;
|
|
121
|
+
};
|
|
122
|
+
declare const DEFAULT_ANOMALY_CONFIG: AnomalyDetectorConfig;
|
|
123
|
+
|
|
124
|
+
interface IConfigTuner {
|
|
125
|
+
getCurrentConfig(): TunableConfig;
|
|
126
|
+
tune(aggregates: AggregatePattern[], anomalies: AnomalyReport$1[]): Result<TunableConfig, LearningError>;
|
|
127
|
+
reset(): Result<TunableConfig, LearningError>;
|
|
128
|
+
onConfigChange(callback: (config: TunableConfig) => void): void;
|
|
129
|
+
}
|
|
130
|
+
type ConfigTunerConfig = {
|
|
131
|
+
minTimeoutMs: number;
|
|
132
|
+
maxTimeoutMs: number;
|
|
133
|
+
smoothingFactor: number;
|
|
134
|
+
adjustmentStepMs: number;
|
|
135
|
+
};
|
|
136
|
+
declare const DEFAULT_TUNER_CONFIG: ConfigTunerConfig;
|
|
137
|
+
|
|
138
|
+
interface IFeedbackLoop {
|
|
139
|
+
start(intervalMs?: number): void;
|
|
140
|
+
stop(): void;
|
|
141
|
+
isRunning(): boolean;
|
|
142
|
+
runOnce(): Promise<Result<LearningCycleEvent, LearningError>>;
|
|
143
|
+
onCycle(callback: (event: LearningCycleEvent) => void): void;
|
|
144
|
+
}
|
|
145
|
+
type FeedbackLoopConfig = {
|
|
146
|
+
defaultIntervalMs: number;
|
|
147
|
+
windowSizeMinutes: number;
|
|
148
|
+
minSamplesBeforeTuning: number;
|
|
149
|
+
cooldownBetweenChangesMs: number;
|
|
150
|
+
};
|
|
151
|
+
declare const DEFAULT_LOOP_CONFIG: FeedbackLoopConfig;
|
|
152
|
+
|
|
153
|
+
type AutoLearningCoreOptions = {
|
|
154
|
+
storage?: StorageAdapter;
|
|
155
|
+
observability?: ObservabilityAdapter;
|
|
156
|
+
anomalyConfig?: Partial<AnomalyDetectorConfig>;
|
|
157
|
+
tunerConfig?: Partial<ConfigTunerConfig>;
|
|
158
|
+
loopConfig?: Partial<FeedbackLoopConfig>;
|
|
159
|
+
};
|
|
160
|
+
declare class AutoLearningCore {
|
|
161
|
+
readonly patternRegistry: IPatternRegistry;
|
|
162
|
+
readonly anomalyDetector: IAnomalyDetector;
|
|
163
|
+
readonly configTuner: IConfigTuner;
|
|
164
|
+
readonly feedbackLoop: IFeedbackLoop;
|
|
165
|
+
readonly storage: StorageAdapter;
|
|
166
|
+
readonly observability: ObservabilityAdapter;
|
|
167
|
+
private constructor();
|
|
168
|
+
static create(options?: AutoLearningCoreOptions): AutoLearningCore;
|
|
169
|
+
recordPattern(pattern: EndpointPattern): Result<void, LearningError>;
|
|
170
|
+
getCurrentConfig(): TunableConfig;
|
|
171
|
+
startFeedbackLoop(intervalMs?: number): void;
|
|
172
|
+
stopFeedbackLoop(): void;
|
|
173
|
+
isFeedbackLoopRunning(): boolean;
|
|
174
|
+
runOnce(): Promise<Result<LearningCycleEvent, LearningError>>;
|
|
175
|
+
onConfigChange(callback: (config: TunableConfig) => void): void;
|
|
176
|
+
onCycle(callback: (event: LearningCycleEvent) => void): void;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
type AutoLearningModuleOptions = {
|
|
180
|
+
intervalMs?: number;
|
|
181
|
+
storage?: 'memory' | 'redis' | 'sql';
|
|
182
|
+
redisUrl?: string;
|
|
183
|
+
observability?: {
|
|
184
|
+
logger?: LoggerService;
|
|
185
|
+
metrics?: {
|
|
186
|
+
increment?: (name: string, value?: number, tags?: Record<string, string>) => void;
|
|
187
|
+
gauge?: (name: string, value: number, tags?: Record<string, string>) => void;
|
|
188
|
+
histogram?: (name: string, value: number, tags?: Record<string, string>) => void;
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
coreOptions?: Omit<AutoLearningCoreOptions, 'storage' | 'observability'>;
|
|
192
|
+
};
|
|
193
|
+
declare class AutoLearningModule {
|
|
194
|
+
static forRoot(options?: AutoLearningModuleOptions): DynamicModule;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
type AutoLearnOptions = {
|
|
198
|
+
trackParams?: boolean;
|
|
199
|
+
trackBody?: boolean;
|
|
200
|
+
customMetadata?: (req: any) => Record<string, unknown>;
|
|
201
|
+
};
|
|
202
|
+
declare const AutoLearn: (options?: AutoLearnOptions) => MethodDecorator;
|
|
203
|
+
|
|
204
|
+
declare const AUTO_LEARNING_OPTIONS: unique symbol;
|
|
205
|
+
declare const AUTO_LEARNING_INSTANCE: unique symbol;
|
|
206
|
+
declare const AUTO_LEARN_METADATA = "auto_learn_metadata";
|
|
207
|
+
|
|
208
|
+
export { type AggregatePattern as A, type ConfigTunerConfig as C, DEFAULT_ANOMALY_CONFIG as D, type EndpointPattern as E, type FeedbackLoopConfig as F, type IPatternRegistry as I, type LearningError as L, type ObservabilityAdapter as O, type RegistryStats as R, type StorageAdapter as S, type TunableConfig as T, type IAnomalyDetector as a, type AnomalyDetectorConfig as b, type AnomalyReport as c, type IConfigTuner as d, type AnomalyReport$1 as e, type IFeedbackLoop as f, type LearningCycleEvent as g, AUTO_LEARNING_INSTANCE as h, AUTO_LEARNING_OPTIONS as i, AUTO_LEARN_METADATA as j, type AnomalySeverity as k, AutoLearn as l, type AutoLearnOptions as m, AutoLearningCore as n, type AutoLearningCoreOptions as o, AutoLearningModule as p, type AutoLearningModuleOptions as q, DEFAULT_LOOP_CONFIG as r, DEFAULT_TUNER_CONFIG as s };
|