@oneuptime/common 11.4.1 → 11.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (321) hide show
  1. package/Models/DatabaseModels/AIRun.ts +50 -0
  2. package/Models/DatabaseModels/AlertSeverity.ts +6 -0
  3. package/Models/DatabaseModels/IncidentSeverity.ts +6 -0
  4. package/Models/DatabaseModels/Index.ts +16 -0
  5. package/Models/DatabaseModels/IoTDeviceCredential.ts +471 -0
  6. package/Models/DatabaseModels/LlmLog.ts +56 -0
  7. package/Models/DatabaseModels/LlmProvider.ts +33 -0
  8. package/Models/DatabaseModels/NetworkDevice.ts +1385 -0
  9. package/Models/DatabaseModels/NetworkDeviceDiscoveryScan.ts +717 -0
  10. package/Models/DatabaseModels/NetworkDeviceLabelRule.ts +514 -0
  11. package/Models/DatabaseModels/NetworkDeviceOwnerRule.ts +596 -0
  12. package/Models/DatabaseModels/NetworkDeviceOwnerTeam.ts +487 -0
  13. package/Models/DatabaseModels/NetworkDeviceOwnerUser.ts +486 -0
  14. package/Models/DatabaseModels/NetworkInterface.ts +563 -0
  15. package/Models/DatabaseModels/Project.ts +145 -0
  16. package/Models/DatabaseModels/TelemetryEntityRelationship.ts +54 -0
  17. package/Server/API/AIInvestigationAPI.ts +131 -63
  18. package/Server/API/AlertAPI.ts +5 -0
  19. package/Server/API/IncidentAPI.ts +10 -0
  20. package/Server/API/IncidentEpisodeAPI.ts +5 -0
  21. package/Server/API/LlmProviderAPI.ts +4 -0
  22. package/Server/API/ScheduledMaintenanceAPI.ts +5 -0
  23. package/Server/Infrastructure/Postgres/SchemaMigrations/1783650000000-AddAdditionalParamsToLlmProvider.ts +19 -0
  24. package/Server/Infrastructure/Postgres/SchemaMigrations/1783695782697-AddCacheTokenColumnsToLlmLog.ts +25 -0
  25. package/Server/Infrastructure/Postgres/SchemaMigrations/1783701585317-AddAlertInvestigationGating.ts +31 -0
  26. package/Server/Infrastructure/Postgres/SchemaMigrations/1783702431535-AddAiDailyAutonomousTokenLimitToProject.ts +19 -0
  27. package/Server/Infrastructure/Postgres/SchemaMigrations/1783720000000-AddNetworkDeviceTables.ts +105 -0
  28. package/Server/Infrastructure/Postgres/SchemaMigrations/1783721121260-AddAttemptCountToAIRun.ts +15 -0
  29. package/Server/Infrastructure/Postgres/SchemaMigrations/1783730000000-AddNetworkDeviceOwnersAndRules.ts +192 -0
  30. package/Server/Infrastructure/Postgres/SchemaMigrations/1783740000000-AddNetworkDeviceDiscoveryScan.ts +37 -0
  31. package/Server/Infrastructure/Postgres/SchemaMigrations/1783750000000-AddLldpNeighborsToNetworkDevice.ts +19 -0
  32. package/Server/Infrastructure/Postgres/SchemaMigrations/1783760576655-AddInvestigationTuningToProject.ts +25 -0
  33. package/Server/Infrastructure/Postgres/SchemaMigrations/1783762505482-AddTelemetryEntityRelationshipMetrics.ts +31 -0
  34. package/Server/Infrastructure/Postgres/SchemaMigrations/1783780000000-AddIoTDeviceCredentialTable.ts +79 -0
  35. package/Server/Infrastructure/Postgres/SchemaMigrations/1783790000000-AddSnmpV3AuthColumnsToNetworkDevice.ts +49 -0
  36. package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +24 -0
  37. package/Server/Services/AIRunService.ts +58 -0
  38. package/Server/Services/AIService.ts +101 -0
  39. package/Server/Services/IncidentService.ts +14 -41
  40. package/Server/Services/Index.ts +14 -0
  41. package/Server/Services/IoTDeviceCredentialService.ts +351 -0
  42. package/Server/Services/IoTDeviceService.ts +64 -21
  43. package/Server/Services/LlmLogService.ts +26 -0
  44. package/Server/Services/LlmProviderService.ts +3 -0
  45. package/Server/Services/MonitorService.ts +4 -1
  46. package/Server/Services/NetworkDeviceDiscoveryScanService.ts +10 -0
  47. package/Server/Services/NetworkDeviceLabelRuleEngineService.ts +204 -0
  48. package/Server/Services/NetworkDeviceLabelRuleService.ts +14 -0
  49. package/Server/Services/NetworkDeviceOwnerRuleEngineService.ts +222 -0
  50. package/Server/Services/NetworkDeviceOwnerRuleService.ts +14 -0
  51. package/Server/Services/NetworkDeviceOwnerTeamService.ts +10 -0
  52. package/Server/Services/NetworkDeviceOwnerUserService.ts +10 -0
  53. package/Server/Services/NetworkDeviceService.ts +50 -0
  54. package/Server/Services/NetworkInterfaceService.ts +10 -0
  55. package/Server/Services/TelemetryEntityRelationshipService.ts +23 -0
  56. package/Server/Services/TelemetryEntityService.ts +72 -2
  57. package/Server/Utils/AI/Sentinel/AlertInvestigationRunner.ts +244 -12
  58. package/Server/Utils/AI/Sentinel/IncidentInvestigationRunner.ts +92 -19
  59. package/Server/Utils/AI/Sentinel/InvestigationQueue.ts +493 -0
  60. package/Server/Utils/AI/Sentinel/SentinelInvestigationEngine.ts +88 -68
  61. package/Server/Utils/AI/Toolbox/Index.ts +2 -1
  62. package/Server/Utils/AI/Toolbox/MetricTools.ts +391 -0
  63. package/Server/Utils/LLM/LLMService.ts +21 -0
  64. package/Server/Utils/Monitor/Criteria/SnmpMonitorCriteria.ts +170 -2
  65. package/Server/Utils/Monitor/IoTDeviceAbsenceSeries.ts +101 -0
  66. package/Server/Utils/Monitor/MonitorAlert.ts +15 -3
  67. package/Server/Utils/Monitor/MonitorCriteriaEvaluator.ts +1 -1
  68. package/Server/Utils/Monitor/MonitorIncident.ts +19 -3
  69. package/Server/Utils/Monitor/MonitorMetricUtil.ts +87 -0
  70. package/Server/Utils/Monitor/MonitorResource.ts +77 -21
  71. package/Server/Utils/Monitor/MonitorTemplateUtil.ts +1 -1
  72. package/Server/Utils/Monitor/NetworkDeviceHydrationUtil.ts +201 -0
  73. package/Server/Utils/Monitor/NetworkInventoryUtil.ts +215 -0
  74. package/Server/Utils/Monitor/SnmpInterfaceRateUtil.ts +169 -0
  75. package/Tests/Server/Services/AIServiceDailyBudget.test.ts +173 -0
  76. package/Tests/Server/Services/IncidentInternalNoteAnnouncement.test.ts +97 -0
  77. package/Tests/Server/Services/IoTDeviceService.test.ts +54 -0
  78. package/Tests/Server/Utils/AI/BaselineAnomalyTool.test.ts +253 -0
  79. package/Tests/Server/Utils/AI/LLMServiceToolCalling.test.ts +44 -0
  80. package/Tests/Server/Utils/AI/SentinelAlertGating.test.ts +360 -0
  81. package/Tests/Server/Utils/AI/SentinelInvestigationQueue.test.ts +295 -0
  82. package/Tests/Server/Utils/Monitor/Criteria/SnmpMonitorCriteria.test.ts +59 -0
  83. package/Tests/Server/Utils/Monitor/IoTDeviceAbsenceSeries.test.ts +113 -0
  84. package/Tests/Server/Utils/Monitor/PerSeriesRecoveryResolution.test.ts +198 -0
  85. package/Tests/Types/Monitor/MonitorType.test.ts +1 -1
  86. package/Tests/Utils/Monitor/LatencyMatrixUtil.test.ts +111 -0
  87. package/Types/AI/AIRunStatus.ts +9 -0
  88. package/Types/Dashboard/DashboardComponents/ComponentArgument.ts +0 -1
  89. package/Types/Dashboard/DashboardComponents/DashboardLogChartComponent.ts +8 -3
  90. package/Types/LlmLogStatus.ts +1 -0
  91. package/Types/Monitor/CriteriaFilter.ts +5 -0
  92. package/Types/Monitor/IotAlertTemplates.ts +22 -3
  93. package/Types/Monitor/LatencyMatrix.ts +27 -0
  94. package/Types/Monitor/MonitorCriteriaInstance.ts +2 -2
  95. package/Types/Monitor/MonitorMetricType.ts +10 -0
  96. package/Types/Monitor/MonitorStep.ts +36 -11
  97. package/Types/Monitor/MonitorStepNetworkDeviceMonitor.ts +55 -0
  98. package/Types/Monitor/MonitorStepSnmpMonitor.ts +8 -0
  99. package/Types/Monitor/MonitorType.ts +14 -9
  100. package/Types/Monitor/SnmpMonitor/LldpNeighbor.ts +12 -0
  101. package/Types/Monitor/SnmpMonitor/NetworkDeviceAlertPack.ts +116 -0
  102. package/Types/Monitor/SnmpMonitor/NetworkTopology.ts +29 -0
  103. package/Types/Monitor/SnmpMonitor/SnmpInterface.ts +31 -0
  104. package/Types/Monitor/SnmpMonitor/SnmpMonitorResponse.ts +24 -0
  105. package/Types/Monitor/SnmpMonitor/SnmpTrap.ts +20 -0
  106. package/Types/Monitor/SnmpMonitor/SnmpVendorTemplate.ts +173 -0
  107. package/Types/Permission.ts +314 -0
  108. package/Types/Probe/ProbeMonitorResponse.ts +8 -0
  109. package/UI/Components/Icon/Icon.tsx +8 -6
  110. package/UI/Components/MonitorTemplateVariables/TemplateVariablesCatalog.ts +2 -2
  111. package/UI/Components/Tabs/Tabs.tsx +10 -1
  112. package/UI/Utils/Navigation.ts +10 -1
  113. package/Utils/Dashboard/Components/DashboardLogChartComponent.ts +16 -21
  114. package/Utils/Monitor/LatencyMatrixUtil.ts +162 -0
  115. package/Utils/Monitor/MonitorMetricType.ts +71 -1
  116. package/Utils/Monitor/NetworkTopologyUtil.ts +159 -0
  117. package/Utils/Telemetry/EntityRelationship.ts +11 -0
  118. package/build/dist/Models/DatabaseModels/AIRun.js +52 -0
  119. package/build/dist/Models/DatabaseModels/AIRun.js.map +1 -1
  120. package/build/dist/Models/DatabaseModels/AlertSeverity.js +6 -0
  121. package/build/dist/Models/DatabaseModels/AlertSeverity.js.map +1 -1
  122. package/build/dist/Models/DatabaseModels/IncidentSeverity.js +6 -0
  123. package/build/dist/Models/DatabaseModels/IncidentSeverity.js.map +1 -1
  124. package/build/dist/Models/DatabaseModels/Index.js +16 -0
  125. package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
  126. package/build/dist/Models/DatabaseModels/IoTDeviceCredential.js +493 -0
  127. package/build/dist/Models/DatabaseModels/IoTDeviceCredential.js.map +1 -0
  128. package/build/dist/Models/DatabaseModels/LlmLog.js +58 -0
  129. package/build/dist/Models/DatabaseModels/LlmLog.js.map +1 -1
  130. package/build/dist/Models/DatabaseModels/LlmProvider.js +33 -0
  131. package/build/dist/Models/DatabaseModels/LlmProvider.js.map +1 -1
  132. package/build/dist/Models/DatabaseModels/NetworkDevice.js +1426 -0
  133. package/build/dist/Models/DatabaseModels/NetworkDevice.js.map +1 -0
  134. package/build/dist/Models/DatabaseModels/NetworkDeviceDiscoveryScan.js +738 -0
  135. package/build/dist/Models/DatabaseModels/NetworkDeviceDiscoveryScan.js.map +1 -0
  136. package/build/dist/Models/DatabaseModels/NetworkDeviceLabelRule.js +522 -0
  137. package/build/dist/Models/DatabaseModels/NetworkDeviceLabelRule.js.map +1 -0
  138. package/build/dist/Models/DatabaseModels/NetworkDeviceOwnerRule.js +603 -0
  139. package/build/dist/Models/DatabaseModels/NetworkDeviceOwnerRule.js.map +1 -0
  140. package/build/dist/Models/DatabaseModels/NetworkDeviceOwnerTeam.js +503 -0
  141. package/build/dist/Models/DatabaseModels/NetworkDeviceOwnerTeam.js.map +1 -0
  142. package/build/dist/Models/DatabaseModels/NetworkDeviceOwnerUser.js +502 -0
  143. package/build/dist/Models/DatabaseModels/NetworkDeviceOwnerUser.js.map +1 -0
  144. package/build/dist/Models/DatabaseModels/NetworkInterface.js +589 -0
  145. package/build/dist/Models/DatabaseModels/NetworkInterface.js.map +1 -0
  146. package/build/dist/Models/DatabaseModels/Project.js +147 -0
  147. package/build/dist/Models/DatabaseModels/Project.js.map +1 -1
  148. package/build/dist/Models/DatabaseModels/TelemetryEntityRelationship.js +57 -0
  149. package/build/dist/Models/DatabaseModels/TelemetryEntityRelationship.js.map +1 -1
  150. package/build/dist/Server/API/AIInvestigationAPI.js +95 -55
  151. package/build/dist/Server/API/AIInvestigationAPI.js.map +1 -1
  152. package/build/dist/Server/API/AlertAPI.js +5 -0
  153. package/build/dist/Server/API/AlertAPI.js.map +1 -1
  154. package/build/dist/Server/API/IncidentAPI.js +10 -0
  155. package/build/dist/Server/API/IncidentAPI.js.map +1 -1
  156. package/build/dist/Server/API/IncidentEpisodeAPI.js +5 -0
  157. package/build/dist/Server/API/IncidentEpisodeAPI.js.map +1 -1
  158. package/build/dist/Server/API/LlmProviderAPI.js +5 -7
  159. package/build/dist/Server/API/LlmProviderAPI.js.map +1 -1
  160. package/build/dist/Server/API/ScheduledMaintenanceAPI.js +5 -0
  161. package/build/dist/Server/API/ScheduledMaintenanceAPI.js.map +1 -1
  162. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783650000000-AddAdditionalParamsToLlmProvider.js +12 -0
  163. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783650000000-AddAdditionalParamsToLlmProvider.js.map +1 -0
  164. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783695782697-AddCacheTokenColumnsToLlmLog.js +14 -0
  165. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783695782697-AddCacheTokenColumnsToLlmLog.js.map +1 -0
  166. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783701585317-AddAlertInvestigationGating.js +18 -0
  167. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783701585317-AddAlertInvestigationGating.js.map +1 -0
  168. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783702431535-AddAiDailyAutonomousTokenLimitToProject.js +12 -0
  169. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783702431535-AddAiDailyAutonomousTokenLimitToProject.js.map +1 -0
  170. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783720000000-AddNetworkDeviceTables.js +51 -0
  171. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783720000000-AddNetworkDeviceTables.js.map +1 -0
  172. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783721121260-AddAttemptCountToAIRun.js +12 -0
  173. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783721121260-AddAttemptCountToAIRun.js.map +1 -0
  174. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783730000000-AddNetworkDeviceOwnersAndRules.js +101 -0
  175. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783730000000-AddNetworkDeviceOwnersAndRules.js.map +1 -0
  176. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783740000000-AddNetworkDeviceDiscoveryScan.js +18 -0
  177. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783740000000-AddNetworkDeviceDiscoveryScan.js.map +1 -0
  178. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783750000000-AddLldpNeighborsToNetworkDevice.js +12 -0
  179. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783750000000-AddLldpNeighborsToNetworkDevice.js.map +1 -0
  180. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783760576655-AddInvestigationTuningToProject.js +14 -0
  181. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783760576655-AddInvestigationTuningToProject.js.map +1 -0
  182. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783762505482-AddTelemetryEntityRelationshipMetrics.js +16 -0
  183. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783762505482-AddTelemetryEntityRelationshipMetrics.js.map +1 -0
  184. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783780000000-AddIoTDeviceCredentialTable.js +38 -0
  185. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783780000000-AddIoTDeviceCredentialTable.js.map +1 -0
  186. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783790000000-AddSnmpV3AuthColumnsToNetworkDevice.js +22 -0
  187. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783790000000-AddSnmpV3AuthColumnsToNetworkDevice.js.map +1 -0
  188. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +24 -0
  189. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
  190. package/build/dist/Server/Services/AIRunService.js +33 -0
  191. package/build/dist/Server/Services/AIRunService.js.map +1 -1
  192. package/build/dist/Server/Services/AIService.js +82 -9
  193. package/build/dist/Server/Services/AIService.js.map +1 -1
  194. package/build/dist/Server/Services/IncidentService.js +14 -25
  195. package/build/dist/Server/Services/IncidentService.js.map +1 -1
  196. package/build/dist/Server/Services/Index.js +14 -0
  197. package/build/dist/Server/Services/Index.js.map +1 -1
  198. package/build/dist/Server/Services/IoTDeviceCredentialService.js +321 -0
  199. package/build/dist/Server/Services/IoTDeviceCredentialService.js.map +1 -0
  200. package/build/dist/Server/Services/IoTDeviceService.js +49 -15
  201. package/build/dist/Server/Services/IoTDeviceService.js.map +1 -1
  202. package/build/dist/Server/Services/LlmLogService.js +29 -0
  203. package/build/dist/Server/Services/LlmLogService.js.map +1 -1
  204. package/build/dist/Server/Services/LlmProviderService.js +3 -0
  205. package/build/dist/Server/Services/LlmProviderService.js.map +1 -1
  206. package/build/dist/Server/Services/MonitorService.js +2 -1
  207. package/build/dist/Server/Services/MonitorService.js.map +1 -1
  208. package/build/dist/Server/Services/NetworkDeviceDiscoveryScanService.js +9 -0
  209. package/build/dist/Server/Services/NetworkDeviceDiscoveryScanService.js.map +1 -0
  210. package/build/dist/Server/Services/NetworkDeviceLabelRuleEngineService.js +166 -0
  211. package/build/dist/Server/Services/NetworkDeviceLabelRuleEngineService.js.map +1 -0
  212. package/build/dist/Server/Services/NetworkDeviceLabelRuleService.js +13 -0
  213. package/build/dist/Server/Services/NetworkDeviceLabelRuleService.js.map +1 -0
  214. package/build/dist/Server/Services/NetworkDeviceOwnerRuleEngineService.js +186 -0
  215. package/build/dist/Server/Services/NetworkDeviceOwnerRuleEngineService.js.map +1 -0
  216. package/build/dist/Server/Services/NetworkDeviceOwnerRuleService.js +13 -0
  217. package/build/dist/Server/Services/NetworkDeviceOwnerRuleService.js.map +1 -0
  218. package/build/dist/Server/Services/NetworkDeviceOwnerTeamService.js +9 -0
  219. package/build/dist/Server/Services/NetworkDeviceOwnerTeamService.js.map +1 -0
  220. package/build/dist/Server/Services/NetworkDeviceOwnerUserService.js +9 -0
  221. package/build/dist/Server/Services/NetworkDeviceOwnerUserService.js.map +1 -0
  222. package/build/dist/Server/Services/NetworkDeviceService.js +52 -0
  223. package/build/dist/Server/Services/NetworkDeviceService.js.map +1 -0
  224. package/build/dist/Server/Services/NetworkInterfaceService.js +9 -0
  225. package/build/dist/Server/Services/NetworkInterfaceService.js.map +1 -0
  226. package/build/dist/Server/Services/TelemetryEntityRelationshipService.js +22 -0
  227. package/build/dist/Server/Services/TelemetryEntityRelationshipService.js.map +1 -1
  228. package/build/dist/Server/Services/TelemetryEntityService.js +64 -2
  229. package/build/dist/Server/Services/TelemetryEntityService.js.map +1 -1
  230. package/build/dist/Server/Utils/AI/Sentinel/AlertInvestigationRunner.js +189 -9
  231. package/build/dist/Server/Utils/AI/Sentinel/AlertInvestigationRunner.js.map +1 -1
  232. package/build/dist/Server/Utils/AI/Sentinel/IncidentInvestigationRunner.js +84 -17
  233. package/build/dist/Server/Utils/AI/Sentinel/IncidentInvestigationRunner.js.map +1 -1
  234. package/build/dist/Server/Utils/AI/Sentinel/InvestigationQueue.js +428 -0
  235. package/build/dist/Server/Utils/AI/Sentinel/InvestigationQueue.js.map +1 -0
  236. package/build/dist/Server/Utils/AI/Sentinel/SentinelInvestigationEngine.js +63 -47
  237. package/build/dist/Server/Utils/AI/Sentinel/SentinelInvestigationEngine.js.map +1 -1
  238. package/build/dist/Server/Utils/AI/Toolbox/Index.js +2 -1
  239. package/build/dist/Server/Utils/AI/Toolbox/Index.js.map +1 -1
  240. package/build/dist/Server/Utils/AI/Toolbox/MetricTools.js +300 -0
  241. package/build/dist/Server/Utils/AI/Toolbox/MetricTools.js.map +1 -1
  242. package/build/dist/Server/Utils/LLM/LLMService.js +16 -0
  243. package/build/dist/Server/Utils/LLM/LLMService.js.map +1 -1
  244. package/build/dist/Server/Utils/Monitor/Criteria/SnmpMonitorCriteria.js +130 -2
  245. package/build/dist/Server/Utils/Monitor/Criteria/SnmpMonitorCriteria.js.map +1 -1
  246. package/build/dist/Server/Utils/Monitor/IoTDeviceAbsenceSeries.js +81 -0
  247. package/build/dist/Server/Utils/Monitor/IoTDeviceAbsenceSeries.js.map +1 -0
  248. package/build/dist/Server/Utils/Monitor/MonitorAlert.js +18 -7
  249. package/build/dist/Server/Utils/Monitor/MonitorAlert.js.map +1 -1
  250. package/build/dist/Server/Utils/Monitor/MonitorCriteriaEvaluator.js +1 -1
  251. package/build/dist/Server/Utils/Monitor/MonitorCriteriaEvaluator.js.map +1 -1
  252. package/build/dist/Server/Utils/Monitor/MonitorIncident.js +25 -10
  253. package/build/dist/Server/Utils/Monitor/MonitorIncident.js.map +1 -1
  254. package/build/dist/Server/Utils/Monitor/MonitorMetricUtil.js +69 -3
  255. package/build/dist/Server/Utils/Monitor/MonitorMetricUtil.js.map +1 -1
  256. package/build/dist/Server/Utils/Monitor/MonitorResource.js +76 -30
  257. package/build/dist/Server/Utils/Monitor/MonitorResource.js.map +1 -1
  258. package/build/dist/Server/Utils/Monitor/MonitorTemplateUtil.js +1 -1
  259. package/build/dist/Server/Utils/Monitor/MonitorTemplateUtil.js.map +1 -1
  260. package/build/dist/Server/Utils/Monitor/NetworkDeviceHydrationUtil.js +147 -0
  261. package/build/dist/Server/Utils/Monitor/NetworkDeviceHydrationUtil.js.map +1 -0
  262. package/build/dist/Server/Utils/Monitor/NetworkInventoryUtil.js +167 -0
  263. package/build/dist/Server/Utils/Monitor/NetworkInventoryUtil.js.map +1 -0
  264. package/build/dist/Server/Utils/Monitor/SnmpInterfaceRateUtil.js +93 -0
  265. package/build/dist/Server/Utils/Monitor/SnmpInterfaceRateUtil.js.map +1 -0
  266. package/build/dist/Types/AI/AIRunStatus.js +9 -0
  267. package/build/dist/Types/AI/AIRunStatus.js.map +1 -1
  268. package/build/dist/Types/Dashboard/DashboardComponents/ComponentArgument.js +0 -1
  269. package/build/dist/Types/Dashboard/DashboardComponents/ComponentArgument.js.map +1 -1
  270. package/build/dist/Types/LlmLogStatus.js +1 -0
  271. package/build/dist/Types/LlmLogStatus.js.map +1 -1
  272. package/build/dist/Types/Monitor/CriteriaFilter.js +5 -0
  273. package/build/dist/Types/Monitor/CriteriaFilter.js.map +1 -1
  274. package/build/dist/Types/Monitor/IotAlertTemplates.js +7 -7
  275. package/build/dist/Types/Monitor/IotAlertTemplates.js.map +1 -1
  276. package/build/dist/Types/Monitor/LatencyMatrix.js +2 -0
  277. package/build/dist/Types/Monitor/LatencyMatrix.js.map +1 -0
  278. package/build/dist/Types/Monitor/MonitorCriteriaInstance.js +2 -2
  279. package/build/dist/Types/Monitor/MonitorCriteriaInstance.js.map +1 -1
  280. package/build/dist/Types/Monitor/MonitorMetricType.js +9 -0
  281. package/build/dist/Types/Monitor/MonitorMetricType.js.map +1 -1
  282. package/build/dist/Types/Monitor/MonitorStep.js +22 -9
  283. package/build/dist/Types/Monitor/MonitorStep.js.map +1 -1
  284. package/build/dist/Types/Monitor/MonitorStepNetworkDeviceMonitor.js +36 -0
  285. package/build/dist/Types/Monitor/MonitorStepNetworkDeviceMonitor.js.map +1 -0
  286. package/build/dist/Types/Monitor/MonitorStepSnmpMonitor.js +3 -0
  287. package/build/dist/Types/Monitor/MonitorStepSnmpMonitor.js.map +1 -1
  288. package/build/dist/Types/Monitor/MonitorType.js +14 -9
  289. package/build/dist/Types/Monitor/MonitorType.js.map +1 -1
  290. package/build/dist/Types/Monitor/SnmpMonitor/LldpNeighbor.js +2 -0
  291. package/build/dist/Types/Monitor/SnmpMonitor/LldpNeighbor.js.map +1 -0
  292. package/build/dist/Types/Monitor/SnmpMonitor/NetworkDeviceAlertPack.js +89 -0
  293. package/build/dist/Types/Monitor/SnmpMonitor/NetworkDeviceAlertPack.js.map +1 -0
  294. package/build/dist/Types/Monitor/SnmpMonitor/NetworkTopology.js +2 -0
  295. package/build/dist/Types/Monitor/SnmpMonitor/NetworkTopology.js.map +1 -0
  296. package/build/dist/Types/Monitor/SnmpMonitor/SnmpInterface.js +2 -0
  297. package/build/dist/Types/Monitor/SnmpMonitor/SnmpInterface.js.map +1 -0
  298. package/build/dist/Types/Monitor/SnmpMonitor/SnmpTrap.js +2 -0
  299. package/build/dist/Types/Monitor/SnmpMonitor/SnmpTrap.js.map +1 -0
  300. package/build/dist/Types/Monitor/SnmpMonitor/SnmpVendorTemplate.js +137 -0
  301. package/build/dist/Types/Monitor/SnmpMonitor/SnmpVendorTemplate.js.map +1 -0
  302. package/build/dist/Types/Permission.js +280 -0
  303. package/build/dist/Types/Permission.js.map +1 -1
  304. package/build/dist/UI/Components/Icon/Icon.js +8 -6
  305. package/build/dist/UI/Components/Icon/Icon.js.map +1 -1
  306. package/build/dist/UI/Components/MonitorTemplateVariables/TemplateVariablesCatalog.js +2 -2
  307. package/build/dist/UI/Components/MonitorTemplateVariables/TemplateVariablesCatalog.js.map +1 -1
  308. package/build/dist/UI/Components/Tabs/Tabs.js +3 -1
  309. package/build/dist/UI/Components/Tabs/Tabs.js.map +1 -1
  310. package/build/dist/UI/Utils/Navigation.js +11 -1
  311. package/build/dist/UI/Utils/Navigation.js.map +1 -1
  312. package/build/dist/Utils/Dashboard/Components/DashboardLogChartComponent.js +17 -20
  313. package/build/dist/Utils/Dashboard/Components/DashboardLogChartComponent.js.map +1 -1
  314. package/build/dist/Utils/Monitor/LatencyMatrixUtil.js +89 -0
  315. package/build/dist/Utils/Monitor/LatencyMatrixUtil.js.map +1 -0
  316. package/build/dist/Utils/Monitor/MonitorMetricType.js +68 -1
  317. package/build/dist/Utils/Monitor/MonitorMetricType.js.map +1 -1
  318. package/build/dist/Utils/Monitor/NetworkTopologyUtil.js +112 -0
  319. package/build/dist/Utils/Monitor/NetworkTopologyUtil.js.map +1 -0
  320. package/build/dist/Utils/Telemetry/EntityRelationship.js.map +1 -1
  321. package/package.json +1 -1
@@ -10,9 +10,12 @@ var __metadata = (this && this.__metadata) || function (k, v) {
10
10
  import OneUptimeDate from "../../../../Types/Date";
11
11
  import { Blue500 } from "../../../../Types/BrandColors";
12
12
  import { IncidentFeedEventType } from "../../../../Models/DatabaseModels/IncidentFeed";
13
+ import IncidentInternalNote from "../../../../Models/DatabaseModels/IncidentInternalNote";
13
14
  import IncidentFeedService from "../../../Services/IncidentFeedService";
15
+ import IncidentInternalNoteService from "../../../Services/IncidentInternalNoteService";
14
16
  import IncidentAIContextBuilder from "../IncidentAIContextBuilder";
15
17
  import SentinelInvestigationEngine from "./SentinelInvestigationEngine";
18
+ import SentinelInvestigationQueue from "./InvestigationQueue";
16
19
  import SentinelMemory from "./SentinelMemory";
17
20
  import logger from "../../Logger";
18
21
  import CaptureSpan from "../../Telemetry/CaptureSpan";
@@ -21,18 +24,17 @@ import CaptureSpan from "../../Telemetry/CaptureSpan";
21
24
  *
22
25
  * When a new incident is declared, wakes Sentinel to investigate it (read-only)
23
26
  * and post a cited root-cause analysis into the incident timeline + Slack/Teams
24
- * — before the on-call engineer has finished reading the page. The heavy lifting
25
- * (run lifecycle, the agent loop, confidence gating) lives in the shared
26
- * SentinelInvestigationEngine; this file only assembles incident context and
27
- * posts the result to the incident's feed.
28
- *
29
- * Built on the fire-and-forget async pattern already used throughout
30
- * IncidentService.onCreateSuccess. See Internal/Roadmap/AISentinelExecution.md.
27
+ * — before the on-call engineer has finished reading the page. The trigger only
28
+ * records durable intent (a Queued AIRun via SentinelInvestigationQueue), so a
29
+ * pod restart can no longer orphan an investigation; the heavy lifting (run
30
+ * lifecycle, the agent loop, confidence gating) lives in the shared
31
+ * SentinelInvestigationEngine. See Internal/Roadmap/AISentinelExecution.md.
31
32
  */
32
33
  export default class SentinelIncidentInvestigationRunner {
33
34
  /*
34
35
  * Entry point called (fire-and-forget) from IncidentService.onCreateSuccess.
35
- * Never throws all failures are logged and recorded on the AIRun.
36
+ * Cheap: gates + a Queued AIRun row; execution happens via the queue.
37
+ * Never throws — all failures are logged.
36
38
  */
37
39
  static async investigateNewIncident(data) {
38
40
  const { incidentId, projectId } = data;
@@ -40,6 +42,25 @@ export default class SentinelIncidentInvestigationRunner {
40
42
  if (!(await SentinelInvestigationEngine.isEnabledForProject(projectId, "Incident"))) {
41
43
  return;
42
44
  }
45
+ await SentinelInvestigationQueue.enqueue({
46
+ projectId,
47
+ subjectIncidentId: incidentId,
48
+ });
49
+ }
50
+ catch (error) {
51
+ logger.error(`Sentinel: unexpected error enqueueing investigation for incident ${incidentId.toString()}: ${error}`);
52
+ }
53
+ }
54
+ /*
55
+ * Execute a claimed run: assemble incident context and hand it to the
56
+ * engine. Called by SentinelInvestigationQueue after a successful claim.
57
+ * Never throws — failures are handed to the queue's retry policy so a
58
+ * claimed run is always finalized or requeued.
59
+ */
60
+ static async executeInvestigation(data) {
61
+ const { aiRunId, projectId, incidentId, attemptCount } = data;
62
+ let contextSummary;
63
+ try {
43
64
  const contextData = await IncidentAIContextBuilder.buildIncidentContext({
44
65
  incidentId,
45
66
  includeWorkspaceMessages: false,
@@ -63,11 +84,29 @@ export default class SentinelIncidentInvestigationRunner {
63
84
  })
64
85
  .filter(Boolean),
65
86
  });
66
- await SentinelInvestigationEngine.investigate({
67
- projectId,
87
+ contextSummary =
88
+ this.buildIncidentSummary(contextData) + priorCasesContext;
89
+ }
90
+ catch (error) {
91
+ /*
92
+ * Context assembly failed — the run is claimed, so hand it to the
93
+ * retry policy rather than leaving it Running until the sweeper.
94
+ */
95
+ await SentinelInvestigationQueue.failOrRequeue({
96
+ aiRunId,
97
+ attemptCount,
98
+ errorMessage: `Failed to build incident context: ${error instanceof Error ? error.message : String(error)}`,
99
+ isPermanent: false,
100
+ });
101
+ return;
102
+ }
103
+ await SentinelInvestigationEngine.executeRun({
104
+ aiRunId,
105
+ projectId,
106
+ attemptCount,
107
+ request: {
68
108
  feature: "Sentinel Incident Investigation",
69
- subjectIncidentId: incidentId,
70
- contextSummary: this.buildIncidentSummary(contextData) + priorCasesContext,
109
+ contextSummary,
71
110
  postAnalysis: async (postData) => {
72
111
  await IncidentFeedService.createIncidentFeedItem({
73
112
  incidentId,
@@ -83,12 +122,34 @@ export default class SentinelIncidentInvestigationRunner {
83
122
  sendWorkspaceNotification: postData.isConfident,
84
123
  },
85
124
  });
125
+ /*
126
+ * Also file the RCA as an incident internal note, where responders
127
+ * collaborate. The RootCause feed item above, with its quiet-mode
128
+ * gating, must stay the single notification source, so:
129
+ * ignoreHooks skips the note service's "posted private note" feed
130
+ * item + unconditional workspace ping (workflow triggers and
131
+ * realtime updates still fire), and isOwnerNotified stops the
132
+ * note-posted owner-notification cron from paging owners about it.
133
+ * Best-effort: a note failure must not fail the run after the feed
134
+ * item already posted.
135
+ */
136
+ try {
137
+ const note = new IncidentInternalNote();
138
+ note.incidentId = incidentId;
139
+ note.projectId = projectId;
140
+ note.note = postData.analysisMarkdown;
141
+ note.isOwnerNotified = true;
142
+ await IncidentInternalNoteService.create({
143
+ data: note,
144
+ props: { isRoot: true, ignoreHooks: true },
145
+ });
146
+ }
147
+ catch (error) {
148
+ logger.error(`Sentinel: failed to post RCA internal note for incident ${incidentId.toString()}: ${error}`);
149
+ }
86
150
  },
87
- });
88
- }
89
- catch (error) {
90
- logger.error(`Sentinel: unexpected error investigating incident ${incidentId.toString()}: ${error}`);
91
- }
151
+ },
152
+ });
92
153
  }
93
154
  // Build a compact incident record to seed the investigation.
94
155
  static buildIncidentSummary(contextData) {
@@ -144,4 +205,10 @@ __decorate([
144
205
  __metadata("design:paramtypes", [Object]),
145
206
  __metadata("design:returntype", Promise)
146
207
  ], SentinelIncidentInvestigationRunner, "investigateNewIncident", null);
208
+ __decorate([
209
+ CaptureSpan(),
210
+ __metadata("design:type", Function),
211
+ __metadata("design:paramtypes", [Object]),
212
+ __metadata("design:returntype", Promise)
213
+ ], SentinelIncidentInvestigationRunner, "executeInvestigation", null);
147
214
  //# sourceMappingURL=IncidentInvestigationRunner.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"IncidentInvestigationRunner.js","sourceRoot":"","sources":["../../../../../../Server/Utils/AI/Sentinel/IncidentInvestigationRunner.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,aAAa,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gDAAgD,CAAC;AACvF,OAAO,mBAAmB,MAAM,uCAAuC,CAAC;AACxE,OAAO,wBAEN,MAAM,6BAA6B,CAAC;AACrC,OAAO,2BAA2B,MAAM,+BAA+B,CAAC;AACxE,OAAO,cAAc,MAAM,kBAAk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AM,CAAC,OAAO,CAAC,CAAC;QAEnB,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC3B,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACf,KAAK,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;YACrC,KAAK,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,CAAC;QAC7B,CAAC;QAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CACF;AAhJqB;IADnB,WAAW,EAAE;;;;uEA4Eb"}
1
+ {"version":3,"file":"IncidentInvestigationRunner.js","sourceRoot":"","sources":["../../../../../../Server/Utils/AI/Sentinel/IncidentInvestigationRunner.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,aAAa,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gDAAgD,CAAC;AACvF,OAAO,oBAAoB,MAAM,wDAAwD,CAAC;AAC1F,OAAO,mBAAmB,MAAM,uCAAuC,CAAC;AACxE,OAAO,2BAA2B,MAAM,+CAA+C,CAAC;AACxF,OAAO,wBAEN,MAAM,6BAA6B,CAAC;AACrC,OAAO,2BAA2B,MAAM,+BAA+B,CAAC;AACxE,OAAO,0BAA0B,MAAM,sBAAsB,CAAC;AAC9D,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAE9C,OAAO,MAAM,MAAM,cAAc,CAAC;AAClC,OAAO,WAAW,MAAM,6BAA6B,CAAC;AAEtD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,OAAO,mCAAmC;IACtD;;;;OAIG;IAEiB,AAAb,MAAM,CAAC,KAAK,CAAC,sBAAsB,CAAC,IAG1C;QACC,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;QAEvC,IAAI,CAAC;YACH,IACE,CAAC,CAAC,MAAM,2BAA2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CACF;AAvNqB;IADnB,WAAW,EAAE;;;;uEA0Bb;AASmB;IADnB,WAAW,EAAE;;;;qEAiHb"}
@@ -0,0 +1,428 @@
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 OneUptimeDate from "../../../../Types/Date";
11
+ import AIRunType from "../../../../Types/AI/AIRunType";
12
+ import AIRunStatus from "../../../../Types/AI/AIRunStatus";
13
+ import AIRun from "../../../../Models/DatabaseModels/AIRun";
14
+ import AIRunService from "../../../Services/AIRunService";
15
+ import ProjectService from "../../../Services/ProjectService";
16
+ import AIService from "../../../Services/AIService";
17
+ import SortOrder from "../../../../Types/BaseDatabase/SortOrder";
18
+ import QueryHelper from "../../../Types/Database/QueryHelper";
19
+ import logger from "../../Logger";
20
+ import CaptureSpan from "../../Telemetry/CaptureSpan";
21
+ /*
22
+ * Sentinel — the durable investigation queue (Phase 2's first item; Q1
23
+ * decided as the DB-claim pattern on AIRun rows, no new infrastructure).
24
+ *
25
+ * The problem it replaces: investigations ran as detached in-process
26
+ * promises, so a pod restart orphaned them silently (Deviations log D2).
27
+ *
28
+ * The shape:
29
+ * 1. enqueue() records the durable intent as an AIRun in status Queued
30
+ * BEFORE any expensive work, then immediately tries to process it
31
+ * in-process — same latency as before when the pod stays alive.
32
+ * 2. Claims go through AIRunService.attemptStatusTransition — one
33
+ * conditional UPDATE guarded on BOTH status=Queued and the expected
34
+ * attemptCount — so the enqueueing pod and the poller can race and
35
+ * exactly one wins, and a stale queue snapshot can never claim (or
36
+ * re-number) a run that moved on. attemptCount can therefore never
37
+ * exceed MAX_INVESTIGATION_ATTEMPTS.
38
+ * 3. A Workers poller claims whatever the inline path left behind
39
+ * (pod died, cap was full, budget was exhausted) and expires runs
40
+ * that sat queued past their usefulness window. The poller claims
41
+ * sequentially (so the concurrency cap sees each claim) but executes
42
+ * detached, keeping the every-minute tick fast.
43
+ * 4. Failed attempts requeue (transient errors and stale heartbeats)
44
+ * until MAX_ATTEMPTS, then finalize as Error/Stale — G9's retry
45
+ * policy. Permanent errors (bad configuration) never retry.
46
+ *
47
+ * Mid-run message-level checkpointing is deliberately NOT here: a retried
48
+ * investigation re-runs from the top, which is safe because investigations
49
+ * are read-only until the single postAnalysis at the end.
50
+ */
51
+ // Initial attempt + one retry.
52
+ export const MAX_INVESTIGATION_ATTEMPTS = 2;
53
+ /*
54
+ * G4 cost guardrail: at most this many investigations may be Running per
55
+ * project at once (per-project override in
56
+ * Project.aiMaxConcurrentInvestigations). Enforced at CLAIM time, so a storm
57
+ * queues (bounded by dedupe + severity gates + this TTL) and drains at cap
58
+ * rate instead of being dropped.
59
+ */
60
+ export const DEFAULT_MAX_CONCURRENT_INVESTIGATIONS = 3;
61
+ /*
62
+ * Clamp bounds for the per-project override. Pausing has its own switches
63
+ * (the opt-in toggles, daily limit 0), so the floor is 1, not 0.
64
+ */
65
+ const MIN_CONCURRENT_INVESTIGATIONS = 1;
66
+ const MAX_CONCURRENT_INVESTIGATIONS = 25;
67
+ /*
68
+ * A first-pass RCA is only useful while the incident is fresh. Queued runs
69
+ * older than this are expired rather than run late — this also caps queue
70
+ * growth when the daily budget blocks claiming for hours.
71
+ */
72
+ export const QUEUE_TTL_MINUTES = 30;
73
+ // How many queued runs one poller tick will try to claim.
74
+ const POLLER_BATCH_SIZE = 10;
75
+ export default class SentinelInvestigationQueue {
76
+ /*
77
+ * Record the durable intent to investigate, then try to process it
78
+ * immediately (detached — the poller is the safety net if this pod dies).
79
+ * Callers have already passed the subject-specific gates (opt-in,
80
+ * severity floor, dedupe window).
81
+ */
82
+ static async enqueue(data) {
83
+ const { projectId } = data;
84
+ /*
85
+ * Budget quiet-skip at enqueue: when the daily budget is already
86
+ * exhausted there is no point recording intent that the TTL would
87
+ * expire anyway. Fails cheap (skip) like all the cost gates.
88
+ */
89
+ try {
90
+ const budget = await AIService.getAutonomousDailyBudgetStatus(projectId);
91
+ if (budget.exhausted) {
92
+ logger.debug(`Sentinel: not enqueueing investigation for project ${projectId.toString()} — daily autonomous token budget exhausted (${budget.usedTokensToday} of ${budget.limitInTokens} tokens used today).`);
93
+ return;
94
+ }
95
+ }
96
+ catch (error) {
97
+ logger.error(`Sentinel: budget check failed, not enqueueing investigation: ${error}`);
98
+ return;
99
+ }
100
+ const run = new AIRun();
101
+ run.projectId = projectId;
102
+ run.runType = AIRunType.Investigation;
103
+ run.status = AIRunStatus.Queued;
104
+ if (data.subjectIncidentId) {
105
+ run.triggeredByIncidentId = data.subjectIncidentId;
106
+ }
107
+ if (data.subjectAlertId) {
108
+ run.triggeredByAlertId = data.subjectAlertId;
109
+ }
110
+ if (data.subjectMonitorId) {
111
+ run.monitorId = data.subjectMonitorId;
112
+ }
113
+ let createdRun;
114
+ try {
115
+ createdRun = await AIRunService.create({
116
+ data: run,
117
+ props: { isRoot: true },
118
+ });
119
+ }
120
+ catch (error) {
121
+ logger.error(`Sentinel: failed to enqueue investigation run: ${error}`);
122
+ return;
123
+ }
124
+ // Inline kick — preserves the 1-3 minute RCA latency on the happy path.
125
+ this.processRun({
126
+ id: createdRun.id,
127
+ projectId,
128
+ attemptCount: 0,
129
+ triggeredByIncidentId: data.subjectIncidentId,
130
+ triggeredByAlertId: data.subjectAlertId,
131
+ }).catch((error) => {
132
+ var _a;
133
+ logger.error(`Sentinel: inline processing of queued run ${(_a = createdRun.id) === null || _a === void 0 ? void 0 : _a.toString()} failed: ${error}`);
134
+ });
135
+ }
136
+ /*
137
+ * Claim a queued run and execute it to completion. Safe to call from
138
+ * multiple places concurrently — the claim is one conditional UPDATE, so
139
+ * exactly one caller wins. Leaves the run Queued (for the poller / TTL)
140
+ * when the concurrency cap is full or the budget is exhausted.
141
+ */
142
+ static async processRun(run) {
143
+ try {
144
+ if (!(await this.passesClaimGates(run))) {
145
+ return;
146
+ }
147
+ const attempt = await this.claim(run);
148
+ if (attempt === null) {
149
+ return;
150
+ }
151
+ await this.dispatch(run, attempt);
152
+ }
153
+ catch (error) {
154
+ logger.error(`Sentinel: failed to process queued run ${run.id.toString()}: ${error}`);
155
+ }
156
+ }
157
+ /*
158
+ * One poller tick: expire runs that queued past their usefulness window,
159
+ * then claim a batch of the rest. Claims happen sequentially — each claim
160
+ * sets Running immediately, so the next iteration's concurrency-cap count
161
+ * sees it — but execution is detached so the tick finishes in seconds
162
+ * instead of holding the job open for the length of the investigations.
163
+ * Called every minute from Workers; also the recovery path for runs
164
+ * orphaned by pod restarts.
165
+ */
166
+ static async processQueuedRuns() {
167
+ const expiryThreshold = OneUptimeDate.getSomeMinutesAgo(QUEUE_TTL_MINUTES);
168
+ const expiredRuns = await AIRunService.findBy({
169
+ query: {
170
+ runType: AIRunType.Investigation,
171
+ status: AIRunStatus.Queued,
172
+ createdAt: QueryHelper.lessThan(expiryThreshold),
173
+ },
174
+ select: { _id: true },
175
+ limit: 100,
176
+ skip: 0,
177
+ props: { isRoot: true },
178
+ });
179
+ for (const expired of expiredRuns) {
180
+ await AIRunService.attemptStatusTransition({
181
+ aiRunId: expired.id,
182
+ fromStatus: AIRunStatus.Queued,
183
+ set: {
184
+ status: AIRunStatus.Cancelled,
185
+ completedAt: OneUptimeDate.getCurrentDate(),
186
+ errorMessage: `Expired in the investigation queue after ${QUEUE_TTL_MINUTES} minutes — a first-pass analysis this late would no longer be useful. The project may have been at its concurrency cap or daily token budget.`,
187
+ },
188
+ });
189
+ }
190
+ const queuedRuns = await AIRunService.findBy({
191
+ query: {
192
+ runType: AIRunType.Investigation,
193
+ status: AIRunStatus.Queued,
194
+ },
195
+ select: {
196
+ _id: true,
197
+ projectId: true,
198
+ attemptCount: true,
199
+ triggeredByIncidentId: true,
200
+ triggeredByAlertId: true,
201
+ },
202
+ sort: { createdAt: SortOrder.Ascending },
203
+ limit: POLLER_BATCH_SIZE,
204
+ skip: 0,
205
+ props: { isRoot: true },
206
+ });
207
+ for (const queued of queuedRuns) {
208
+ const ref = {
209
+ id: queued.id,
210
+ projectId: queued.projectId,
211
+ attemptCount: queued.attemptCount || 0,
212
+ triggeredByIncidentId: queued.triggeredByIncidentId,
213
+ triggeredByAlertId: queued.triggeredByAlertId,
214
+ };
215
+ try {
216
+ if (!(await this.passesClaimGates(ref))) {
217
+ continue;
218
+ }
219
+ const attempt = await this.claim(ref);
220
+ if (attempt === null) {
221
+ continue;
222
+ }
223
+ /*
224
+ * Execute detached — the run is claimed (Running + heartbeat), so
225
+ * the sweeper owns recovery if this pod dies mid-flight.
226
+ */
227
+ this.dispatch(ref, attempt).catch((error) => {
228
+ logger.error(`Sentinel: detached execution of run ${ref.id.toString()} failed: ${error}`);
229
+ });
230
+ }
231
+ catch (error) {
232
+ logger.error(`Sentinel: poller failed on queued run ${ref.id.toString()}: ${error}`);
233
+ }
234
+ }
235
+ }
236
+ /*
237
+ * Finalize a failed attempt: requeue transient failures while attempts
238
+ * remain, otherwise mark the run Error. The transition guards on Running
239
+ * so a run that already completed (e.g. only postAnalysis failed) is
240
+ * never clobbered or re-run.
241
+ */
242
+ static async failOrRequeue(data) {
243
+ const truncatedMessage = data.errorMessage.substring(0, 400);
244
+ if (!data.isPermanent && data.attemptCount < MAX_INVESTIGATION_ATTEMPTS) {
245
+ const requeued = await AIRunService.attemptStatusTransition({
246
+ aiRunId: data.aiRunId,
247
+ fromStatus: AIRunStatus.Running,
248
+ set: {
249
+ status: AIRunStatus.Queued,
250
+ errorMessage: `Attempt ${data.attemptCount} failed and the run was requeued: ${truncatedMessage}`,
251
+ },
252
+ });
253
+ if (requeued > 0) {
254
+ logger.debug(`Sentinel: requeued run ${data.aiRunId.toString()} after attempt ${data.attemptCount} failed.`);
255
+ }
256
+ return;
257
+ }
258
+ await AIRunService.attemptStatusTransition({
259
+ aiRunId: data.aiRunId,
260
+ fromStatus: AIRunStatus.Running,
261
+ set: {
262
+ status: AIRunStatus.Error,
263
+ completedAt: OneUptimeDate.getCurrentDate(),
264
+ errorMessage: truncatedMessage,
265
+ },
266
+ });
267
+ }
268
+ /*
269
+ * Called by the stale-run sweeper for an Investigation run whose
270
+ * heartbeat went silent (the pod running it died). Requeues while
271
+ * attempts remain; otherwise marks it Stale as before.
272
+ */
273
+ static async requeueOrMarkStale(run) {
274
+ if ((run.attemptCount || 0) < MAX_INVESTIGATION_ATTEMPTS) {
275
+ const requeued = await AIRunService.attemptStatusTransition({
276
+ aiRunId: run.id,
277
+ fromStatus: AIRunStatus.Running,
278
+ set: {
279
+ status: AIRunStatus.Queued,
280
+ errorMessage: `Attempt ${run.attemptCount} stopped reporting progress (the server processing it may have restarted) and the run was requeued.`,
281
+ },
282
+ });
283
+ if (requeued > 0) {
284
+ return "requeued";
285
+ }
286
+ }
287
+ await AIRunService.attemptStatusTransition({
288
+ aiRunId: run.id,
289
+ fromStatus: AIRunStatus.Running,
290
+ set: {
291
+ status: AIRunStatus.Stale,
292
+ completedAt: OneUptimeDate.getCurrentDate(),
293
+ errorMessage: "The run stopped reporting progress and was marked as stale after exhausting its retry attempts. The server processing it may have restarted.",
294
+ },
295
+ });
296
+ return "stale";
297
+ }
298
+ /*
299
+ * The claim-time cost gates: concurrency cap and daily budget. A run
300
+ * failing these stays Queued — the poller retries and the TTL expires
301
+ * what never fits. Fails cheap (skip) on gate errors.
302
+ */
303
+ static async passesClaimGates(run) {
304
+ var _a;
305
+ // Per-project cap override, defaulting to 3 and clamped to [1, 25].
306
+ const project = await ProjectService.findOneById({
307
+ id: run.projectId,
308
+ select: { aiMaxConcurrentInvestigations: true },
309
+ props: { isRoot: true },
310
+ });
311
+ const concurrencyCap = Math.min(MAX_CONCURRENT_INVESTIGATIONS, Math.max(MIN_CONCURRENT_INVESTIGATIONS, (_a = project === null || project === void 0 ? void 0 : project.aiMaxConcurrentInvestigations) !== null && _a !== void 0 ? _a : DEFAULT_MAX_CONCURRENT_INVESTIGATIONS));
312
+ const runningCount = (await AIRunService.countBy({
313
+ query: {
314
+ projectId: run.projectId,
315
+ runType: AIRunType.Investigation,
316
+ status: AIRunStatus.Running,
317
+ },
318
+ props: { isRoot: true },
319
+ })).toNumber();
320
+ if (runningCount >= concurrencyCap) {
321
+ logger.debug(`Sentinel: leaving run ${run.id.toString()} queued — ${runningCount} investigations already running (cap: ${concurrencyCap}).`);
322
+ return false;
323
+ }
324
+ const budget = await AIService.getAutonomousDailyBudgetStatus(run.projectId);
325
+ if (budget.exhausted) {
326
+ logger.debug(`Sentinel: leaving run ${run.id.toString()} queued — daily autonomous token budget exhausted.`);
327
+ return false;
328
+ }
329
+ return true;
330
+ }
331
+ /*
332
+ * The atomic claim: Queued -> Running, guarded on the attemptCount the
333
+ * caller observed, so a stale queue snapshot can neither double-claim
334
+ * nor reset the attempt numbering. Returns the claimed attempt number,
335
+ * or null when another actor won.
336
+ */
337
+ static async claim(run) {
338
+ const attempt = (run.attemptCount || 0) + 1;
339
+ const claimedCount = await AIRunService.attemptStatusTransition({
340
+ aiRunId: run.id,
341
+ fromStatus: AIRunStatus.Queued,
342
+ expectedAttemptCount: run.attemptCount || 0,
343
+ set: {
344
+ status: AIRunStatus.Running,
345
+ startedAt: OneUptimeDate.getCurrentDate(),
346
+ lastHeartbeatAt: OneUptimeDate.getCurrentDate(),
347
+ attemptCount: attempt,
348
+ },
349
+ });
350
+ if (claimedCount === 0) {
351
+ return null;
352
+ }
353
+ return attempt;
354
+ }
355
+ // Route a claimed run to its subject's executor.
356
+ static async dispatch(run, attempt) {
357
+ if (run.triggeredByIncidentId) {
358
+ /*
359
+ * Lazy require: the runners import this queue to enqueue, so a
360
+ * top-level import here would be circular at module-init time
361
+ * (same pattern as DatabaseService -> AuditLogService).
362
+ */
363
+ const incidentRunner =
364
+ // eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
365
+ require("./IncidentInvestigationRunner").default;
366
+ await incidentRunner.executeInvestigation({
367
+ aiRunId: run.id,
368
+ projectId: run.projectId,
369
+ incidentId: run.triggeredByIncidentId,
370
+ attemptCount: attempt,
371
+ });
372
+ return;
373
+ }
374
+ if (run.triggeredByAlertId) {
375
+ const alertRunner =
376
+ // eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
377
+ require("./AlertInvestigationRunner").default;
378
+ await alertRunner.executeInvestigation({
379
+ aiRunId: run.id,
380
+ projectId: run.projectId,
381
+ alertId: run.triggeredByAlertId,
382
+ attemptCount: attempt,
383
+ });
384
+ return;
385
+ }
386
+ // A queued investigation without a subject cannot be executed.
387
+ await AIRunService.attemptStatusTransition({
388
+ aiRunId: run.id,
389
+ fromStatus: AIRunStatus.Running,
390
+ set: {
391
+ status: AIRunStatus.Error,
392
+ completedAt: OneUptimeDate.getCurrentDate(),
393
+ errorMessage: "Queued investigation has no subject to investigate.",
394
+ },
395
+ });
396
+ }
397
+ }
398
+ __decorate([
399
+ CaptureSpan(),
400
+ __metadata("design:type", Function),
401
+ __metadata("design:paramtypes", [Object]),
402
+ __metadata("design:returntype", Promise)
403
+ ], SentinelInvestigationQueue, "enqueue", null);
404
+ __decorate([
405
+ CaptureSpan(),
406
+ __metadata("design:type", Function),
407
+ __metadata("design:paramtypes", [Object]),
408
+ __metadata("design:returntype", Promise)
409
+ ], SentinelInvestigationQueue, "processRun", null);
410
+ __decorate([
411
+ CaptureSpan(),
412
+ __metadata("design:type", Function),
413
+ __metadata("design:paramtypes", []),
414
+ __metadata("design:returntype", Promise)
415
+ ], SentinelInvestigationQueue, "processQueuedRuns", null);
416
+ __decorate([
417
+ CaptureSpan(),
418
+ __metadata("design:type", Function),
419
+ __metadata("design:paramtypes", [Object]),
420
+ __metadata("design:returntype", Promise)
421
+ ], SentinelInvestigationQueue, "failOrRequeue", null);
422
+ __decorate([
423
+ CaptureSpan(),
424
+ __metadata("design:type", Function),
425
+ __metadata("design:paramtypes", [Object]),
426
+ __metadata("design:returntype", Promise)
427
+ ], SentinelInvestigationQueue, "requeueOrMarkStale", null);
428
+ //# sourceMappingURL=InvestigationQueue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InvestigationQueue.js","sourceRoot":"","sources":["../../../../../../Server/Utils/AI/Sentinel/InvestigationQueue.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,aAAa,MAAM,wBAAwB,CAAC;AACnD,OAAO,SAAS,MAAM,gCAAgC,CAAC;AACvD,OAAO,WAAW,MAAM,kCAAkC,CAAC;AAC3D,OAAO,KAAK,MAAM,yCAAyC,CAAC;AAE5D,OAAO,YAAY,MAAM,gCAAgC,CAAC;AAC1D,OAAO,cAAc,MAAM,kCAAkC,CAAC;AAC9D,OAAO,SAAqC,MAAM,6BAA6B,CAAC;AAChF,OAAO,SAAS,MAAM,0CAA0C,CAAC;AACjE,OAAO,WAAW,MAAM,qCAAqC,CAAC;AAC9D,OAAO,MAAM,MAAM,cAAc,CAAC;AAClC,OAAO,WAAW,MAAM,6BAA6B,CAAC;AAEtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,+BAA+B;AAC/B,MAAM,CAAC,MAAM,0BAA0B,GAAW,CAAC,CAAC;AAEpD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,qCAAqC,GAAW,CAAC,CAAC;AAC/D;;;GAGG;AACH,MAAM,6BAA6B,GAAW,CAAC,CAAC;AAChD,MAAM,6BAA6B,GAAW,EAAE,CAAC;AAEjD;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAW,EAAE,CAAC;AAE5C,0DAA0D;AAC1D,MAAM,iBAAiB,GAAW,EAAE,CAAC;AAUrC,MAAM,CAAC,OAA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