@oneuptime/common 14.0.100 → 14.0.101
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/Models/AnalyticsModels/NetworkTrafficUsage.js +30 -10
- package/Models/DatabaseModels/KubernetesResource.d.mts +1 -0
- package/Models/DatabaseModels/KubernetesResource.d.ts +1 -0
- package/Models/DatabaseModels/KubernetesResource.js +36 -0
- package/Types/AutoRemediation/AiRemediationCommandPlan.d.mts +3 -0
- package/Types/AutoRemediation/AiRemediationCommandPlan.d.ts +3 -0
- package/Types/AutoRemediation/AiRemediationCommandPlan.js +11 -2
- package/Types/AutoRemediation/RemediationTrackRecord.d.mts +26 -0
- package/Types/AutoRemediation/RemediationTrackRecord.d.ts +26 -0
- package/Types/AutoRemediation/RemediationTrackRecord.js +137 -0
- package/Types/AutoRemediation/RemediationTrackRecord.mjs +8 -0
- package/Types/AutoRemediation/RemediationTrackRecordWords.d.mts +10 -0
- package/Types/AutoRemediation/RemediationTrackRecordWords.d.ts +10 -0
- package/Types/AutoRemediation/RemediationTrackRecordWords.js +86 -0
- package/Types/AutoRemediation/RemediationTrackRecordWords.mjs +9 -0
- package/Types/Kubernetes/KubernetesHealth.d.mts +92 -0
- package/Types/Kubernetes/KubernetesHealth.d.ts +92 -0
- package/Types/Kubernetes/KubernetesHealth.js +1273 -0
- package/Types/Kubernetes/KubernetesHealth.mjs +32 -0
- package/Types/Kubernetes/KubernetesInventoryExtractor.d.mts +2 -0
- package/Types/Kubernetes/KubernetesInventoryExtractor.d.ts +2 -0
- package/Types/Kubernetes/KubernetesInventoryExtractor.js +7 -0
- package/Types/Kubernetes/KubernetesObjectParser.d.mts +30 -0
- package/Types/Kubernetes/KubernetesObjectParser.d.ts +30 -0
- package/Types/Kubernetes/KubernetesObjectParser.js +164 -38
- package/Types/Kubernetes/KubernetesObjectParser.mjs +3 -0
- package/Types/Monitor/KubernetesAlertTemplates.js +238 -0
- package/Types/Monitor/KubernetesMetricCatalog.js +57 -0
- package/Types/Monitor/MetricMonitor/MetricMonitorResponse.d.mts +1 -0
- package/Types/Monitor/MetricMonitor/MetricMonitorResponse.d.ts +1 -0
- package/Types/NetFlow/NetworkTrafficUsage.d.mts +40 -1
- package/Types/NetFlow/NetworkTrafficUsage.d.ts +40 -1
- package/Types/NetFlow/NetworkTrafficUsage.js +58 -6
- package/Types/NetFlow/NetworkTrafficUsage.mjs +1 -0
- package/Utils/AI/InvestigationReport.d.mts +9 -0
- package/Utils/AI/InvestigationReport.d.ts +9 -0
- package/Utils/AI/InvestigationReport.js +122 -10
- package/Utils/AI/InvestigationReport.mjs +3 -0
- package/Utils/AiRemediation/CloudChangeWords.d.mts +32 -0
- package/Utils/AiRemediation/CloudChangeWords.d.ts +32 -0
- package/Utils/AiRemediation/CloudChangeWords.js +242 -0
- package/Utils/AiRemediation/CloudChangeWords.mjs +8 -0
- package/Utils/AiRemediation/RemediationChangeKey.d.mts +2 -0
- package/Utils/AiRemediation/RemediationChangeKey.d.ts +2 -0
- package/Utils/AiRemediation/RemediationChangeKey.js +132 -0
- package/Utils/AiRemediation/RemediationChangeKey.mjs +2 -0
- package/package.json +1 -1
|
@@ -8,4 +8,5 @@ export const NetworkTrafficUsageKind = commonJsModule.NetworkTrafficUsageKind;
|
|
|
8
8
|
export const getNetworkTrafficUsageBucketSeconds = commonJsModule.getNetworkTrafficUsageBucketSeconds;
|
|
9
9
|
export const getUnavailableNetworkTrafficUsageSummary = commonJsModule.getUnavailableNetworkTrafficUsageSummary;
|
|
10
10
|
export const getUsageOctets = commonJsModule.getUsageOctets;
|
|
11
|
+
export const isUplinkUsageKind = commonJsModule.isUplinkUsageKind;
|
|
11
12
|
export const isUsageObjectId = commonJsModule.isUsageObjectId;
|
|
@@ -6,9 +6,11 @@ export declare enum InvestigationReportSectionKind {
|
|
|
6
6
|
Summary = "Summary",
|
|
7
7
|
RootCause = "RootCause",
|
|
8
8
|
Evidence = "Evidence",
|
|
9
|
+
RuledOut = "RuledOut",
|
|
9
10
|
NextSteps = "NextSteps",
|
|
10
11
|
Other = "Other"
|
|
11
12
|
}
|
|
13
|
+
export declare const RULED_OUT_SECTION_TITLE: string;
|
|
12
14
|
export interface InvestigationReportSection {
|
|
13
15
|
kind: InvestigationReportSectionKind;
|
|
14
16
|
title: string;
|
|
@@ -35,6 +37,7 @@ export interface ParsedInvestigationReport {
|
|
|
35
37
|
summary?: string | undefined;
|
|
36
38
|
rootCause?: string | undefined;
|
|
37
39
|
evidence?: string | undefined;
|
|
40
|
+
ruledOut?: string | undefined;
|
|
38
41
|
nextSteps?: string | undefined;
|
|
39
42
|
evidenceChecked: Array<InvestigationEvidenceCheckedEntry>;
|
|
40
43
|
footer?: InvestigationReportFooter | undefined;
|
|
@@ -53,5 +56,11 @@ export interface ExtractedInvestigationEventReference {
|
|
|
53
56
|
export declare const DEFAULT_EVENT_REFERENCE_LIMIT: number;
|
|
54
57
|
export declare function getCitationMarkerRegex(): RegExp;
|
|
55
58
|
export declare function parseInvestigationReport(markdown: string): ParsedInvestigationReport;
|
|
59
|
+
export interface RuledOutCause {
|
|
60
|
+
causeMarkdown: string;
|
|
61
|
+
reasonMarkdown: string;
|
|
62
|
+
}
|
|
63
|
+
export declare const MAX_RULED_OUT_CAUSES_SHOWN: number;
|
|
64
|
+
export declare function parseRuledOutCauses(markdown: string | null | undefined): Array<RuledOutCause>;
|
|
56
65
|
export declare function tokenizeEventReferences(text: string): Array<InvestigationEventReferenceToken>;
|
|
57
66
|
export declare function extractEventReferences(markdown: string, defaultKind: "incident" | "alert", limit?: number): Array<ExtractedInvestigationEventReference>;
|
|
@@ -6,9 +6,11 @@ export declare enum InvestigationReportSectionKind {
|
|
|
6
6
|
Summary = "Summary",
|
|
7
7
|
RootCause = "RootCause",
|
|
8
8
|
Evidence = "Evidence",
|
|
9
|
+
RuledOut = "RuledOut",
|
|
9
10
|
NextSteps = "NextSteps",
|
|
10
11
|
Other = "Other"
|
|
11
12
|
}
|
|
13
|
+
export declare const RULED_OUT_SECTION_TITLE: string;
|
|
12
14
|
export interface InvestigationReportSection {
|
|
13
15
|
kind: InvestigationReportSectionKind;
|
|
14
16
|
title: string;
|
|
@@ -35,6 +37,7 @@ export interface ParsedInvestigationReport {
|
|
|
35
37
|
summary?: string | undefined;
|
|
36
38
|
rootCause?: string | undefined;
|
|
37
39
|
evidence?: string | undefined;
|
|
40
|
+
ruledOut?: string | undefined;
|
|
38
41
|
nextSteps?: string | undefined;
|
|
39
42
|
evidenceChecked: Array<InvestigationEvidenceCheckedEntry>;
|
|
40
43
|
footer?: InvestigationReportFooter | undefined;
|
|
@@ -53,5 +56,11 @@ export interface ExtractedInvestigationEventReference {
|
|
|
53
56
|
export declare const DEFAULT_EVENT_REFERENCE_LIMIT: number;
|
|
54
57
|
export declare function getCitationMarkerRegex(): RegExp;
|
|
55
58
|
export declare function parseInvestigationReport(markdown: string): ParsedInvestigationReport;
|
|
59
|
+
export interface RuledOutCause {
|
|
60
|
+
causeMarkdown: string;
|
|
61
|
+
reasonMarkdown: string;
|
|
62
|
+
}
|
|
63
|
+
export declare const MAX_RULED_OUT_CAUSES_SHOWN: number;
|
|
64
|
+
export declare function parseRuledOutCauses(markdown: string | null | undefined): Array<RuledOutCause>;
|
|
56
65
|
export declare function tokenizeEventReferences(text: string): Array<InvestigationEventReferenceToken>;
|
|
57
66
|
export declare function extractEventReferences(markdown: string, defaultKind: "incident" | "alert", limit?: number): Array<ExtractedInvestigationEventReference>;
|
|
@@ -15,9 +15,10 @@
|
|
|
15
15
|
* numbers, and resolve anything clickable from their own database rows.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.DEFAULT_EVENT_REFERENCE_LIMIT = exports.InvestigationReportSectionKind = exports.SECURITY_CASE_TRIAGE_INJECTION_LEAD_PREFIX = exports.FOLLOW_UP_REPORT_LEAD_PREFIX = exports.AI_SECURITY_CASE_TRIAGE_HEADING_TEXT = exports.AI_ROOT_CAUSE_HEADING_TEXT = void 0;
|
|
18
|
+
exports.MAX_RULED_OUT_CAUSES_SHOWN = exports.DEFAULT_EVENT_REFERENCE_LIMIT = exports.RULED_OUT_SECTION_TITLE = exports.InvestigationReportSectionKind = exports.SECURITY_CASE_TRIAGE_INJECTION_LEAD_PREFIX = exports.FOLLOW_UP_REPORT_LEAD_PREFIX = exports.AI_SECURITY_CASE_TRIAGE_HEADING_TEXT = exports.AI_ROOT_CAUSE_HEADING_TEXT = void 0;
|
|
19
19
|
exports.getCitationMarkerRegex = getCitationMarkerRegex;
|
|
20
20
|
exports.parseInvestigationReport = parseInvestigationReport;
|
|
21
|
+
exports.parseRuledOutCauses = parseRuledOutCauses;
|
|
21
22
|
exports.tokenizeEventReferences = tokenizeEventReferences;
|
|
22
23
|
exports.extractEventReferences = extractEventReferences;
|
|
23
24
|
exports.AI_ROOT_CAUSE_HEADING_TEXT = "AI — Automated Root Cause Analysis";
|
|
@@ -52,9 +53,17 @@ var InvestigationReportSectionKind;
|
|
|
52
53
|
InvestigationReportSectionKind["Summary"] = "Summary";
|
|
53
54
|
InvestigationReportSectionKind["RootCause"] = "RootCause";
|
|
54
55
|
InvestigationReportSectionKind["Evidence"] = "Evidence";
|
|
56
|
+
/*
|
|
57
|
+
* The other likely causes the investigation checked, and why the
|
|
58
|
+
* evidence rules each out (AIInvestigationEngine's persona): one bullet
|
|
59
|
+
* per cause, "**The cause:** why".
|
|
60
|
+
*/
|
|
61
|
+
InvestigationReportSectionKind["RuledOut"] = "RuledOut";
|
|
55
62
|
InvestigationReportSectionKind["NextSteps"] = "NextSteps";
|
|
56
63
|
InvestigationReportSectionKind["Other"] = "Other";
|
|
57
64
|
})(InvestigationReportSectionKind || (exports.InvestigationReportSectionKind = InvestigationReportSectionKind = {}));
|
|
65
|
+
// The heading the investigation writes its ruled-out causes under.
|
|
66
|
+
exports.RULED_OUT_SECTION_TITLE = "Ruled out";
|
|
58
67
|
exports.DEFAULT_EVENT_REFERENCE_LIMIT = 25;
|
|
59
68
|
/*
|
|
60
69
|
* Citation marker "[C12]". A fresh RegExp per call because the global flag
|
|
@@ -83,6 +92,13 @@ const KNOWN_LABELS = new Map([
|
|
|
83
92
|
["supporting evidence", InvestigationReportSectionKind.Evidence],
|
|
84
93
|
["key findings", InvestigationReportSectionKind.Evidence],
|
|
85
94
|
["findings", InvestigationReportSectionKind.Evidence],
|
|
95
|
+
["ruled out", InvestigationReportSectionKind.RuledOut],
|
|
96
|
+
["what was ruled out", InvestigationReportSectionKind.RuledOut],
|
|
97
|
+
["other causes ruled out", InvestigationReportSectionKind.RuledOut],
|
|
98
|
+
["causes ruled out", InvestigationReportSectionKind.RuledOut],
|
|
99
|
+
["other causes checked", InvestigationReportSectionKind.RuledOut],
|
|
100
|
+
["alternatives ruled out", InvestigationReportSectionKind.RuledOut],
|
|
101
|
+
["hypotheses ruled out", InvestigationReportSectionKind.RuledOut],
|
|
86
102
|
["suggested next steps", InvestigationReportSectionKind.NextSteps],
|
|
87
103
|
["next steps", InvestigationReportSectionKind.NextSteps],
|
|
88
104
|
["recommended next steps", InvestigationReportSectionKind.NextSteps],
|
|
@@ -1098,7 +1114,30 @@ function resolveSectionStarts(lines, kept, allCandidates, contentEnd) {
|
|
|
1098
1114
|
candidates.forEach((candidate, position) => {
|
|
1099
1115
|
const match = candidate.match;
|
|
1100
1116
|
const headingLevel = match.headingLevel || 0;
|
|
1101
|
-
|
|
1117
|
+
const open = starts[starts.length - 1];
|
|
1118
|
+
// A sub-heading of the recognised heading that opened the section.
|
|
1119
|
+
const isSubHeadingOfOpen = Boolean(open &&
|
|
1120
|
+
open.kind !== InvestigationReportSectionKind.Other &&
|
|
1121
|
+
open.headingLevel > 0 &&
|
|
1122
|
+
headingLevel > open.headingLevel);
|
|
1123
|
+
// The first label under a label with no body of its own.
|
|
1124
|
+
const isFirstUnderBodilessLabel = Boolean(open &&
|
|
1125
|
+
open.inlineBody === "" &&
|
|
1126
|
+
!hasKeptContent(open.index + 1, candidate.index) &&
|
|
1127
|
+
!isPeerHeading(open.headingLevel, match));
|
|
1128
|
+
/*
|
|
1129
|
+
* "Ruled out" is a section of its own (RULED_OUT_SECTION_TITLE) - and
|
|
1130
|
+
* also how a model groups an Evidence section's findings ("**Evidence**"
|
|
1131
|
+
* then "**Ruled out:**" and "**Supports:**", or "## Evidence" then
|
|
1132
|
+
* "### Ruled out"). Nested so, it stays in the section it is in, as it
|
|
1133
|
+
* did before it was a section; every other recognised label always
|
|
1134
|
+
* starts one.
|
|
1135
|
+
*/
|
|
1136
|
+
const isNestedRuledOut = match.kind === InvestigationReportSectionKind.RuledOut &&
|
|
1137
|
+
(isSubHeadingOfOpen || isFirstUnderBodilessLabel);
|
|
1138
|
+
if (match.kind !== null &&
|
|
1139
|
+
match.kind !== "EvidenceChecked" &&
|
|
1140
|
+
!isNestedRuledOut) {
|
|
1102
1141
|
starts.push({
|
|
1103
1142
|
index: candidate.index,
|
|
1104
1143
|
kind: match.kind,
|
|
@@ -1108,22 +1147,16 @@ function resolveSectionStarts(lines, kept, allCandidates, contentEnd) {
|
|
|
1108
1147
|
});
|
|
1109
1148
|
return;
|
|
1110
1149
|
}
|
|
1111
|
-
const open = starts[starts.length - 1];
|
|
1112
1150
|
// Before the first recognised section, labels are preamble content.
|
|
1113
1151
|
if (!open) {
|
|
1114
1152
|
return;
|
|
1115
1153
|
}
|
|
1116
1154
|
const rank = getLabelRank(match);
|
|
1117
|
-
|
|
1118
|
-
if (open.kind !== InvestigationReportSectionKind.Other &&
|
|
1119
|
-
open.headingLevel > 0 &&
|
|
1120
|
-
headingLevel > open.headingLevel) {
|
|
1155
|
+
if (isSubHeadingOfOpen) {
|
|
1121
1156
|
return;
|
|
1122
1157
|
}
|
|
1123
1158
|
// The first label under a label with no body: that label is a group heading.
|
|
1124
|
-
if (
|
|
1125
|
-
!hasKeptContent(open.index + 1, candidate.index) &&
|
|
1126
|
-
!isPeerHeading(open.headingLevel, match)) {
|
|
1159
|
+
if (isFirstUnderBodilessLabel) {
|
|
1127
1160
|
open.subLabelRank = rank;
|
|
1128
1161
|
return;
|
|
1129
1162
|
}
|
|
@@ -1251,12 +1284,91 @@ function parseInvestigationReport(markdown) {
|
|
|
1251
1284
|
summary,
|
|
1252
1285
|
rootCause,
|
|
1253
1286
|
evidence: firstOfKind(InvestigationReportSectionKind.Evidence),
|
|
1287
|
+
ruledOut: firstOfKind(InvestigationReportSectionKind.RuledOut),
|
|
1254
1288
|
nextSteps: firstOfKind(InvestigationReportSectionKind.NextSteps),
|
|
1255
1289
|
evidenceChecked,
|
|
1256
1290
|
footer: footerMatch === null || footerMatch === void 0 ? void 0 : footerMatch.footer,
|
|
1257
1291
|
bodyMarkdown: joinKeptLines(lines, kept, 0, lines.length).trim(),
|
|
1258
1292
|
};
|
|
1259
1293
|
}
|
|
1294
|
+
// The most causes the card lists: the persona asks for at most five.
|
|
1295
|
+
exports.MAX_RULED_OUT_CAUSES_SHOWN = 8;
|
|
1296
|
+
// The longest bullet read; the rest of a longer one is left as written.
|
|
1297
|
+
const MAX_RULED_OUT_BULLET_LENGTH = 2000;
|
|
1298
|
+
// "- ", "* ", "+ " or "1. " at the start of a line opens a bullet.
|
|
1299
|
+
const BULLET_START_REGEX = /^ {0,3}(?:[-*+]|\d{1,3}[.)])[ \t]+/;
|
|
1300
|
+
/*
|
|
1301
|
+
* The bullet's bold label, "**The cause:**" or "**The cause**:", and what
|
|
1302
|
+
* follows it. A label is one short run with no asterisk in it, so the
|
|
1303
|
+
* pattern reads it in time linear in the bullet.
|
|
1304
|
+
*/
|
|
1305
|
+
const BOLD_LABEL_REGEX = /^\*\*([^*\n]{1,200}?)\*\*[ \t]*/;
|
|
1306
|
+
// The colons a label ends with: ASCII, and the full-width one CJK text writes.
|
|
1307
|
+
const LABEL_COLONS = [":", "\uFF1A"];
|
|
1308
|
+
// Text without the colon (and the spaces around it) it ends with.
|
|
1309
|
+
function withoutTrailingColon(text) {
|
|
1310
|
+
const trimmed = text.trim();
|
|
1311
|
+
return LABEL_COLONS.some((colon) => {
|
|
1312
|
+
return trimmed.endsWith(colon);
|
|
1313
|
+
})
|
|
1314
|
+
? trimmed.slice(0, -1).trim()
|
|
1315
|
+
: trimmed;
|
|
1316
|
+
}
|
|
1317
|
+
// Text without the colon (and the spaces after it) it starts with.
|
|
1318
|
+
function withoutLeadingColon(text) {
|
|
1319
|
+
const trimmed = text.trim();
|
|
1320
|
+
return LABEL_COLONS.some((colon) => {
|
|
1321
|
+
return trimmed.startsWith(colon);
|
|
1322
|
+
})
|
|
1323
|
+
? trimmed.slice(1).trim()
|
|
1324
|
+
: trimmed;
|
|
1325
|
+
}
|
|
1326
|
+
/*
|
|
1327
|
+
* The causes a report's Ruled out section lists, one per bullet, in order;
|
|
1328
|
+
* empty when the section is not a list (the card then draws it as written).
|
|
1329
|
+
* Lines under a bullet continue it. Pure, and linear in the text.
|
|
1330
|
+
*/
|
|
1331
|
+
function parseRuledOutCauses(markdown) {
|
|
1332
|
+
if (typeof markdown !== "string" || !markdown.trim()) {
|
|
1333
|
+
return [];
|
|
1334
|
+
}
|
|
1335
|
+
const bullets = [];
|
|
1336
|
+
for (const line of markdown.replace(LINE_ENDING_REGEX, "\n").split("\n")) {
|
|
1337
|
+
if (!line.trim()) {
|
|
1338
|
+
continue;
|
|
1339
|
+
}
|
|
1340
|
+
const start = BULLET_START_REGEX.exec(line);
|
|
1341
|
+
if (start) {
|
|
1342
|
+
bullets.push([line.slice(start[0].length).trim()]);
|
|
1343
|
+
continue;
|
|
1344
|
+
}
|
|
1345
|
+
// Text before the first bullet: not a list of causes.
|
|
1346
|
+
if (bullets.length === 0) {
|
|
1347
|
+
return [];
|
|
1348
|
+
}
|
|
1349
|
+
bullets[bullets.length - 1].push(line.trim());
|
|
1350
|
+
}
|
|
1351
|
+
const causes = [];
|
|
1352
|
+
for (const parts of bullets.slice(0, exports.MAX_RULED_OUT_CAUSES_SHOWN)) {
|
|
1353
|
+
const text = parts
|
|
1354
|
+
.join(" ")
|
|
1355
|
+
.slice(0, MAX_RULED_OUT_BULLET_LENGTH)
|
|
1356
|
+
.trim();
|
|
1357
|
+
if (!text) {
|
|
1358
|
+
continue;
|
|
1359
|
+
}
|
|
1360
|
+
const label = BOLD_LABEL_REGEX.exec(text);
|
|
1361
|
+
if (!label) {
|
|
1362
|
+
causes.push({ causeMarkdown: "", reasonMarkdown: text });
|
|
1363
|
+
continue;
|
|
1364
|
+
}
|
|
1365
|
+
causes.push({
|
|
1366
|
+
causeMarkdown: withoutTrailingColon(label[1] || ""),
|
|
1367
|
+
reasonMarkdown: withoutLeadingColon(text.slice(label[0].length)),
|
|
1368
|
+
});
|
|
1369
|
+
}
|
|
1370
|
+
return causes;
|
|
1371
|
+
}
|
|
1260
1372
|
/*
|
|
1261
1373
|
* The qualifier word directly before a reference: "incident #12", "Alerts
|
|
1262
1374
|
* #3", "prior incidents: #6954", "alerts (#100". "blocked" means a word from
|
|
@@ -4,8 +4,11 @@ export const AI_SECURITY_CASE_TRIAGE_HEADING_TEXT = commonJsModule.AI_SECURITY_C
|
|
|
4
4
|
export const DEFAULT_EVENT_REFERENCE_LIMIT = commonJsModule.DEFAULT_EVENT_REFERENCE_LIMIT;
|
|
5
5
|
export const FOLLOW_UP_REPORT_LEAD_PREFIX = commonJsModule.FOLLOW_UP_REPORT_LEAD_PREFIX;
|
|
6
6
|
export const InvestigationReportSectionKind = commonJsModule.InvestigationReportSectionKind;
|
|
7
|
+
export const MAX_RULED_OUT_CAUSES_SHOWN = commonJsModule.MAX_RULED_OUT_CAUSES_SHOWN;
|
|
8
|
+
export const RULED_OUT_SECTION_TITLE = commonJsModule.RULED_OUT_SECTION_TITLE;
|
|
7
9
|
export const SECURITY_CASE_TRIAGE_INJECTION_LEAD_PREFIX = commonJsModule.SECURITY_CASE_TRIAGE_INJECTION_LEAD_PREFIX;
|
|
8
10
|
export const extractEventReferences = commonJsModule.extractEventReferences;
|
|
9
11
|
export const getCitationMarkerRegex = commonJsModule.getCitationMarkerRegex;
|
|
10
12
|
export const parseInvestigationReport = commonJsModule.parseInvestigationReport;
|
|
13
|
+
export const parseRuledOutCauses = commonJsModule.parseRuledOutCauses;
|
|
11
14
|
export const tokenizeEventReferences = commonJsModule.tokenizeEventReferences;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { PluralTemplate, Translator } from "../../Types/Translator.mjs";
|
|
2
|
+
import { ParsedCloudResource } from "./Resource/CloudOperationCatalog.mjs";
|
|
3
|
+
export interface CloudChangeWords {
|
|
4
|
+
operation: string;
|
|
5
|
+
kindName: string;
|
|
6
|
+
resourceName: string;
|
|
7
|
+
sentence: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const CLOUD_KIND_WORDS: Readonly<Record<string, string>>;
|
|
10
|
+
type ScaleUnit = "tasks" | "instances" | "minimumInstances";
|
|
11
|
+
export declare const CLOUD_CHANGE_SENTENCES: {
|
|
12
|
+
restartService: string;
|
|
13
|
+
startInstance: string;
|
|
14
|
+
rebootInstance: string;
|
|
15
|
+
rollBackToPrevious: string;
|
|
16
|
+
rollBackToVersion: string;
|
|
17
|
+
swapSlot: string;
|
|
18
|
+
removeConcurrencyLimit: string;
|
|
19
|
+
failOverDatabase: string;
|
|
20
|
+
stopInstance: string;
|
|
21
|
+
redriveQueue: string;
|
|
22
|
+
};
|
|
23
|
+
export declare const CLOUD_SCALE_SENTENCES: Readonly<Record<"out" | "in", Record<ScaleUnit, PluralTemplate>>>;
|
|
24
|
+
export declare const CLOUD_CONCURRENCY_SENTENCE: PluralTemplate;
|
|
25
|
+
export declare function getCloudResourceShortName(resource: ParsedCloudResource): string;
|
|
26
|
+
export declare function describeCloudChange(data: {
|
|
27
|
+
resourceType: unknown;
|
|
28
|
+
command: string;
|
|
29
|
+
translator?: Translator | undefined;
|
|
30
|
+
}): CloudChangeWords | null;
|
|
31
|
+
export declare function getCloudKindWordsKeys(): Array<string>;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { PluralTemplate, Translator } from "../../Types/Translator";
|
|
2
|
+
import { ParsedCloudResource } from "./Resource/CloudOperationCatalog";
|
|
3
|
+
export interface CloudChangeWords {
|
|
4
|
+
operation: string;
|
|
5
|
+
kindName: string;
|
|
6
|
+
resourceName: string;
|
|
7
|
+
sentence: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const CLOUD_KIND_WORDS: Readonly<Record<string, string>>;
|
|
10
|
+
type ScaleUnit = "tasks" | "instances" | "minimumInstances";
|
|
11
|
+
export declare const CLOUD_CHANGE_SENTENCES: {
|
|
12
|
+
restartService: string;
|
|
13
|
+
startInstance: string;
|
|
14
|
+
rebootInstance: string;
|
|
15
|
+
rollBackToPrevious: string;
|
|
16
|
+
rollBackToVersion: string;
|
|
17
|
+
swapSlot: string;
|
|
18
|
+
removeConcurrencyLimit: string;
|
|
19
|
+
failOverDatabase: string;
|
|
20
|
+
stopInstance: string;
|
|
21
|
+
redriveQueue: string;
|
|
22
|
+
};
|
|
23
|
+
export declare const CLOUD_SCALE_SENTENCES: Readonly<Record<"out" | "in", Record<ScaleUnit, PluralTemplate>>>;
|
|
24
|
+
export declare const CLOUD_CONCURRENCY_SENTENCE: PluralTemplate;
|
|
25
|
+
export declare function getCloudResourceShortName(resource: ParsedCloudResource): string;
|
|
26
|
+
export declare function describeCloudChange(data: {
|
|
27
|
+
resourceType: unknown;
|
|
28
|
+
command: string;
|
|
29
|
+
translator?: Translator | undefined;
|
|
30
|
+
}): CloudChangeWords | null;
|
|
31
|
+
export declare function getCloudKindWordsKeys(): Array<string>;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CLOUD_CONCURRENCY_SENTENCE = exports.CLOUD_SCALE_SENTENCES = exports.CLOUD_CHANGE_SENTENCES = exports.CLOUD_KIND_WORDS = void 0;
|
|
4
|
+
exports.getCloudResourceShortName = getCloudResourceShortName;
|
|
5
|
+
exports.describeCloudChange = describeCloudChange;
|
|
6
|
+
exports.getCloudKindWordsKeys = getCloudKindWordsKeys;
|
|
7
|
+
const Translator_1 = require("../../Types/Translator");
|
|
8
|
+
const CloudOperationCatalog_1 = require("./Resource/CloudOperationCatalog");
|
|
9
|
+
const ResourceCommandPolicyCore_1 = require("./Resource/ResourceCommandPolicyCore");
|
|
10
|
+
/*
|
|
11
|
+
* The catalog's kinds of resource, as the sentences name them - the
|
|
12
|
+
* catalog's own display names (CLOUD_RESOURCE_KINDS), here as translation
|
|
13
|
+
* keys, since the catalog itself is the agent's import-closed copy.
|
|
14
|
+
* CloudChangeWords.test holds the two lists to the same words, but for a
|
|
15
|
+
* kind whose display name does not say whose it is: "virtual machine" is
|
|
16
|
+
* an "Azure virtual machine" here, as "EC2 instance" and "Compute Engine
|
|
17
|
+
* VM" say theirs.
|
|
18
|
+
*/
|
|
19
|
+
exports.CLOUD_KIND_WORDS = {
|
|
20
|
+
"aws:ecs-service": (0, Translator_1.translationKey)("ECS service"),
|
|
21
|
+
"aws:ec2-instance": (0, Translator_1.translationKey)("EC2 instance"),
|
|
22
|
+
"aws:rds-instance": (0, Translator_1.translationKey)("RDS instance"),
|
|
23
|
+
"aws:rds-cluster": (0, Translator_1.translationKey)("Aurora cluster"),
|
|
24
|
+
"aws:autoscaling-group": (0, Translator_1.translationKey)("Auto Scaling group"),
|
|
25
|
+
"aws:lambda-function": (0, Translator_1.translationKey)("Lambda function"),
|
|
26
|
+
"aws:lambda-alias": (0, Translator_1.translationKey)("Lambda alias"),
|
|
27
|
+
"aws:sqs-queue": (0, Translator_1.translationKey)("SQS queue"),
|
|
28
|
+
"aws:elb-target-group": (0, Translator_1.translationKey)("target group"),
|
|
29
|
+
"aws:elb-load-balancer": (0, Translator_1.translationKey)("load balancer"),
|
|
30
|
+
"azure:app-service": (0, Translator_1.translationKey)("App Service or Function App"),
|
|
31
|
+
"azure:app-service-plan": (0, Translator_1.translationKey)("App Service plan"),
|
|
32
|
+
"azure:container-app": (0, Translator_1.translationKey)("Container App"),
|
|
33
|
+
"azure:virtual-machine": (0, Translator_1.translationKey)("Azure virtual machine"),
|
|
34
|
+
"azure:vm-scale-set": (0, Translator_1.translationKey)("VM scale set"),
|
|
35
|
+
"azure:postgresql-flexible-server": (0, Translator_1.translationKey)("PostgreSQL flexible server"),
|
|
36
|
+
"azure:mysql-flexible-server": (0, Translator_1.translationKey)("MySQL flexible server"),
|
|
37
|
+
"azure:sql-failover-group": (0, Translator_1.translationKey)("SQL failover group"),
|
|
38
|
+
"gcp:compute-instance": (0, Translator_1.translationKey)("Compute Engine VM"),
|
|
39
|
+
"gcp:cloud-run-service": (0, Translator_1.translationKey)("Cloud Run service"),
|
|
40
|
+
"gcp:managed-instance-group": (0, Translator_1.translationKey)("managed instance group"),
|
|
41
|
+
"gcp:cloud-sql-instance": (0, Translator_1.translationKey)("Cloud SQL instance"),
|
|
42
|
+
};
|
|
43
|
+
const SCALE_UNITS = {
|
|
44
|
+
"aws:ecs-service": "tasks",
|
|
45
|
+
"aws:autoscaling-group": "instances",
|
|
46
|
+
"azure:app-service-plan": "instances",
|
|
47
|
+
"azure:vm-scale-set": "instances",
|
|
48
|
+
"gcp:cloud-run-service": "minimumInstances",
|
|
49
|
+
"gcp:managed-instance-group": "instances",
|
|
50
|
+
};
|
|
51
|
+
exports.CLOUD_CHANGE_SENTENCES = {
|
|
52
|
+
restartService: (0, Translator_1.translationKey)("Restart the {{kind}} {{name}}"),
|
|
53
|
+
startInstance: (0, Translator_1.translationKey)("Start the {{kind}} {{name}}"),
|
|
54
|
+
rebootInstance: (0, Translator_1.translationKey)("Reboot the {{kind}} {{name}}"),
|
|
55
|
+
rollBackToPrevious: (0, Translator_1.translationKey)("Roll the {{kind}} {{name}} back to the version before"),
|
|
56
|
+
rollBackToVersion: (0, Translator_1.translationKey)("Roll the {{kind}} {{name}} back to {{version}}"),
|
|
57
|
+
swapSlot: (0, Translator_1.translationKey)("Swap the {{kind}} {{name}} with its {{slot}} slot, back to the version before"),
|
|
58
|
+
removeConcurrencyLimit: (0, Translator_1.translationKey)("Remove the limit on how many copies of the {{kind}} {{name}} run at once"),
|
|
59
|
+
failOverDatabase: (0, Translator_1.translationKey)("Fail the {{kind}} {{name}} over to its standby"),
|
|
60
|
+
stopInstance: (0, Translator_1.translationKey)("Stop the {{kind}} {{name}}"),
|
|
61
|
+
redriveQueue: (0, Translator_1.translationKey)("Move the messages of the {{kind}} {{name}} back to the queue they came from"),
|
|
62
|
+
};
|
|
63
|
+
exports.CLOUD_SCALE_SENTENCES = {
|
|
64
|
+
out: {
|
|
65
|
+
tasks: {
|
|
66
|
+
one: "Scale the {{kind}} {{name}} out to {{count}} task",
|
|
67
|
+
other: "Scale the {{kind}} {{name}} out to {{count}} tasks",
|
|
68
|
+
},
|
|
69
|
+
instances: {
|
|
70
|
+
one: "Scale the {{kind}} {{name}} out to {{count}} instance",
|
|
71
|
+
other: "Scale the {{kind}} {{name}} out to {{count}} instances",
|
|
72
|
+
},
|
|
73
|
+
minimumInstances: {
|
|
74
|
+
one: "Raise the minimum of the {{kind}} {{name}} to {{count}} instance",
|
|
75
|
+
other: "Raise the minimum of the {{kind}} {{name}} to {{count}} instances",
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
in: {
|
|
79
|
+
tasks: {
|
|
80
|
+
one: "Scale the {{kind}} {{name}} in to {{count}} task",
|
|
81
|
+
other: "Scale the {{kind}} {{name}} in to {{count}} tasks",
|
|
82
|
+
},
|
|
83
|
+
instances: {
|
|
84
|
+
one: "Scale the {{kind}} {{name}} in to {{count}} instance",
|
|
85
|
+
other: "Scale the {{kind}} {{name}} in to {{count}} instances",
|
|
86
|
+
},
|
|
87
|
+
minimumInstances: {
|
|
88
|
+
one: "Lower the minimum of the {{kind}} {{name}} to {{count}} instance",
|
|
89
|
+
other: "Lower the minimum of the {{kind}} {{name}} to {{count}} instances",
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
exports.CLOUD_CONCURRENCY_SENTENCE = {
|
|
94
|
+
one: "Let at most {{count}} copy of the {{kind}} {{name}} run at once",
|
|
95
|
+
other: "Let at most {{count}} copies of the {{kind}} {{name}} run at once",
|
|
96
|
+
};
|
|
97
|
+
// The longest name a sentence shows; the command under it is whole.
|
|
98
|
+
const MAX_SHOWN_NAME_LENGTH = 96;
|
|
99
|
+
// Where an id the catalog has no kind for breaks into words.
|
|
100
|
+
const ID_WORD_SEPARATOR = /[/:]/;
|
|
101
|
+
function shown(text) {
|
|
102
|
+
return text.length > MAX_SHOWN_NAME_LENGTH
|
|
103
|
+
? `${text.slice(0, MAX_SHOWN_NAME_LENGTH)}...`
|
|
104
|
+
: text;
|
|
105
|
+
}
|
|
106
|
+
/*
|
|
107
|
+
* The short name a resource's id carries: an ECS service's or a database's
|
|
108
|
+
* name, an EC2 instance's id, a Lambda function (and its alias), a queue.
|
|
109
|
+
*/
|
|
110
|
+
function getCloudResourceShortName(resource) {
|
|
111
|
+
const parts = resource.parts || {};
|
|
112
|
+
if (parts["functionName"]) {
|
|
113
|
+
return shown(parts["alias"]
|
|
114
|
+
? `${parts["functionName"]}:${parts["alias"]}`
|
|
115
|
+
: parts["functionName"]);
|
|
116
|
+
}
|
|
117
|
+
const name = parts["name"] || parts["instanceId"] || parts["queueName"] || "";
|
|
118
|
+
if (name) {
|
|
119
|
+
return shown(name);
|
|
120
|
+
}
|
|
121
|
+
// The id's last word: what is left of an id the catalog has no kind for.
|
|
122
|
+
const words = resource.id.split(ID_WORD_SEPARATOR);
|
|
123
|
+
return shown(words[words.length - 1] || resource.id);
|
|
124
|
+
}
|
|
125
|
+
function readCount(value) {
|
|
126
|
+
return typeof value === "number" && Number.isInteger(value) && value > 0
|
|
127
|
+
? value
|
|
128
|
+
: null;
|
|
129
|
+
}
|
|
130
|
+
function describeParsedChange(command, translator) {
|
|
131
|
+
const resource = command.resource;
|
|
132
|
+
if (!resource || !resource.kind) {
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
const kindKey = `${resource.provider}:${resource.kind}`;
|
|
136
|
+
const kindName = exports.CLOUD_KIND_WORDS[kindKey];
|
|
137
|
+
if (!kindName) {
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
const name = getCloudResourceShortName(resource);
|
|
141
|
+
const values = {
|
|
142
|
+
kind: (0, Translator_1.translatableTerm)(kindName),
|
|
143
|
+
name,
|
|
144
|
+
};
|
|
145
|
+
const flags = command.flags || {};
|
|
146
|
+
const operation = command.operation.name;
|
|
147
|
+
let sentence = null;
|
|
148
|
+
switch (operation) {
|
|
149
|
+
case "restart-service":
|
|
150
|
+
sentence = translator.translateTemplate(exports.CLOUD_CHANGE_SENTENCES.restartService, values);
|
|
151
|
+
break;
|
|
152
|
+
case "start-instance":
|
|
153
|
+
sentence = translator.translateTemplate(exports.CLOUD_CHANGE_SENTENCES.startInstance, values);
|
|
154
|
+
break;
|
|
155
|
+
case "reboot-instance":
|
|
156
|
+
sentence = translator.translateTemplate(exports.CLOUD_CHANGE_SENTENCES.rebootInstance, values);
|
|
157
|
+
break;
|
|
158
|
+
case "stop-instance":
|
|
159
|
+
sentence = translator.translateTemplate(exports.CLOUD_CHANGE_SENTENCES.stopInstance, values);
|
|
160
|
+
break;
|
|
161
|
+
case "fail-over-database":
|
|
162
|
+
sentence = translator.translateTemplate(exports.CLOUD_CHANGE_SENTENCES.failOverDatabase, values);
|
|
163
|
+
break;
|
|
164
|
+
case "redrive-queue":
|
|
165
|
+
sentence = translator.translateTemplate(exports.CLOUD_CHANGE_SENTENCES.redriveQueue, values);
|
|
166
|
+
break;
|
|
167
|
+
case "scale-out":
|
|
168
|
+
case "scale-in": {
|
|
169
|
+
const count = readCount(flags["count"]);
|
|
170
|
+
const unit = SCALE_UNITS[kindKey];
|
|
171
|
+
if (count === null || !unit) {
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
sentence = translator.translatePlural(exports.CLOUD_SCALE_SENTENCES[operation === "scale-out" ? "out" : "in"][unit], count, values);
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
case "roll-back-service": {
|
|
178
|
+
const slot = flags["slot"];
|
|
179
|
+
const to = flags["to"];
|
|
180
|
+
if (typeof slot === "string" && slot) {
|
|
181
|
+
sentence = translator.translateTemplate(exports.CLOUD_CHANGE_SENTENCES.swapSlot, Object.assign(Object.assign({}, values), { slot: shown(slot) }));
|
|
182
|
+
}
|
|
183
|
+
else if (typeof to === "string" && to) {
|
|
184
|
+
sentence = translator.translateTemplate(exports.CLOUD_CHANGE_SENTENCES.rollBackToVersion, Object.assign(Object.assign({}, values), { version: shown(to) }));
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
sentence = translator.translateTemplate(exports.CLOUD_CHANGE_SENTENCES.rollBackToPrevious, values);
|
|
188
|
+
}
|
|
189
|
+
break;
|
|
190
|
+
}
|
|
191
|
+
case "set-concurrency": {
|
|
192
|
+
const value = flags["value"];
|
|
193
|
+
const count = readCount(value);
|
|
194
|
+
if (count !== null) {
|
|
195
|
+
sentence = translator.translatePlural(exports.CLOUD_CONCURRENCY_SENTENCE, count, values);
|
|
196
|
+
}
|
|
197
|
+
else if (value === "none" || value === null) {
|
|
198
|
+
sentence = translator.translateTemplate(exports.CLOUD_CHANGE_SENTENCES.removeConcurrencyLimit, values);
|
|
199
|
+
}
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
default:
|
|
203
|
+
return null;
|
|
204
|
+
}
|
|
205
|
+
if (!sentence) {
|
|
206
|
+
return null;
|
|
207
|
+
}
|
|
208
|
+
return { operation, kindName, resourceName: name, sentence };
|
|
209
|
+
}
|
|
210
|
+
/*
|
|
211
|
+
* A cloud change in plain words, in the translator's language (English when
|
|
212
|
+
* none is given). `resourceType` is the agent's (AwsAccount,
|
|
213
|
+
* AzureSubscription, GoogleCloudProject). Null for anything that is not a
|
|
214
|
+
* change of the catalog: a read, a dry run, another resource's command, a
|
|
215
|
+
* command that does not parse. Never throws.
|
|
216
|
+
*/
|
|
217
|
+
function describeCloudChange(data) {
|
|
218
|
+
try {
|
|
219
|
+
const provider = (0, CloudOperationCatalog_1.getCloudCatalogProvider)(data.resourceType);
|
|
220
|
+
if (!provider || typeof data.command !== "string") {
|
|
221
|
+
return null;
|
|
222
|
+
}
|
|
223
|
+
const tokens = (0, ResourceCommandPolicyCore_1.tokenizeResourceCommand)(data.command);
|
|
224
|
+
if (!tokens.argv) {
|
|
225
|
+
return null;
|
|
226
|
+
}
|
|
227
|
+
const parse = (0, CloudOperationCatalog_1.parseCloudCommand)(provider, tokens.argv);
|
|
228
|
+
if (!parse.ok) {
|
|
229
|
+
return null;
|
|
230
|
+
}
|
|
231
|
+
return describeParsedChange(parse.command, data.translator || (0, Translator_1.createTranslator)(undefined, Translator_1.DEFAULT_LANGUAGE));
|
|
232
|
+
}
|
|
233
|
+
catch (_a) {
|
|
234
|
+
return null;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
// Every kind the catalog knows, with its words (for the suites).
|
|
238
|
+
function getCloudKindWordsKeys() {
|
|
239
|
+
return CloudOperationCatalog_1.CLOUD_RESOURCE_KINDS.map((spec) => {
|
|
240
|
+
return `${spec.provider}:${spec.kind}`;
|
|
241
|
+
});
|
|
242
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import commonJsModule from "./CloudChangeWords.js";
|
|
2
|
+
export const CLOUD_CHANGE_SENTENCES = commonJsModule.CLOUD_CHANGE_SENTENCES;
|
|
3
|
+
export const CLOUD_CONCURRENCY_SENTENCE = commonJsModule.CLOUD_CONCURRENCY_SENTENCE;
|
|
4
|
+
export const CLOUD_KIND_WORDS = commonJsModule.CLOUD_KIND_WORDS;
|
|
5
|
+
export const CLOUD_SCALE_SENTENCES = commonJsModule.CLOUD_SCALE_SENTENCES;
|
|
6
|
+
export const describeCloudChange = commonJsModule.describeCloudChange;
|
|
7
|
+
export const getCloudKindWordsKeys = commonJsModule.getCloudKindWordsKeys;
|
|
8
|
+
export const getCloudResourceShortName = commonJsModule.getCloudResourceShortName;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { AiRemediationCommand } from "../../Types/AutoRemediation/AiRemediationCommandPlan.mjs";
|
|
2
|
+
export declare function getRemediationChangeKey(command: Pick<AiRemediationCommand, "stepType" | "command" | "runnerId" | "kubernetesClusterId" | "resourceType" | "resourceId">): string | null;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { AiRemediationCommand } from "../../Types/AutoRemediation/AiRemediationCommandPlan";
|
|
2
|
+
export declare function getRemediationChangeKey(command: Pick<AiRemediationCommand, "stepType" | "command" | "runnerId" | "kubernetesClusterId" | "resourceType" | "resourceId">): string | null;
|