@oneuptime/common 9.2.16 → 9.2.18

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.
Files changed (133) hide show
  1. package/Models/DatabaseModels/CodeRepository.ts +664 -0
  2. package/Models/DatabaseModels/Index.ts +8 -0
  3. package/Models/DatabaseModels/LlmLog.ts +818 -0
  4. package/Models/DatabaseModels/LlmProvider.ts +21 -0
  5. package/Models/DatabaseModels/Project.ts +206 -0
  6. package/Models/DatabaseModels/ServiceCatalogCodeRepository.ts +549 -0
  7. package/Server/API/AIBillingAPI.ts +126 -0
  8. package/Server/API/AlertAPI.ts +139 -0
  9. package/Server/API/GitHubAPI.ts +360 -0
  10. package/Server/API/IncidentAPI.ts +258 -0
  11. package/Server/API/ScheduledMaintenanceAPI.ts +164 -0
  12. package/Server/EnvironmentConfig.ts +44 -0
  13. package/Server/Infrastructure/Postgres/SchemaMigrations/1765580181582-MigrationName.ts +79 -0
  14. package/Server/Infrastructure/Postgres/SchemaMigrations/1765633554715-MigrationName.ts +75 -0
  15. package/Server/Infrastructure/Postgres/SchemaMigrations/1765801357168-MigrationName.ts +32 -0
  16. package/Server/Infrastructure/Postgres/SchemaMigrations/1765810218488-MigrationName.ts +69 -0
  17. package/Server/Infrastructure/Postgres/SchemaMigrations/1765830758857-MigrationName.ts +111 -0
  18. package/Server/Infrastructure/Postgres/SchemaMigrations/1765834537501-MigrationName.ts +39 -0
  19. package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +12 -0
  20. package/Server/Services/AIBillingService.ts +247 -0
  21. package/Server/Services/AIService.ts +238 -0
  22. package/Server/Services/CodeRepositoryService.ts +10 -0
  23. package/Server/Services/IncidentService.ts +88 -0
  24. package/Server/Services/Index.ts +2 -0
  25. package/Server/Services/LlmLogService.ts +14 -0
  26. package/Server/Services/LlmProviderService.ts +58 -0
  27. package/Server/Services/ServiceCatalogCodeRepositoryService.ts +55 -0
  28. package/Server/Utils/AI/AlertAIContextBuilder.ts +264 -0
  29. package/Server/Utils/AI/IncidentAIContextBuilder.ts +710 -0
  30. package/Server/Utils/AI/ScheduledMaintenanceAIContextBuilder.ts +345 -0
  31. package/Server/Utils/CodeRepository/GitHub/GitHub.ts +226 -0
  32. package/Server/Utils/LLM/LLMService.ts +276 -0
  33. package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.ts +166 -0
  34. package/Server/Utils/Workspace/Slack/Slack.ts +134 -0
  35. package/Server/Utils/Workspace/Workspace.ts +126 -0
  36. package/Tests/Types/Domain.test.ts +24 -3
  37. package/Types/CodeRepository/CodeRepositoryType.ts +1 -1
  38. package/Types/Domain.ts +21 -24
  39. package/Types/LlmLogStatus.ts +7 -0
  40. package/Types/Permission.ts +87 -0
  41. package/Types/ServiceCatalog/CodeRepositoryImprovementAction.ts +9 -0
  42. package/UI/Components/AI/AILoader.tsx +95 -0
  43. package/UI/Components/AI/GenerateFromAIModal.tsx +432 -0
  44. package/UI/Components/Modal/Modal.tsx +6 -1
  45. package/build/dist/Models/DatabaseModels/CodeRepository.js +689 -0
  46. package/build/dist/Models/DatabaseModels/CodeRepository.js.map +1 -0
  47. package/build/dist/Models/DatabaseModels/Index.js +7 -0
  48. package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
  49. package/build/dist/Models/DatabaseModels/LlmLog.js +856 -0
  50. package/build/dist/Models/DatabaseModels/LlmLog.js.map +1 -0
  51. package/build/dist/Models/DatabaseModels/LlmProvider.js +22 -0
  52. package/build/dist/Models/DatabaseModels/LlmProvider.js.map +1 -1
  53. package/build/dist/Models/DatabaseModels/Project.js +220 -0
  54. package/build/dist/Models/DatabaseModels/Project.js.map +1 -1
  55. package/build/dist/Models/DatabaseModels/ServiceCatalogCodeRepository.js +565 -0
  56. package/build/dist/Models/DatabaseModels/ServiceCatalogCodeRepository.js.map +1 -0
  57. package/build/dist/Server/API/AIBillingAPI.js +58 -0
  58. package/build/dist/Server/API/AIBillingAPI.js.map +1 -0
  59. package/build/dist/Server/API/AlertAPI.js +94 -0
  60. package/build/dist/Server/API/AlertAPI.js.map +1 -0
  61. package/build/dist/Server/API/GitHubAPI.js +207 -0
  62. package/build/dist/Server/API/GitHubAPI.js.map +1 -0
  63. package/build/dist/Server/API/IncidentAPI.js +171 -1
  64. package/build/dist/Server/API/IncidentAPI.js.map +1 -1
  65. package/build/dist/Server/API/ScheduledMaintenanceAPI.js +103 -0
  66. package/build/dist/Server/API/ScheduledMaintenanceAPI.js.map +1 -0
  67. package/build/dist/Server/EnvironmentConfig.js +31 -0
  68. package/build/dist/Server/EnvironmentConfig.js.map +1 -1
  69. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1765580181582-MigrationName.js +34 -0
  70. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1765580181582-MigrationName.js.map +1 -0
  71. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1765633554715-MigrationName.js +32 -0
  72. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1765633554715-MigrationName.js.map +1 -0
  73. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1765801357168-MigrationName.js +38 -0
  74. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1765801357168-MigrationName.js.map +1 -0
  75. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1765810218488-MigrationName.js +30 -0
  76. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1765810218488-MigrationName.js.map +1 -0
  77. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1765830758857-MigrationName.js +44 -0
  78. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1765830758857-MigrationName.js.map +1 -0
  79. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1765834537501-MigrationName.js +22 -0
  80. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1765834537501-MigrationName.js.map +1 -0
  81. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +12 -0
  82. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
  83. package/build/dist/Server/Services/AIBillingService.js +187 -0
  84. package/build/dist/Server/Services/AIBillingService.js.map +1 -0
  85. package/build/dist/Server/Services/AIService.js +184 -0
  86. package/build/dist/Server/Services/AIService.js.map +1 -0
  87. package/build/dist/Server/Services/CodeRepositoryService.js +9 -0
  88. package/build/dist/Server/Services/CodeRepositoryService.js.map +1 -0
  89. package/build/dist/Server/Services/IncidentService.js +60 -0
  90. package/build/dist/Server/Services/IncidentService.js.map +1 -1
  91. package/build/dist/Server/Services/Index.js +2 -0
  92. package/build/dist/Server/Services/Index.js.map +1 -1
  93. package/build/dist/Server/Services/LlmLogService.js +13 -0
  94. package/build/dist/Server/Services/LlmLogService.js.map +1 -0
  95. package/build/dist/Server/Services/LlmProviderService.js +65 -0
  96. package/build/dist/Server/Services/LlmProviderService.js.map +1 -1
  97. package/build/dist/Server/Services/ServiceCatalogCodeRepositoryService.js +54 -0
  98. package/build/dist/Server/Services/ServiceCatalogCodeRepositoryService.js.map +1 -0
  99. package/build/dist/Server/Utils/AI/AlertAIContextBuilder.js +238 -0
  100. package/build/dist/Server/Utils/AI/AlertAIContextBuilder.js.map +1 -0
  101. package/build/dist/Server/Utils/AI/IncidentAIContextBuilder.js +597 -0
  102. package/build/dist/Server/Utils/AI/IncidentAIContextBuilder.js.map +1 -0
  103. package/build/dist/Server/Utils/AI/ScheduledMaintenanceAIContextBuilder.js +311 -0
  104. package/build/dist/Server/Utils/AI/ScheduledMaintenanceAIContextBuilder.js.map +1 -0
  105. package/build/dist/Server/Utils/CodeRepository/GitHub/GitHub.js +163 -0
  106. package/build/dist/Server/Utils/CodeRepository/GitHub/GitHub.js.map +1 -1
  107. package/build/dist/Server/Utils/LLM/LLMService.js +225 -0
  108. package/build/dist/Server/Utils/LLM/LLMService.js.map +1 -0
  109. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js +110 -0
  110. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js.map +1 -1
  111. package/build/dist/Server/Utils/Workspace/Slack/Slack.js +89 -0
  112. package/build/dist/Server/Utils/Workspace/Slack/Slack.js.map +1 -1
  113. package/build/dist/Server/Utils/Workspace/Workspace.js +80 -0
  114. package/build/dist/Server/Utils/Workspace/Workspace.js.map +1 -1
  115. package/build/dist/Tests/Types/Domain.test.js +19 -3
  116. package/build/dist/Tests/Types/Domain.test.js.map +1 -1
  117. package/build/dist/Types/CodeRepository/CodeRepositoryType.js +1 -1
  118. package/build/dist/Types/CodeRepository/CodeRepositoryType.js.map +1 -1
  119. package/build/dist/Types/Domain.js +18 -16
  120. package/build/dist/Types/Domain.js.map +1 -1
  121. package/build/dist/Types/LlmLogStatus.js +8 -0
  122. package/build/dist/Types/LlmLogStatus.js.map +1 -0
  123. package/build/dist/Types/Permission.js +74 -0
  124. package/build/dist/Types/Permission.js.map +1 -1
  125. package/build/dist/Types/ServiceCatalog/CodeRepositoryImprovementAction.js +10 -0
  126. package/build/dist/Types/ServiceCatalog/CodeRepositoryImprovementAction.js.map +1 -0
  127. package/build/dist/UI/Components/AI/AILoader.js +64 -0
  128. package/build/dist/UI/Components/AI/AILoader.js.map +1 -0
  129. package/build/dist/UI/Components/AI/GenerateFromAIModal.js +320 -0
  130. package/build/dist/UI/Components/AI/GenerateFromAIModal.js.map +1 -0
  131. package/build/dist/UI/Components/Modal/Modal.js +6 -1
  132. package/build/dist/UI/Components/Modal/Modal.js.map +1 -1
  133. package/package.json +1 -1
@@ -0,0 +1,597 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import IncidentService from "../../Services/IncidentService";
11
+ import IncidentStateTimelineService from "../../Services/IncidentStateTimelineService";
12
+ import IncidentInternalNoteService from "../../Services/IncidentInternalNoteService";
13
+ import IncidentPublicNoteService from "../../Services/IncidentPublicNoteService";
14
+ import WorkspaceUtil from "../Workspace/Workspace";
15
+ import WorkspaceProjectAuthTokenService from "../../Services/WorkspaceProjectAuthTokenService";
16
+ import logger from "../Logger";
17
+ import CaptureSpan from "../Telemetry/CaptureSpan";
18
+ import OneUptimeDate from "../../../Types/Date";
19
+ import SortOrder from "../../../Types/BaseDatabase/SortOrder";
20
+ export default class IncidentAIContextBuilder {
21
+ static async buildIncidentContext(data) {
22
+ const incident = await IncidentService.findOneById({
23
+ id: data.incidentId,
24
+ select: {
25
+ _id: true,
26
+ title: true,
27
+ description: true,
28
+ createdAt: true,
29
+ postmortemNote: true,
30
+ remediationNotes: true,
31
+ rootCause: true,
32
+ customFields: true,
33
+ projectId: true,
34
+ incidentSeverity: {
35
+ name: true,
36
+ color: true,
37
+ },
38
+ currentIncidentState: {
39
+ name: true,
40
+ color: true,
41
+ },
42
+ monitors: {
43
+ name: true,
44
+ },
45
+ labels: {
46
+ name: true,
47
+ color: true,
48
+ },
49
+ postUpdatesToWorkspaceChannels: true,
50
+ },
51
+ props: {
52
+ isRoot: true,
53
+ },
54
+ });
55
+ if (!incident) {
56
+ throw new Error("Incident not found");
57
+ }
58
+ // Fetch state timeline
59
+ const stateTimeline = await IncidentStateTimelineService.findBy({
60
+ query: {
61
+ incidentId: data.incidentId,
62
+ },
63
+ select: {
64
+ _id: true,
65
+ createdAt: true,
66
+ startsAt: true,
67
+ endsAt: true,
68
+ rootCause: true,
69
+ incidentState: {
70
+ name: true,
71
+ color: true,
72
+ },
73
+ createdByUser: {
74
+ name: true,
75
+ email: true,
76
+ },
77
+ },
78
+ sort: {
79
+ startsAt: SortOrder.Ascending,
80
+ },
81
+ limit: 100,
82
+ skip: 0,
83
+ props: {
84
+ isRoot: true,
85
+ },
86
+ });
87
+ // Fetch internal notes
88
+ const internalNotes = await IncidentInternalNoteService.findBy({
89
+ query: {
90
+ incidentId: data.incidentId,
91
+ },
92
+ select: {
93
+ _id: true,
94
+ note: true,
95
+ createdAt: true,
96
+ createdByUser: {
97
+ name: true,
98
+ email: true,
99
+ },
100
+ },
101
+ sort: {
102
+ createdAt: SortOrder.Ascending,
103
+ },
104
+ limit: 100,
105
+ skip: 0,
106
+ props: {
107
+ isRoot: true,
108
+ },
109
+ });
110
+ // Fetch public notes
111
+ const publicNotes = await IncidentPublicNoteService.findBy({
112
+ query: {
113
+ incidentId: data.incidentId,
114
+ },
115
+ select: {
116
+ _id: true,
117
+ note: true,
118
+ createdAt: true,
119
+ postedAt: true,
120
+ createdByUser: {
121
+ name: true,
122
+ email: true,
123
+ },
124
+ },
125
+ sort: {
126
+ createdAt: SortOrder.Ascending,
127
+ },
128
+ limit: 100,
129
+ skip: 0,
130
+ props: {
131
+ isRoot: true,
132
+ },
133
+ });
134
+ // Fetch workspace messages if requested and channels exist
135
+ let workspaceMessages = [];
136
+ const workspaceChannels = incident.postUpdatesToWorkspaceChannels;
137
+ if (data.includeWorkspaceMessages &&
138
+ workspaceChannels &&
139
+ workspaceChannels.length > 0 &&
140
+ incident.projectId) {
141
+ try {
142
+ const fetchParams = {
143
+ projectId: incident.projectId,
144
+ workspaceChannels: workspaceChannels,
145
+ limit: data.workspaceMessageLimit || 500,
146
+ };
147
+ if (incident.createdAt) {
148
+ fetchParams.oldestTimestamp = incident.createdAt;
149
+ }
150
+ workspaceMessages =
151
+ await this.getWorkspaceMessagesForIncident(fetchParams);
152
+ }
153
+ catch (error) {
154
+ logger.error(`Error fetching workspace messages: ${error}`);
155
+ // Continue without workspace messages
156
+ }
157
+ }
158
+ return {
159
+ incident,
160
+ stateTimeline,
161
+ internalNotes,
162
+ publicNotes,
163
+ workspaceMessages,
164
+ };
165
+ }
166
+ static formatIncidentContextForPostmortem(contextData, template) {
167
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
168
+ const { incident, stateTimeline, internalNotes, publicNotes, workspaceMessages, } = contextData;
169
+ let contextText = "";
170
+ // Basic incident information
171
+ contextText += "# Incident Information\n\n";
172
+ contextText += `**Title:** ${incident.title || "N/A"}\n\n`;
173
+ contextText += `**Description:** ${incident.description || "N/A"}\n\n`;
174
+ contextText += `**Severity:** ${((_a = incident.incidentSeverity) === null || _a === void 0 ? void 0 : _a.name) || "N/A"}\n\n`;
175
+ contextText += `**Current State:** ${((_b = incident.currentIncidentState) === null || _b === void 0 ? void 0 : _b.name) || "N/A"}\n\n`;
176
+ contextText += `**Created At:** ${incident.createdAt ? OneUptimeDate.getDateAsFormattedString(incident.createdAt) : "N/A"}\n\n`;
177
+ // Affected monitors
178
+ if (incident.monitors && incident.monitors.length > 0) {
179
+ contextText += "**Affected Monitors:** ";
180
+ contextText += incident.monitors
181
+ .map((m) => {
182
+ return m.name;
183
+ })
184
+ .join(", ");
185
+ contextText += "\n\n";
186
+ }
187
+ // Labels
188
+ if (incident.labels && incident.labels.length > 0) {
189
+ contextText += "**Labels:** ";
190
+ contextText += incident.labels
191
+ .map((l) => {
192
+ return l.name;
193
+ })
194
+ .join(", ");
195
+ contextText += "\n\n";
196
+ }
197
+ // Root cause if available
198
+ if (incident.rootCause) {
199
+ contextText += `**Root Cause:** ${incident.rootCause}\n\n`;
200
+ }
201
+ // Remediation notes if available
202
+ if (incident.remediationNotes) {
203
+ contextText += `**Remediation Notes:** ${incident.remediationNotes}\n\n`;
204
+ }
205
+ // State timeline
206
+ if (stateTimeline.length > 0) {
207
+ contextText += "# State Timeline\n\n";
208
+ for (const timeline of stateTimeline) {
209
+ const startTime = timeline.startsAt
210
+ ? OneUptimeDate.getDateAsFormattedString(timeline.startsAt)
211
+ : "N/A";
212
+ const stateName = ((_d = (_c = timeline.incidentState) === null || _c === void 0 ? void 0 : _c.name) === null || _d === void 0 ? void 0 : _d.toString()) || "Unknown";
213
+ const createdBy = ((_f = (_e = timeline.createdByUser) === null || _e === void 0 ? void 0 : _e.name) === null || _f === void 0 ? void 0 : _f.toString()) ||
214
+ ((_h = (_g = timeline.createdByUser) === null || _g === void 0 ? void 0 : _g.email) === null || _h === void 0 ? void 0 : _h.toString()) ||
215
+ "System";
216
+ contextText += `- **${startTime}**: State changed to **${stateName}** by ${createdBy}\n`;
217
+ if (timeline.rootCause) {
218
+ contextText += ` - Root cause noted: ${timeline.rootCause}\n`;
219
+ }
220
+ }
221
+ contextText += "\n";
222
+ }
223
+ // Internal notes
224
+ if (internalNotes.length > 0) {
225
+ contextText += "# Internal Notes (Private)\n\n";
226
+ for (const note of internalNotes) {
227
+ const noteTime = note.createdAt
228
+ ? OneUptimeDate.getDateAsFormattedString(note.createdAt)
229
+ : "N/A";
230
+ const createdBy = ((_k = (_j = note.createdByUser) === null || _j === void 0 ? void 0 : _j.name) === null || _k === void 0 ? void 0 : _k.toString()) ||
231
+ ((_m = (_l = note.createdByUser) === null || _l === void 0 ? void 0 : _l.email) === null || _m === void 0 ? void 0 : _m.toString()) ||
232
+ "Unknown";
233
+ contextText += `**[${noteTime}] ${createdBy}:**\n`;
234
+ contextText += `${note.note || "N/A"}\n\n`;
235
+ }
236
+ }
237
+ // Public notes
238
+ if (publicNotes.length > 0) {
239
+ contextText += "# Public Notes\n\n";
240
+ for (const note of publicNotes) {
241
+ const noteTime = note.postedAt
242
+ ? OneUptimeDate.getDateAsFormattedString(note.postedAt)
243
+ : note.createdAt
244
+ ? OneUptimeDate.getDateAsFormattedString(note.createdAt)
245
+ : "N/A";
246
+ const createdBy = ((_p = (_o = note.createdByUser) === null || _o === void 0 ? void 0 : _o.name) === null || _p === void 0 ? void 0 : _p.toString()) ||
247
+ ((_r = (_q = note.createdByUser) === null || _q === void 0 ? void 0 : _q.email) === null || _r === void 0 ? void 0 : _r.toString()) ||
248
+ "Unknown";
249
+ contextText += `**[${noteTime}] ${createdBy}:**\n`;
250
+ contextText += `${note.note || "N/A"}\n\n`;
251
+ }
252
+ }
253
+ // Workspace messages (Slack/Teams)
254
+ if (workspaceMessages.length > 0) {
255
+ contextText += "# Discussion from Incident Channel\n\n";
256
+ contextText += WorkspaceUtil.formatMessagesAsContext(workspaceMessages, {
257
+ includeTimestamp: true,
258
+ includeUsername: true,
259
+ maxLength: 30000,
260
+ });
261
+ contextText += "\n\n";
262
+ }
263
+ // System prompt for postmortem generation
264
+ let systemPrompt;
265
+ if (template) {
266
+ // When a template is provided, strictly fill only the template
267
+ systemPrompt = `You are an expert Site Reliability Engineer (SRE) and incident response specialist. Your task is to fill in an incident postmortem template based on the provided incident data.
268
+
269
+ CRITICAL INSTRUCTIONS:
270
+ - You MUST use ONLY the exact template structure provided below
271
+ - Fill in each section of the template with relevant information from the incident data
272
+ - Do NOT add any new sections, headers, or content that is not part of the template
273
+ - Do NOT add introductions, conclusions, or any text outside the template structure
274
+ - If a section in the template has no relevant data, write "No data available" or leave the placeholder text
275
+ - Be blameless - focus on systemic improvements rather than individual blame
276
+ - Write in a professional, clear, and concise manner
277
+
278
+ TEMPLATE TO FILL (use this exact structure):
279
+
280
+ ${template}`;
281
+ }
282
+ else {
283
+ // When no template is provided, use standard format
284
+ systemPrompt = `You are an expert Site Reliability Engineer (SRE) and incident response specialist. Your task is to generate a comprehensive, well-structured incident postmortem based on the provided incident data.
285
+
286
+ The postmortem should:
287
+ 1. Be written in a blameless manner, focusing on systemic improvements rather than individual blame
288
+ 2. Include a clear executive summary
289
+ 3. Provide a detailed timeline of events
290
+ 4. Identify the root cause(s) and contributing factors
291
+ 5. Outline the impact on users and systems
292
+ 6. List actionable items to prevent recurrence
293
+ 7. Include lessons learned
294
+
295
+ Use a standard incident postmortem format with sections for: Executive Summary, Timeline, Root Cause Analysis, Impact, Action Items, and Lessons Learned.
296
+
297
+ Write in a professional, clear, and concise manner. Use markdown formatting for better readability.`;
298
+ }
299
+ // Build user message based on whether template is provided
300
+ const userMessage = template
301
+ ? `Fill in the template above using ONLY the following incident data. Output only the filled template, nothing else:\n\n${contextText}`
302
+ : `Based on the following incident data, please generate a comprehensive incident postmortem:\n\n${contextText}`;
303
+ // Build messages array
304
+ const messages = [
305
+ {
306
+ role: "system",
307
+ content: systemPrompt,
308
+ },
309
+ {
310
+ role: "user",
311
+ content: userMessage,
312
+ },
313
+ ];
314
+ return {
315
+ contextText,
316
+ systemPrompt,
317
+ messages,
318
+ };
319
+ }
320
+ static formatIncidentContextForNote(contextData, noteType, template) {
321
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
322
+ const { incident, stateTimeline, internalNotes, publicNotes, workspaceMessages, } = contextData;
323
+ let contextText = "";
324
+ // Basic incident information
325
+ contextText += "# Incident Information\n\n";
326
+ contextText += `**Title:** ${incident.title || "N/A"}\n\n`;
327
+ contextText += `**Description:** ${incident.description || "N/A"}\n\n`;
328
+ contextText += `**Severity:** ${((_a = incident.incidentSeverity) === null || _a === void 0 ? void 0 : _a.name) || "N/A"}\n\n`;
329
+ contextText += `**Current State:** ${((_b = incident.currentIncidentState) === null || _b === void 0 ? void 0 : _b.name) || "N/A"}\n\n`;
330
+ contextText += `**Created At:** ${incident.createdAt ? OneUptimeDate.getDateAsFormattedString(incident.createdAt) : "N/A"}\n\n`;
331
+ // Affected monitors
332
+ if (incident.monitors && incident.monitors.length > 0) {
333
+ contextText += "**Affected Monitors:** ";
334
+ contextText += incident.monitors
335
+ .map((m) => {
336
+ return m.name;
337
+ })
338
+ .join(", ");
339
+ contextText += "\n\n";
340
+ }
341
+ // Labels
342
+ if (incident.labels && incident.labels.length > 0) {
343
+ contextText += "**Labels:** ";
344
+ contextText += incident.labels
345
+ .map((l) => {
346
+ return l.name;
347
+ })
348
+ .join(", ");
349
+ contextText += "\n\n";
350
+ }
351
+ // Root cause if available
352
+ if (incident.rootCause) {
353
+ contextText += `**Root Cause:** ${incident.rootCause}\n\n`;
354
+ }
355
+ // State timeline
356
+ if (stateTimeline.length > 0) {
357
+ contextText += "# State Timeline\n\n";
358
+ for (const timeline of stateTimeline) {
359
+ const startTime = timeline.startsAt
360
+ ? OneUptimeDate.getDateAsFormattedString(timeline.startsAt)
361
+ : "N/A";
362
+ const stateName = ((_d = (_c = timeline.incidentState) === null || _c === void 0 ? void 0 : _c.name) === null || _d === void 0 ? void 0 : _d.toString()) || "Unknown";
363
+ const createdBy = ((_f = (_e = timeline.createdByUser) === null || _e === void 0 ? void 0 : _e.name) === null || _f === void 0 ? void 0 : _f.toString()) ||
364
+ ((_h = (_g = timeline.createdByUser) === null || _g === void 0 ? void 0 : _g.email) === null || _h === void 0 ? void 0 : _h.toString()) ||
365
+ "System";
366
+ contextText += `- **${startTime}**: State changed to **${stateName}** by ${createdBy}\n`;
367
+ if (timeline.rootCause) {
368
+ contextText += ` - Root cause noted: ${timeline.rootCause}\n`;
369
+ }
370
+ }
371
+ contextText += "\n";
372
+ }
373
+ // Include internal notes for context (for both note types)
374
+ if (internalNotes.length > 0) {
375
+ contextText += "# Internal Notes (Private)\n\n";
376
+ for (const note of internalNotes) {
377
+ const noteTime = note.createdAt
378
+ ? OneUptimeDate.getDateAsFormattedString(note.createdAt)
379
+ : "N/A";
380
+ const createdBy = ((_k = (_j = note.createdByUser) === null || _j === void 0 ? void 0 : _j.name) === null || _k === void 0 ? void 0 : _k.toString()) ||
381
+ ((_m = (_l = note.createdByUser) === null || _l === void 0 ? void 0 : _l.email) === null || _m === void 0 ? void 0 : _m.toString()) ||
382
+ "Unknown";
383
+ contextText += `**[${noteTime}] ${createdBy}:**\n`;
384
+ contextText += `${note.note || "N/A"}\n\n`;
385
+ }
386
+ }
387
+ // Public notes
388
+ if (publicNotes.length > 0) {
389
+ contextText += "# Public Notes\n\n";
390
+ for (const note of publicNotes) {
391
+ const noteTime = note.postedAt
392
+ ? OneUptimeDate.getDateAsFormattedString(note.postedAt)
393
+ : note.createdAt
394
+ ? OneUptimeDate.getDateAsFormattedString(note.createdAt)
395
+ : "N/A";
396
+ const createdBy = ((_p = (_o = note.createdByUser) === null || _o === void 0 ? void 0 : _o.name) === null || _p === void 0 ? void 0 : _p.toString()) ||
397
+ ((_r = (_q = note.createdByUser) === null || _q === void 0 ? void 0 : _q.email) === null || _r === void 0 ? void 0 : _r.toString()) ||
398
+ "Unknown";
399
+ contextText += `**[${noteTime}] ${createdBy}:**\n`;
400
+ contextText += `${note.note || "N/A"}\n\n`;
401
+ }
402
+ }
403
+ // Workspace messages (Slack/Teams)
404
+ if (workspaceMessages.length > 0) {
405
+ contextText += "# Discussion from Incident Channel\n\n";
406
+ contextText += WorkspaceUtil.formatMessagesAsContext(workspaceMessages, {
407
+ includeTimestamp: true,
408
+ includeUsername: true,
409
+ maxLength: 20000,
410
+ });
411
+ contextText += "\n\n";
412
+ }
413
+ // System prompt for note generation
414
+ let systemPrompt;
415
+ if (noteType === "public") {
416
+ if (template) {
417
+ systemPrompt = `You are an expert incident communicator. Your task is to fill in a public incident note template based on the provided incident data.
418
+
419
+ CRITICAL INSTRUCTIONS:
420
+ - You MUST use ONLY the exact template structure provided below
421
+ - Fill in each section of the template with relevant information from the incident data
422
+ - Do NOT add any new sections, headers, or content that is not part of the template
423
+ - Do NOT add introductions, conclusions, or any text outside the template structure
424
+ - Write in a professional, clear, and customer-friendly manner
425
+ - Focus on what customers need to know: impact, current status, and next steps
426
+ - Avoid technical jargon - keep it understandable for non-technical readers
427
+ - Be concise but informative
428
+
429
+ TEMPLATE TO FILL (use this exact structure):
430
+
431
+ ${template}`;
432
+ }
433
+ else {
434
+ systemPrompt = `You are an expert incident communicator. Your task is to generate a public incident note that will be visible to customers on the status page.
435
+
436
+ The note should:
437
+ 1. Be written in a professional, customer-friendly tone
438
+ 2. Clearly communicate the current status of the incident
439
+ 3. Explain the impact on users without excessive technical details
440
+ 4. Provide information about what is being done to resolve the issue
441
+ 5. Set appropriate expectations about resolution timing if known
442
+ 6. Be concise but informative
443
+
444
+ DO NOT include:
445
+ - Internal technical details that customers don't need
446
+ - Blame or finger-pointing
447
+ - Confidential information
448
+ - Excessive jargon
449
+
450
+ Write in markdown format for better readability.`;
451
+ }
452
+ }
453
+ else if (template) {
454
+ // Internal note with template
455
+ systemPrompt = `You are an expert Site Reliability Engineer (SRE). Your task is to fill in an internal incident note template based on the provided incident data.
456
+
457
+ CRITICAL INSTRUCTIONS:
458
+ - You MUST use ONLY the exact template structure provided below
459
+ - Fill in each section of the template with relevant information from the incident data
460
+ - Do NOT add any new sections, headers, or content that is not part of the template
461
+ - Do NOT add introductions, conclusions, or any text outside the template structure
462
+ - Be technical and detailed - this is for the internal team
463
+ - Include relevant technical details, metrics, and observations
464
+
465
+ TEMPLATE TO FILL (use this exact structure):
466
+
467
+ ${template}`;
468
+ }
469
+ else {
470
+ // Internal note without template
471
+ systemPrompt = `You are an expert Site Reliability Engineer (SRE). Your task is to generate an internal incident note for the response team.
472
+
473
+ The note should:
474
+ 1. Provide technical details about the current situation
475
+ 2. Document observations, findings, or actions taken
476
+ 3. Include relevant metrics or error messages if mentioned in the context
477
+ 4. Be detailed enough to help team members understand the situation
478
+ 5. Use technical language appropriate for the engineering team
479
+
480
+ Write in markdown format for better readability. Be thorough and technical.`;
481
+ }
482
+ // Build user message
483
+ const userMessage = template
484
+ ? `Fill in the template above using ONLY the following incident data. Output only the filled template, nothing else:\n\n${contextText}`
485
+ : `Based on the following incident data, please generate ${noteType === "public" ? "a customer-facing public" : "an internal technical"} incident note:\n\n${contextText}`;
486
+ // Build messages array
487
+ const messages = [
488
+ {
489
+ role: "system",
490
+ content: systemPrompt,
491
+ },
492
+ {
493
+ role: "user",
494
+ content: userMessage,
495
+ },
496
+ ];
497
+ return {
498
+ contextText,
499
+ systemPrompt,
500
+ messages,
501
+ };
502
+ }
503
+ static buildGenericAIContext(data) {
504
+ let userContent = data.userPrompt;
505
+ if (data.context) {
506
+ userContent = `${data.userPrompt}\n\nContext:\n${data.context}`;
507
+ }
508
+ const messages = [
509
+ {
510
+ role: "system",
511
+ content: data.systemPrompt,
512
+ },
513
+ {
514
+ role: "user",
515
+ content: userContent,
516
+ },
517
+ ];
518
+ return {
519
+ contextText: data.context || "",
520
+ systemPrompt: data.systemPrompt,
521
+ messages,
522
+ };
523
+ }
524
+ static async getWorkspaceMessagesForIncident(data) {
525
+ const allMessages = [];
526
+ for (const channel of data.workspaceChannels) {
527
+ try {
528
+ // Get auth token for this workspace type
529
+ const projectAuth = await WorkspaceProjectAuthTokenService.getProjectAuth({
530
+ projectId: data.projectId,
531
+ workspaceType: channel.workspaceType,
532
+ });
533
+ if (!projectAuth || !projectAuth.authToken) {
534
+ logger.debug(`No auth token found for workspace type: ${channel.workspaceType}`);
535
+ continue;
536
+ }
537
+ const messagesParams = {
538
+ channelId: channel.id,
539
+ authToken: projectAuth.authToken,
540
+ projectId: data.projectId,
541
+ workspaceType: channel.workspaceType,
542
+ };
543
+ if (channel.teamId) {
544
+ messagesParams.teamId = channel.teamId;
545
+ }
546
+ if (data.limit !== undefined) {
547
+ messagesParams.limit = data.limit;
548
+ }
549
+ if (data.oldestTimestamp) {
550
+ messagesParams.oldestTimestamp = data.oldestTimestamp;
551
+ }
552
+ const messages = await WorkspaceUtil.getChannelMessages(messagesParams);
553
+ allMessages.push(...messages);
554
+ }
555
+ catch (error) {
556
+ logger.error(`Error fetching messages from channel ${channel.id}: ${error}`);
557
+ // Continue with other channels even if one fails
558
+ }
559
+ }
560
+ // Sort all messages by timestamp
561
+ allMessages.sort((a, b) => {
562
+ return a.timestamp.getTime() - b.timestamp.getTime();
563
+ });
564
+ return allMessages;
565
+ }
566
+ }
567
+ __decorate([
568
+ CaptureSpan(),
569
+ __metadata("design:type", Function),
570
+ __metadata("design:paramtypes", [Object]),
571
+ __metadata("design:returntype", Promise)
572
+ ], IncidentAIContextBuilder, "buildIncidentContext", null);
573
+ __decorate([
574
+ CaptureSpan(),
575
+ __metadata("design:type", Function),
576
+ __metadata("design:paramtypes", [Object, String]),
577
+ __metadata("design:returntype", Object)
578
+ ], IncidentAIContextBuilder, "formatIncidentContextForPostmortem", null);
579
+ __decorate([
580
+ CaptureSpan(),
581
+ __metadata("design:type", Function),
582
+ __metadata("design:paramtypes", [Object, String, String]),
583
+ __metadata("design:returntype", Object)
584
+ ], IncidentAIContextBuilder, "formatIncidentContextForNote", null);
585
+ __decorate([
586
+ CaptureSpan(),
587
+ __metadata("design:type", Function),
588
+ __metadata("design:paramtypes", [Object]),
589
+ __metadata("design:returntype", Object)
590
+ ], IncidentAIContextBuilder, "buildGenericAIContext", null);
591
+ __decorate([
592
+ CaptureSpan(),
593
+ __metadata("design:type", Function),
594
+ __metadata("design:paramtypes", [Object]),
595
+ __metadata("design:returntype", Promise)
596
+ ], IncidentAIContextBuilder, "getWorkspaceMessagesForIncident", null);
597
+ //# sourceMappingURL=IncidentAIContextBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IncidentAIContextBuilder.js","sourceRoot":"","sources":["../../../../../Server/Utils/AI/IncidentAIContextBuilder.ts"],"names":[],"mappings":";;;;;;;;;AAKA,OAAO,eAAe,MAAM,gCAAgC,CAAC;AAC7D,OAAO,4BAA4B,MAAM,6CAA6C,CAAC;AACvF,OAAO,2BAA2B,MAAM,4CAA4C,CAAC;AACrF,OAAO,yBAAyB,MAAM,0CAA0C,CAAC;AACjF,OAAO,aAA0C,MAAM,wBAAwB,CAAC;AAChF,OAAO,gCAAgC,MAAM,iDAAiD,CAAC;AAE/F,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,WAAW,MAAM,0BAA0B,CAAC;AACnD,OAAO,aAAa,MAAM,qBAAqB,CAAC;AAChD,OAAO,SAAS,MAAM,uCAAuC,CAAC;AAmB9D,MAAM,CAAC,OAAO,OAAO,wBAAwB;IAEvB,AAAb,MAAM,CAAC,KAAK,CAAC,oBAAoB,C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