@junando/core 0.15.1 → 0.16.1
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.d.ts +45 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +61 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -213,6 +213,11 @@ export declare enum RuleEvaluationPhase {
|
|
|
213
213
|
PreLlm = "pre-llm",
|
|
214
214
|
PostLlm = "post-llm"
|
|
215
215
|
}
|
|
216
|
+
/** Notifier backend a logical channel resolves to */
|
|
217
|
+
export declare enum ChannelType {
|
|
218
|
+
Slack = "slack",
|
|
219
|
+
Teams = "teams"
|
|
220
|
+
}
|
|
216
221
|
export interface RuleCondition {
|
|
217
222
|
serviceName?: string;
|
|
218
223
|
alertType?: AlertType;
|
|
@@ -389,9 +394,26 @@ export declare const RuleSectionSchema: z.ZodObject<{
|
|
|
389
394
|
requiresRollback: z.ZodOptional<z.ZodBoolean>;
|
|
390
395
|
}, z.core.$strip>>>;
|
|
391
396
|
}, z.core.$strip>;
|
|
397
|
+
export interface SlackChannelConfig {
|
|
398
|
+
type: ChannelType.Slack;
|
|
399
|
+
channel: string;
|
|
400
|
+
}
|
|
401
|
+
export interface TeamsChannelConfig {
|
|
402
|
+
type: ChannelType.Teams;
|
|
403
|
+
webhookUrlEnv: string;
|
|
404
|
+
}
|
|
405
|
+
export type ChannelConfig = SlackChannelConfig | TeamsChannelConfig;
|
|
406
|
+
export declare const ChannelConfigSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
407
|
+
type: z.ZodLiteral<ChannelType.Slack>;
|
|
408
|
+
channel: z.ZodString;
|
|
409
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
410
|
+
type: z.ZodLiteral<ChannelType.Teams>;
|
|
411
|
+
webhookUrlEnv: z.ZodString;
|
|
412
|
+
}, z.core.$strip>], "type">;
|
|
392
413
|
export interface RuleConfiguration {
|
|
393
414
|
[RuleEvaluationPhase.PreLlm]: RuleSection;
|
|
394
415
|
[RuleEvaluationPhase.PostLlm]: RuleSection;
|
|
416
|
+
channels: Record<string, ChannelConfig>;
|
|
395
417
|
}
|
|
396
418
|
export declare const RuleConfigurationSchema: z.ZodObject<{
|
|
397
419
|
"pre-llm": z.ZodObject<{
|
|
@@ -492,11 +514,19 @@ export declare const RuleConfigurationSchema: z.ZodObject<{
|
|
|
492
514
|
requiresRollback: z.ZodOptional<z.ZodBoolean>;
|
|
493
515
|
}, z.core.$strip>>>;
|
|
494
516
|
}, z.core.$strip>;
|
|
517
|
+
channels: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
518
|
+
type: z.ZodLiteral<ChannelType.Slack>;
|
|
519
|
+
channel: z.ZodString;
|
|
520
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
521
|
+
type: z.ZodLiteral<ChannelType.Teams>;
|
|
522
|
+
webhookUrlEnv: z.ZodString;
|
|
523
|
+
}, z.core.$strip>], "type">>>;
|
|
495
524
|
}, z.core.$strip>;
|
|
496
525
|
export type ValidatedRuleCondition = z.infer<typeof RuleConditionSchema>;
|
|
497
526
|
export type ValidatedRuleAction = z.infer<typeof RuleActionSchema>;
|
|
498
527
|
export type ValidatedRule = z.infer<typeof RuleSchema>;
|
|
499
528
|
export type ValidatedRuleSection = z.infer<typeof RuleSectionSchema>;
|
|
529
|
+
export type ValidatedChannelConfig = z.infer<typeof ChannelConfigSchema>;
|
|
500
530
|
export type ValidatedRuleConfiguration = z.infer<typeof RuleConfigurationSchema>;
|
|
501
531
|
//#endregion
|
|
502
532
|
//#region src/domain/entities/traceability.d.ts
|
|
@@ -671,6 +701,14 @@ interface RollbackActionRequest {
|
|
|
671
701
|
endpointPath: string;
|
|
672
702
|
alertType: AlertType;
|
|
673
703
|
urgencyLevel?: 'low' | 'medium' | 'high' | 'critical';
|
|
704
|
+
/**
|
|
705
|
+
* The LLM analysis's probable_cause, carried from the Slack button value
|
|
706
|
+
* (truncated — see slack.adapter.ts) so a rollback handler can record WHY
|
|
707
|
+
* the model recommended the action alongside the action itself, for
|
|
708
|
+
* post-incident review. Absent if the button was rendered before this
|
|
709
|
+
* field existed, or if parsing/validation dropped it.
|
|
710
|
+
*/
|
|
711
|
+
probableCause?: string;
|
|
674
712
|
triggeredBy: {
|
|
675
713
|
id?: string;
|
|
676
714
|
username?: string;
|
|
@@ -1121,11 +1159,17 @@ export declare class ChannelRegistry {
|
|
|
1121
1159
|
*
|
|
1122
1160
|
* When `config.rulesConfigPath` is set:
|
|
1123
1161
|
* - Reads and validates the rules YAML config
|
|
1124
|
-
* -
|
|
1162
|
+
* - Builds a ChannelRegistry from its `channels:` section, with the default
|
|
1163
|
+
* notifier as fallback
|
|
1125
1164
|
* - Wraps the default notifier with a RoutingNotifier for multi-channel dispatch
|
|
1126
1165
|
*
|
|
1127
1166
|
* When `config.rulesConfigPath` is NOT set:
|
|
1128
1167
|
* - Returns the default notifier directly (backward-compatible)
|
|
1168
|
+
*
|
|
1169
|
+
* @throws {Error} at startup if a rule's route/escalate action references a
|
|
1170
|
+
* channel with no matching entry under `channels:` — an operator must fix
|
|
1171
|
+
* the rules config rather than have the alert silently fall back to the
|
|
1172
|
+
* default channel mid-incident.
|
|
1129
1173
|
*/
|
|
1130
1174
|
export declare function createNotifier(config: Config): INotifier;
|
|
1131
1175
|
/**
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/shared/constants.ts","../src/domain/entities/alert.ts","../src/domain/entities/cluster.ts","../src/domain/entities/incident.ts","../src/domain/entities/rule.ts","../src/domain/entities/traceability.ts","../src/domain/value-objects/fingerprint.ts","../src/domain/ports/index.ts","../src/domain/services/clustering.service.ts","../src/application/dtos/normalize-payload.ts","../src/shared/logger/enums.ts","../src/shared/logger/wide-event-builder.ts","../src/shared/logger/index.ts","../src/application/use-cases/process-incident.use-case.ts","../src/infrastructure/dedup/redis-dedup.adapter.ts","../src/infrastructure/dedup/dynamodb-dedup.adapter.ts","../src/infrastructure/indexer/opensearch.adapter.ts","../src/infrastructure/llm/bedrock.provider.ts","../src/infrastructure/llm/claude.provider.ts","../src/infrastructure/llm/openrouter.provider.ts","../src/infrastructure/llm/factory.ts","../src/infrastructure/llm/gemini.provider.ts","../src/infrastructure/llm/mock.provider.ts","../src/shared/config/index.ts","../src/infrastructure/rules/channel-registry.ts","../src/infrastructure/notifier/factory.ts","../src/infrastructure/rollback/factory.ts","../src/infrastructure/rollback/noop-rollback-action.handler.ts","../src/infrastructure/notifier/slack.adapter.ts","../src/infrastructure/notifier/teams.adapter.ts","../src/infrastructure/notifier/routing-notifier.ts","../src/infrastructure/queue/sqs.adapter.ts","../src/infrastructure/queue/sqs-lag-poller.ts","../src/infrastructure/traces/loki-trace.adapter.ts","../src/infrastructure/rules/yaml-rule-loader.ts","../src/infrastructure/rules/condition-evaluator.ts","../src/infrastructure/rules/action-dispatcher.ts","../src/infrastructure/rules/rule-engine.ts","../src/shared/factory-registry.ts","../src/shared/logger/loki-transport.ts"],"mappings":";;;;;;oBAMY;EACV;EACA;EACA;;UAGQ;WACC;WACA;WACA,UAAU,iBAAiB,WAAW;;cAG3C,mBAAmB,OAAO,WAAW;qBAmB9B,mBAAmB,gBAAgB;oBAIpC;EACV;EACA;EACA;EACA;EACA;;qBAIW,iBAAe;;;;;;qBAOf,iBAAe;;;;;qBAMf;qBAGA,cAAY;;;;qBAMZ;qBAGA;qBAGA;qBAGA,uBAAqB;;EAM3B;;qBAIM,YAAU;;;;;;qBAQV;qBACA;qBAGA;cAEP,eAAe;qBAMR,eAAe,gBAAgB;qBAG/B;qBAGA,kBAAgB;;;;qBAKhB,kBAAgB;;;;;;;qBCjHhB,mBAAiB,EAAA;;;;qBAEjB,uBAAqB,EAAA;;;;;;;;;;;;;;;GAYhC,EAAA,KAAA;qBAIW,2BAAyB,EAAA;;;;;;;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B,UAAU;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/shared/constants.ts","../src/domain/entities/alert.ts","../src/domain/entities/cluster.ts","../src/domain/entities/incident.ts","../src/domain/entities/rule.ts","../src/domain/entities/traceability.ts","../src/domain/value-objects/fingerprint.ts","../src/domain/ports/index.ts","../src/domain/services/clustering.service.ts","../src/application/dtos/normalize-payload.ts","../src/shared/logger/enums.ts","../src/shared/logger/wide-event-builder.ts","../src/shared/logger/index.ts","../src/application/use-cases/process-incident.use-case.ts","../src/infrastructure/dedup/redis-dedup.adapter.ts","../src/infrastructure/dedup/dynamodb-dedup.adapter.ts","../src/infrastructure/indexer/opensearch.adapter.ts","../src/infrastructure/llm/bedrock.provider.ts","../src/infrastructure/llm/claude.provider.ts","../src/infrastructure/llm/openrouter.provider.ts","../src/infrastructure/llm/factory.ts","../src/infrastructure/llm/gemini.provider.ts","../src/infrastructure/llm/mock.provider.ts","../src/shared/config/index.ts","../src/infrastructure/rules/channel-registry.ts","../src/infrastructure/notifier/factory.ts","../src/infrastructure/rollback/factory.ts","../src/infrastructure/rollback/noop-rollback-action.handler.ts","../src/infrastructure/notifier/slack.adapter.ts","../src/infrastructure/notifier/teams.adapter.ts","../src/infrastructure/notifier/routing-notifier.ts","../src/infrastructure/queue/sqs.adapter.ts","../src/infrastructure/queue/sqs-lag-poller.ts","../src/infrastructure/traces/loki-trace.adapter.ts","../src/infrastructure/rules/yaml-rule-loader.ts","../src/infrastructure/rules/condition-evaluator.ts","../src/infrastructure/rules/action-dispatcher.ts","../src/infrastructure/rules/rule-engine.ts","../src/shared/factory-registry.ts","../src/shared/logger/loki-transport.ts"],"mappings":";;;;;;oBAMY;EACV;EACA;EACA;;UAGQ;WACC;WACA;WACA,UAAU,iBAAiB,WAAW;;cAG3C,mBAAmB,OAAO,WAAW;qBAmB9B,mBAAmB,gBAAgB;oBAIpC;EACV;EACA;EACA;EACA;EACA;;qBAIW,iBAAe;;;;;;qBAOf,iBAAe;;;;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Q/B,QAAQ,cAAc;;;;EAWtB,IAAI;;;;EAOJ;;;;;;;;;wBCkDoB,aAAa"}
|
package/dist/index.js
CHANGED
|
@@ -194,6 +194,12 @@ let RuleEvaluationPhase = /* @__PURE__ */ function(RuleEvaluationPhase) {
|
|
|
194
194
|
RuleEvaluationPhase["PostLlm"] = "post-llm";
|
|
195
195
|
return RuleEvaluationPhase;
|
|
196
196
|
}({});
|
|
197
|
+
/** Notifier backend a logical channel resolves to */
|
|
198
|
+
let ChannelType = /* @__PURE__ */ function(ChannelType) {
|
|
199
|
+
ChannelType["Slack"] = "slack";
|
|
200
|
+
ChannelType["Teams"] = "teams";
|
|
201
|
+
return ChannelType;
|
|
202
|
+
}({});
|
|
197
203
|
const AlertCountSchema = z.object({
|
|
198
204
|
min: z.number().optional(),
|
|
199
205
|
max: z.number().optional()
|
|
@@ -243,9 +249,19 @@ const RuleSchema = z.object({
|
|
|
243
249
|
requiresRollback: z.boolean().optional()
|
|
244
250
|
});
|
|
245
251
|
const RuleSectionSchema = z.object({ rules: z.array(RuleSchema).default([]) });
|
|
252
|
+
const SLACK_CHANNEL_SCHEMA = z.object({
|
|
253
|
+
type: z.literal("slack"),
|
|
254
|
+
channel: z.string().startsWith("#")
|
|
255
|
+
});
|
|
256
|
+
const TEAMS_CHANNEL_SCHEMA = z.object({
|
|
257
|
+
type: z.literal("teams"),
|
|
258
|
+
webhookUrlEnv: z.string().min(1)
|
|
259
|
+
});
|
|
260
|
+
const ChannelConfigSchema = z.discriminatedUnion("type", [SLACK_CHANNEL_SCHEMA, TEAMS_CHANNEL_SCHEMA]);
|
|
246
261
|
const RuleConfigurationSchema = z.object({
|
|
247
262
|
["pre-llm"]: RuleSectionSchema,
|
|
248
|
-
["post-llm"]: RuleSectionSchema
|
|
263
|
+
["post-llm"]: RuleSectionSchema,
|
|
264
|
+
channels: z.record(z.string(), ChannelConfigSchema).default({})
|
|
249
265
|
});
|
|
250
266
|
//#endregion
|
|
251
267
|
//#region src/domain/value-objects/fingerprint.ts
|
|
@@ -1554,6 +1570,7 @@ function sanitizeEndpointPath(endpointPath) {
|
|
|
1554
1570
|
if (!endpointPath) return "unknown";
|
|
1555
1571
|
return endpointPath.replaceAll("`", "").slice(0, 200);
|
|
1556
1572
|
}
|
|
1573
|
+
const ROLLBACK_PROBABLE_CAUSE_MAX_LEN = 500;
|
|
1557
1574
|
var SlackNotifier = class {
|
|
1558
1575
|
botToken;
|
|
1559
1576
|
channel;
|
|
@@ -1669,7 +1686,8 @@ var SlackNotifier = class {
|
|
|
1669
1686
|
serviceName: cluster.serviceName,
|
|
1670
1687
|
endpointPath: cluster.endpointPath,
|
|
1671
1688
|
alertType: cluster.alertType,
|
|
1672
|
-
urgencyLevel: analysis.urgency_level
|
|
1689
|
+
urgencyLevel: analysis.urgency_level,
|
|
1690
|
+
probableCause: analysis.probable_cause.slice(0, ROLLBACK_PROBABLE_CAUSE_MAX_LEN)
|
|
1673
1691
|
}),
|
|
1674
1692
|
confirm: {
|
|
1675
1693
|
title: {
|
|
@@ -2263,15 +2281,46 @@ function buildNotifierRegistry(config) {
|
|
|
2263
2281
|
return registry;
|
|
2264
2282
|
}
|
|
2265
2283
|
/**
|
|
2284
|
+
* Builds the notifier for a single named channel entry from the rules YAML's
|
|
2285
|
+
* `channels:` section.
|
|
2286
|
+
*
|
|
2287
|
+
* @throws {Error} if the channel's backend cannot actually be reached (e.g.
|
|
2288
|
+
* `type: slack` with no SLACK_BOT_TOKEN configured, or `type: teams` whose
|
|
2289
|
+
* `webhookUrlEnv` is unset) — fails fast at startup rather than at delivery
|
|
2290
|
+
* time, mid-incident.
|
|
2291
|
+
*/
|
|
2292
|
+
function buildChannelNotifier(name, channelConfig, config) {
|
|
2293
|
+
if (channelConfig.type === "slack") {
|
|
2294
|
+
if (!config.slackBotToken) throw new Error(`Channel "${name}" (type: slack) requires SLACK_BOT_TOKEN to be set`);
|
|
2295
|
+
return new SlackNotifier(config.slackBotToken, channelConfig.channel);
|
|
2296
|
+
}
|
|
2297
|
+
const webhookUrl = process.env[channelConfig.webhookUrlEnv];
|
|
2298
|
+
if (!webhookUrl) throw new Error(`Channel "${name}" (type: teams) references env var "${channelConfig.webhookUrlEnv}", which is not set`);
|
|
2299
|
+
let parsedUrl;
|
|
2300
|
+
try {
|
|
2301
|
+
parsedUrl = new URL(webhookUrl);
|
|
2302
|
+
} catch {
|
|
2303
|
+
throw new Error(`Channel "${name}": ${channelConfig.webhookUrlEnv} is not a valid URL`);
|
|
2304
|
+
}
|
|
2305
|
+
if (!parsedUrl.searchParams.has("api-version")) throw new Error(`Channel "${name}": ${channelConfig.webhookUrlEnv} must include api-version= as a query parameter`);
|
|
2306
|
+
return new TeamsNotifier(webhookUrl);
|
|
2307
|
+
}
|
|
2308
|
+
/**
|
|
2266
2309
|
* Creates the notifier for the application.
|
|
2267
2310
|
*
|
|
2268
2311
|
* When `config.rulesConfigPath` is set:
|
|
2269
2312
|
* - Reads and validates the rules YAML config
|
|
2270
|
-
* -
|
|
2313
|
+
* - Builds a ChannelRegistry from its `channels:` section, with the default
|
|
2314
|
+
* notifier as fallback
|
|
2271
2315
|
* - Wraps the default notifier with a RoutingNotifier for multi-channel dispatch
|
|
2272
2316
|
*
|
|
2273
2317
|
* When `config.rulesConfigPath` is NOT set:
|
|
2274
2318
|
* - Returns the default notifier directly (backward-compatible)
|
|
2319
|
+
*
|
|
2320
|
+
* @throws {Error} at startup if a rule's route/escalate action references a
|
|
2321
|
+
* channel with no matching entry under `channels:` — an operator must fix
|
|
2322
|
+
* the rules config rather than have the alert silently fall back to the
|
|
2323
|
+
* default channel mid-incident.
|
|
2275
2324
|
*/
|
|
2276
2325
|
function createNotifier(config) {
|
|
2277
2326
|
const defaultNotifier = buildNotifierRegistry(config).resolve(config.notifierType);
|
|
@@ -2279,19 +2328,19 @@ function createNotifier(config) {
|
|
|
2279
2328
|
logger$2.debug("RULES_CONFIG_PATH not set — rule engine disabled, using default notifier");
|
|
2280
2329
|
return defaultNotifier;
|
|
2281
2330
|
}
|
|
2331
|
+
const ruleConfig = parseRuleConfig(readFileSync(config.rulesConfigPath, "utf-8"));
|
|
2282
2332
|
const channelRegistry = new ChannelRegistry();
|
|
2283
2333
|
channelRegistry.setDefault(defaultNotifier);
|
|
2334
|
+
for (const [name, channelConfig] of Object.entries(ruleConfig.channels)) channelRegistry.register(name, buildChannelNotifier(name, channelConfig, config));
|
|
2284
2335
|
const unresolved = collectUnresolvedChannels(config, channelRegistry);
|
|
2285
|
-
if (unresolved.length > 0)
|
|
2286
|
-
channels: unresolved,
|
|
2287
|
-
rulesConfigPath: config.rulesConfigPath
|
|
2288
|
-
}, "Rules reference channels with no registered notifier — these will be delivered to the default channel");
|
|
2336
|
+
if (unresolved.length > 0) throw new Error(`Rules reference undefined channels: ${unresolved.join(", ")}. Define them under "channels:" in ${config.rulesConfigPath}, or remove the reference.`);
|
|
2289
2337
|
return new RoutingNotifier(channelRegistry, defaultNotifier);
|
|
2290
2338
|
}
|
|
2291
2339
|
/**
|
|
2292
2340
|
* Collect the channel names referenced by Route/Escalate actions in the rules
|
|
2293
|
-
* config that have no notifier registered
|
|
2294
|
-
*
|
|
2341
|
+
* config that have no notifier registered against `registry` — i.e. no
|
|
2342
|
+
* matching entry under the rules YAML's `channels:` section. `createNotifier`
|
|
2343
|
+
* treats a non-empty result as a fail-fast startup error.
|
|
2295
2344
|
*
|
|
2296
2345
|
* Returns an empty list when no rules config is set.
|
|
2297
2346
|
*/
|
|
@@ -2299,7 +2348,7 @@ function collectUnresolvedChannels(config, registry) {
|
|
|
2299
2348
|
if (!config.rulesConfigPath) return [];
|
|
2300
2349
|
const ruleConfig = parseRuleConfig(readFileSync(config.rulesConfigPath, "utf-8"));
|
|
2301
2350
|
const referenced = /* @__PURE__ */ new Set();
|
|
2302
|
-
for (const section of
|
|
2351
|
+
for (const section of [ruleConfig["pre-llm"], ruleConfig["post-llm"]]) for (const rule of section.rules) for (const action of rule.actions) if ("channel" in action) referenced.add(action.channel);
|
|
2303
2352
|
return [...referenced].filter((channel) => !registry?.has(channel));
|
|
2304
2353
|
}
|
|
2305
2354
|
/**
|
|
@@ -2330,6 +2379,7 @@ var NoopRollbackActionHandler = class {
|
|
|
2330
2379
|
endpointPath: request.endpointPath,
|
|
2331
2380
|
alertType: request.alertType,
|
|
2332
2381
|
urgencyLevel: request.urgencyLevel,
|
|
2382
|
+
probableCause: request.probableCause,
|
|
2333
2383
|
triggeredBy: request.triggeredBy,
|
|
2334
2384
|
correlationId: request.correlationId,
|
|
2335
2385
|
messageTs: request.messageTs
|
|
@@ -36013,6 +36063,6 @@ async function loadConfig() {
|
|
|
36013
36063
|
return result.data;
|
|
36014
36064
|
}
|
|
36015
36065
|
//#endregion
|
|
36016
|
-
export { ALERT_TYPE_LABELS, AlertClusterSchema, AlertStatusSchema, AlertType, AlertmanagerPayloadSchema, BedrockProvider, CIRCUIT_BREAKER, ChannelRegistry, ClaudeProvider, ClusteringService, Component, ConsoleNotifier, DEDUP_TTL_MS_MULTIPLIER, DEV_SERVER_PORT, DynamoDBDeduplicationStore, FactoryRegistry, Fingerprint, GeminiProvider, HOUR_MS, HTTP_TIMEOUT_MS, InMemoryAlertQueue, InMemoryDeduplicationStore, InMemoryIndexer, IncidentSchema, LLMAnalysisSchema, LLMProviderType, LLM_FALLBACK_DEFAULTS, LLM_MAX_TOKENS, LLM_MODELS, LokiTraceRepository, MockLLMProvider, MockTraceRepository, NoopRollbackActionHandler, NormalizedAlertSchema, NotifyOutcome, OpenRouterProvider, OpenSearchIndexer, Outcome, PAYLOAD_DEFAULTS, ProcessIncidentUseCase, RATE_LIMITER, REDIS_KEY_PREFIX, ROLLBACK_ACTION_ID, RedisDeduplicationStore, RoutingNotifier, RuleActionSchema, RuleActionType, RuleConditionSchema, RuleConfigurationSchema, RuleEngine, RuleEvaluationPhase, RuleSchema, RuleSectionSchema, SLACK_API_URL, SQSAlertQueue, SamplingDecision, SeverityLevel, SlackNotifier, Stage, TEAMS_WEBHOOK_TIMEOUT_MS, TeamsNotifier, TeamsNotifierError, URGENCY_EMOJI, UrgencyLevelSchema, WEBHOOK_DEFAULTS, WideEventBuilder, compileCondition, createLLMProvider, createLogger, createNotifier, createRollbackActionHandler, createRuleEngine, dispatchActions, flushLoki, loadConfig, metrics_exports as metrics, normalizePayload, parseRuleConfig, reinitLogger, startSqsLagPoller };
|
|
36066
|
+
export { ALERT_TYPE_LABELS, AlertClusterSchema, AlertStatusSchema, AlertType, AlertmanagerPayloadSchema, BedrockProvider, CIRCUIT_BREAKER, ChannelConfigSchema, ChannelRegistry, ChannelType, ClaudeProvider, ClusteringService, Component, ConsoleNotifier, DEDUP_TTL_MS_MULTIPLIER, DEV_SERVER_PORT, DynamoDBDeduplicationStore, FactoryRegistry, Fingerprint, GeminiProvider, HOUR_MS, HTTP_TIMEOUT_MS, InMemoryAlertQueue, InMemoryDeduplicationStore, InMemoryIndexer, IncidentSchema, LLMAnalysisSchema, LLMProviderType, LLM_FALLBACK_DEFAULTS, LLM_MAX_TOKENS, LLM_MODELS, LokiTraceRepository, MockLLMProvider, MockTraceRepository, NoopRollbackActionHandler, NormalizedAlertSchema, NotifyOutcome, OpenRouterProvider, OpenSearchIndexer, Outcome, PAYLOAD_DEFAULTS, ProcessIncidentUseCase, RATE_LIMITER, REDIS_KEY_PREFIX, ROLLBACK_ACTION_ID, RedisDeduplicationStore, RoutingNotifier, RuleActionSchema, RuleActionType, RuleConditionSchema, RuleConfigurationSchema, RuleEngine, RuleEvaluationPhase, RuleSchema, RuleSectionSchema, SLACK_API_URL, SQSAlertQueue, SamplingDecision, SeverityLevel, SlackNotifier, Stage, TEAMS_WEBHOOK_TIMEOUT_MS, TeamsNotifier, TeamsNotifierError, URGENCY_EMOJI, UrgencyLevelSchema, WEBHOOK_DEFAULTS, WideEventBuilder, compileCondition, createLLMProvider, createLogger, createNotifier, createRollbackActionHandler, createRuleEngine, dispatchActions, flushLoki, loadConfig, metrics_exports as metrics, normalizePayload, parseRuleConfig, reinitLogger, startSqsLagPoller };
|
|
36017
36067
|
|
|
36018
36068
|
//# sourceMappingURL=index.js.map
|