@oneuptime/common 11.4.0 → 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.
- package/Models/DatabaseModels/AIRun.ts +50 -0
- package/Models/DatabaseModels/AlertSeverity.ts +6 -0
- package/Models/DatabaseModels/IncidentSeverity.ts +6 -0
- package/Models/DatabaseModels/Index.ts +16 -0
- package/Models/DatabaseModels/IoTDeviceCredential.ts +471 -0
- package/Models/DatabaseModels/LlmLog.ts +56 -0
- package/Models/DatabaseModels/LlmProvider.ts +33 -0
- package/Models/DatabaseModels/NetworkDevice.ts +1385 -0
- package/Models/DatabaseModels/NetworkDeviceDiscoveryScan.ts +717 -0
- package/Models/DatabaseModels/NetworkDeviceLabelRule.ts +514 -0
- package/Models/DatabaseModels/NetworkDeviceOwnerRule.ts +596 -0
- package/Models/DatabaseModels/NetworkDeviceOwnerTeam.ts +487 -0
- package/Models/DatabaseModels/NetworkDeviceOwnerUser.ts +486 -0
- package/Models/DatabaseModels/NetworkInterface.ts +563 -0
- package/Models/DatabaseModels/Project.ts +145 -0
- package/Models/DatabaseModels/TelemetryEntityRelationship.ts +54 -0
- package/Server/API/AIAgentTaskAPI.ts +10 -24
- package/Server/API/AIInvestigationAPI.ts +131 -63
- package/Server/API/AlertAPI.ts +5 -0
- package/Server/API/IncidentAPI.ts +10 -0
- package/Server/API/IncidentEpisodeAPI.ts +5 -0
- package/Server/API/LlmProviderAPI.ts +4 -0
- package/Server/API/ScheduledMaintenanceAPI.ts +5 -0
- package/Server/API/TelemetryAPI.ts +4 -3
- package/Server/Infrastructure/Postgres/SchemaMigrations/1783650000000-AddAdditionalParamsToLlmProvider.ts +19 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1783695782697-AddCacheTokenColumnsToLlmLog.ts +25 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1783701585317-AddAlertInvestigationGating.ts +31 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1783702431535-AddAiDailyAutonomousTokenLimitToProject.ts +19 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1783720000000-AddNetworkDeviceTables.ts +105 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1783721121260-AddAttemptCountToAIRun.ts +15 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1783730000000-AddNetworkDeviceOwnersAndRules.ts +192 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1783740000000-AddNetworkDeviceDiscoveryScan.ts +37 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1783750000000-AddLldpNeighborsToNetworkDevice.ts +19 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1783760576655-AddInvestigationTuningToProject.ts +25 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1783762505482-AddTelemetryEntityRelationshipMetrics.ts +31 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1783780000000-AddIoTDeviceCredentialTable.ts +79 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1783790000000-AddSnmpV3AuthColumnsToNetworkDevice.ts +49 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +24 -0
- package/Server/Services/AIAgentTaskService.ts +62 -0
- package/Server/Services/AIRunService.ts +58 -0
- package/Server/Services/AIService.ts +101 -0
- package/Server/Services/AnalyticsDatabaseService.ts +27 -0
- package/Server/Services/IncidentService.ts +14 -41
- package/Server/Services/Index.ts +14 -0
- package/Server/Services/IoTDeviceCredentialService.ts +351 -0
- package/Server/Services/IoTDeviceService.ts +64 -21
- package/Server/Services/LlmLogService.ts +26 -0
- package/Server/Services/LlmProviderService.ts +3 -0
- package/Server/Services/LogAggregationService.ts +29 -11
- package/Server/Services/MetricService.ts +603 -13
- package/Server/Services/MonitorService.ts +4 -1
- package/Server/Services/NetworkDeviceDiscoveryScanService.ts +10 -0
- package/Server/Services/NetworkDeviceLabelRuleEngineService.ts +204 -0
- package/Server/Services/NetworkDeviceLabelRuleService.ts +14 -0
- package/Server/Services/NetworkDeviceOwnerRuleEngineService.ts +222 -0
- package/Server/Services/NetworkDeviceOwnerRuleService.ts +14 -0
- package/Server/Services/NetworkDeviceOwnerTeamService.ts +10 -0
- package/Server/Services/NetworkDeviceOwnerUserService.ts +10 -0
- package/Server/Services/NetworkDeviceService.ts +50 -0
- package/Server/Services/NetworkInterfaceService.ts +10 -0
- package/Server/Services/TelemetryEntityRelationshipService.ts +23 -0
- package/Server/Services/TelemetryEntityService.ts +72 -2
- package/Server/Utils/AI/Sentinel/AlertInvestigationRunner.ts +244 -12
- package/Server/Utils/AI/Sentinel/IncidentInvestigationRunner.ts +92 -19
- package/Server/Utils/AI/Sentinel/InvestigationQueue.ts +493 -0
- package/Server/Utils/AI/Sentinel/README.md +10 -0
- package/Server/Utils/AI/Sentinel/SentinelInvestigationEngine.ts +88 -68
- package/Server/Utils/AI/Toolbox/Index.ts +2 -1
- package/Server/Utils/AI/Toolbox/MetricTools.ts +391 -0
- package/Server/Utils/LLM/LLMService.ts +21 -0
- package/Server/Utils/Monitor/Criteria/APIRequestCriteria.ts +44 -0
- package/Server/Utils/Monitor/Criteria/SnmpMonitorCriteria.ts +170 -2
- package/Server/Utils/Monitor/IoTDeviceAbsenceSeries.ts +101 -0
- package/Server/Utils/Monitor/MonitorAlert.ts +15 -3
- package/Server/Utils/Monitor/MonitorCriteriaEvaluator.ts +1 -1
- package/Server/Utils/Monitor/MonitorIncident.ts +19 -3
- package/Server/Utils/Monitor/MonitorMetricUtil.ts +195 -2
- package/Server/Utils/Monitor/MonitorResource.ts +77 -21
- package/Server/Utils/Monitor/MonitorTemplateUtil.ts +1 -1
- package/Server/Utils/Monitor/NetworkDeviceHydrationUtil.ts +201 -0
- package/Server/Utils/Monitor/NetworkInventoryUtil.ts +215 -0
- package/Server/Utils/Monitor/SnmpInterfaceRateUtil.ts +169 -0
- package/Tests/Server/Services/AIAgentTaskServiceClaim.test.ts +146 -0
- package/Tests/Server/Services/AIServiceDailyBudget.test.ts +173 -0
- package/Tests/Server/Services/IncidentInternalNoteAnnouncement.test.ts +97 -0
- package/Tests/Server/Services/IoTDeviceService.test.ts +54 -0
- package/Tests/Server/Services/LogAggregationService.test.ts +22 -0
- package/Tests/Server/Services/MetricServiceAggregate.test.ts +194 -0
- package/Tests/Server/Utils/AI/BaselineAnomalyTool.test.ts +253 -0
- package/Tests/Server/Utils/AI/LLMServiceToolCalling.test.ts +44 -0
- package/Tests/Server/Utils/AI/SentinelAlertGating.test.ts +360 -0
- package/Tests/Server/Utils/AI/SentinelInvestigationQueue.test.ts +295 -0
- package/Tests/Server/Utils/Monitor/Criteria/SnmpMonitorCriteria.test.ts +59 -0
- package/Tests/Server/Utils/Monitor/IoTDeviceAbsenceSeries.test.ts +113 -0
- package/Tests/Server/Utils/Monitor/PerSeriesRecoveryResolution.test.ts +198 -0
- package/Tests/Types/AI/AIAgentTaskStatus.test.ts +86 -0
- package/Tests/Types/BaseDatabase/AggregationIntervalUtil.test.ts +127 -0
- package/Tests/Types/BaseDatabase/DatabaseCommonInteractionPropsUtil.test.ts +152 -0
- package/Tests/Types/Monitor/MonitorType.test.ts +1 -1
- package/Tests/Types/Trace/TraceRecordingRuleDefinition.test.ts +308 -0
- package/Tests/UI/Components/Dropdown.test.tsx +17 -0
- package/Tests/UI/Components/EntityDropdown.test.tsx +130 -0
- package/Tests/UI/Components/Modal.test.tsx +144 -2
- package/Tests/UI/Components/TelemetrySearchBar.test.tsx +90 -0
- package/Tests/UI/Utils/Theme.test.ts +161 -0
- package/Tests/Utils/Monitor/LatencyMatrixUtil.test.ts +111 -0
- package/Types/AI/AIRunStatus.ts +9 -0
- package/Types/BaseDatabase/AggregateBy.ts +12 -0
- package/Types/Dashboard/DashboardComponentType.ts +1 -0
- package/Types/Dashboard/DashboardComponents/DashboardLogChartComponent.ts +24 -0
- package/Types/Dashboard/DashboardTemplates.ts +9 -1
- package/Types/LlmLogStatus.ts +1 -0
- package/Types/Monitor/CriteriaFilter.ts +9 -0
- package/Types/Monitor/HttpPhaseTimings.ts +16 -0
- package/Types/Monitor/IotAlertTemplates.ts +22 -3
- package/Types/Monitor/LatencyMatrix.ts +27 -0
- package/Types/Monitor/MonitorCriteriaInstance.ts +2 -2
- package/Types/Monitor/MonitorMetricType.ts +27 -0
- package/Types/Monitor/MonitorStep.ts +36 -11
- package/Types/Monitor/MonitorStepNetworkDeviceMonitor.ts +55 -0
- package/Types/Monitor/MonitorStepSnmpMonitor.ts +8 -0
- package/Types/Monitor/MonitorType.ts +14 -9
- package/Types/Monitor/PingMonitor/PingMonitorResponse.ts +20 -0
- package/Types/Monitor/SnmpMonitor/LldpNeighbor.ts +12 -0
- package/Types/Monitor/SnmpMonitor/NetworkDeviceAlertPack.ts +116 -0
- package/Types/Monitor/SnmpMonitor/NetworkTopology.ts +29 -0
- package/Types/Monitor/SnmpMonitor/SnmpInterface.ts +31 -0
- package/Types/Monitor/SnmpMonitor/SnmpMonitorResponse.ts +24 -0
- package/Types/Monitor/SnmpMonitor/SnmpTrap.ts +20 -0
- package/Types/Monitor/SnmpMonitor/SnmpVendorTemplate.ts +173 -0
- package/Types/Permission.ts +314 -0
- package/Types/Probe/ProbeMonitorResponse.ts +22 -0
- package/UI/Components/Charts/ChartLibrary/AreaChart/AreaChart.tsx +8 -5
- package/UI/Components/Charts/ChartLibrary/BarChart/BarChart.tsx +4 -1
- package/UI/Components/Charts/ChartLibrary/LineChart/LineChart.tsx +6 -3
- package/UI/Components/CodeBlock/CodeBlock.tsx +2 -1
- package/UI/Components/CodeEditor/CodeEditor.tsx +3 -0
- package/UI/Components/Divider/Divider.tsx +1 -1
- package/UI/Components/Dropdown/Dropdown.tsx +13 -4
- package/UI/Components/EntityDropdown/EntityDropdown.tsx +110 -2
- package/UI/Components/ErrorBoundary.tsx +2 -1
- package/UI/Components/EventItem/EventItem.tsx +2 -2
- package/UI/Components/GanttChart/Bar/Index.tsx +1 -1
- package/UI/Components/Graphs/UptimeBarTooltip.tsx +30 -23
- package/UI/Components/Header/Header.tsx +7 -0
- package/UI/Components/Header/HeaderIconDropdownButton.tsx +2 -0
- package/UI/Components/Icon/Icon.tsx +8 -6
- package/UI/Components/Label/Label.tsx +2 -2
- package/UI/Components/LogsViewer/components/LogsAnalyticsView.tsx +22 -10
- package/UI/Components/LogsViewer/components/LogsHistogram.tsx +9 -3
- package/UI/Components/Markdown.tsx/MarkdownEditor.tsx +8 -8
- package/UI/Components/Markdown.tsx/MarkdownViewer.tsx +44 -20
- package/UI/Components/Modal/ConfirmModal.tsx +1 -1
- package/UI/Components/Modal/Modal.tsx +213 -121
- package/UI/Components/Modal/ModalFooter.tsx +33 -22
- package/UI/Components/ModelTable/TableView.tsx +1 -1
- package/UI/Components/MonitorGraphs/UptimeBarDayModal.tsx +20 -12
- package/UI/Components/MonitorTemplateVariables/TemplateVariablesCatalog.ts +2 -2
- package/UI/Components/Pill/Pill.tsx +21 -13
- package/UI/Components/StatusBubble/StatusBubble.tsx +3 -3
- package/UI/Components/Tabs/Tabs.tsx +10 -1
- package/UI/Components/TelemetryViewer/TelemetryViewer.tsx +7 -1
- package/UI/Components/TelemetryViewer/components/TelemetryHistogram.tsx +9 -3
- package/UI/Components/TelemetryViewer/components/TelemetrySearchBar.tsx +62 -4
- package/UI/Components/Workflow/Component.tsx +53 -33
- package/UI/Components/Workflow/ComponentPortViewer.tsx +6 -6
- package/UI/Components/Workflow/ComponentReturnValueViewer.tsx +8 -8
- package/UI/Components/Workflow/ComponentsModal.tsx +16 -9
- package/UI/Components/Workflow/Workflow.tsx +13 -11
- package/UI/Utils/Navigation.ts +10 -1
- package/UI/Utils/Theme.ts +140 -0
- package/Utils/Dashboard/Components/DashboardLogChartComponent.ts +99 -0
- package/Utils/Dashboard/Components/Index.ts +7 -0
- package/Utils/Monitor/LatencyMatrixUtil.ts +162 -0
- package/Utils/Monitor/MonitorMetricType.ts +141 -3
- package/Utils/Monitor/NetworkTopologyUtil.ts +159 -0
- package/Utils/Telemetry/EntityRelationship.ts +11 -0
- package/build/dist/Models/DatabaseModels/AIRun.js +52 -0
- package/build/dist/Models/DatabaseModels/AIRun.js.map +1 -1
- package/build/dist/Models/DatabaseModels/AlertSeverity.js +6 -0
- package/build/dist/Models/DatabaseModels/AlertSeverity.js.map +1 -1
- package/build/dist/Models/DatabaseModels/IncidentSeverity.js +6 -0
- package/build/dist/Models/DatabaseModels/IncidentSeverity.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Index.js +16 -0
- package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
- package/build/dist/Models/DatabaseModels/IoTDeviceCredential.js +493 -0
- package/build/dist/Models/DatabaseModels/IoTDeviceCredential.js.map +1 -0
- package/build/dist/Models/DatabaseModels/LlmLog.js +58 -0
- package/build/dist/Models/DatabaseModels/LlmLog.js.map +1 -1
- package/build/dist/Models/DatabaseModels/LlmProvider.js +33 -0
- package/build/dist/Models/DatabaseModels/LlmProvider.js.map +1 -1
- package/build/dist/Models/DatabaseModels/NetworkDevice.js +1426 -0
- package/build/dist/Models/DatabaseModels/NetworkDevice.js.map +1 -0
- package/build/dist/Models/DatabaseModels/NetworkDeviceDiscoveryScan.js +738 -0
- package/build/dist/Models/DatabaseModels/NetworkDeviceDiscoveryScan.js.map +1 -0
- package/build/dist/Models/DatabaseModels/NetworkDeviceLabelRule.js +522 -0
- package/build/dist/Models/DatabaseModels/NetworkDeviceLabelRule.js.map +1 -0
- package/build/dist/Models/DatabaseModels/NetworkDeviceOwnerRule.js +603 -0
- package/build/dist/Models/DatabaseModels/NetworkDeviceOwnerRule.js.map +1 -0
- package/build/dist/Models/DatabaseModels/NetworkDeviceOwnerTeam.js +503 -0
- package/build/dist/Models/DatabaseModels/NetworkDeviceOwnerTeam.js.map +1 -0
- package/build/dist/Models/DatabaseModels/NetworkDeviceOwnerUser.js +502 -0
- package/build/dist/Models/DatabaseModels/NetworkDeviceOwnerUser.js.map +1 -0
- package/build/dist/Models/DatabaseModels/NetworkInterface.js +589 -0
- package/build/dist/Models/DatabaseModels/NetworkInterface.js.map +1 -0
- package/build/dist/Models/DatabaseModels/Project.js +147 -0
- package/build/dist/Models/DatabaseModels/Project.js.map +1 -1
- package/build/dist/Models/DatabaseModels/TelemetryEntityRelationship.js +57 -0
- package/build/dist/Models/DatabaseModels/TelemetryEntityRelationship.js.map +1 -1
- package/build/dist/Server/API/AIAgentTaskAPI.js +8 -23
- package/build/dist/Server/API/AIAgentTaskAPI.js.map +1 -1
- package/build/dist/Server/API/AIInvestigationAPI.js +95 -55
- package/build/dist/Server/API/AIInvestigationAPI.js.map +1 -1
- package/build/dist/Server/API/AlertAPI.js +5 -0
- package/build/dist/Server/API/AlertAPI.js.map +1 -1
- package/build/dist/Server/API/IncidentAPI.js +10 -0
- package/build/dist/Server/API/IncidentAPI.js.map +1 -1
- package/build/dist/Server/API/IncidentEpisodeAPI.js +5 -0
- package/build/dist/Server/API/IncidentEpisodeAPI.js.map +1 -1
- package/build/dist/Server/API/LlmProviderAPI.js +5 -7
- package/build/dist/Server/API/LlmProviderAPI.js.map +1 -1
- package/build/dist/Server/API/ScheduledMaintenanceAPI.js +5 -0
- package/build/dist/Server/API/ScheduledMaintenanceAPI.js.map +1 -1
- package/build/dist/Server/API/TelemetryAPI.js.map +1 -1
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783650000000-AddAdditionalParamsToLlmProvider.js +12 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783650000000-AddAdditionalParamsToLlmProvider.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783695782697-AddCacheTokenColumnsToLlmLog.js +14 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783695782697-AddCacheTokenColumnsToLlmLog.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783701585317-AddAlertInvestigationGating.js +18 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783701585317-AddAlertInvestigationGating.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783702431535-AddAiDailyAutonomousTokenLimitToProject.js +12 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783702431535-AddAiDailyAutonomousTokenLimitToProject.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783720000000-AddNetworkDeviceTables.js +51 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783720000000-AddNetworkDeviceTables.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783721121260-AddAttemptCountToAIRun.js +12 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783721121260-AddAttemptCountToAIRun.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783730000000-AddNetworkDeviceOwnersAndRules.js +101 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783730000000-AddNetworkDeviceOwnersAndRules.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783740000000-AddNetworkDeviceDiscoveryScan.js +18 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783740000000-AddNetworkDeviceDiscoveryScan.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783750000000-AddLldpNeighborsToNetworkDevice.js +12 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783750000000-AddLldpNeighborsToNetworkDevice.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783760576655-AddInvestigationTuningToProject.js +14 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783760576655-AddInvestigationTuningToProject.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783762505482-AddTelemetryEntityRelationshipMetrics.js +16 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783762505482-AddTelemetryEntityRelationshipMetrics.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783780000000-AddIoTDeviceCredentialTable.js +38 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783780000000-AddIoTDeviceCredentialTable.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783790000000-AddSnmpV3AuthColumnsToNetworkDevice.js +22 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783790000000-AddSnmpV3AuthColumnsToNetworkDevice.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +24 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
- package/build/dist/Server/Services/AIAgentTaskService.js +59 -0
- package/build/dist/Server/Services/AIAgentTaskService.js.map +1 -1
- package/build/dist/Server/Services/AIRunService.js +33 -0
- package/build/dist/Server/Services/AIRunService.js.map +1 -1
- package/build/dist/Server/Services/AIService.js +82 -9
- package/build/dist/Server/Services/AIService.js.map +1 -1
- package/build/dist/Server/Services/AnalyticsDatabaseService.js +19 -0
- package/build/dist/Server/Services/AnalyticsDatabaseService.js.map +1 -1
- package/build/dist/Server/Services/IncidentService.js +14 -25
- package/build/dist/Server/Services/IncidentService.js.map +1 -1
- package/build/dist/Server/Services/Index.js +14 -0
- package/build/dist/Server/Services/Index.js.map +1 -1
- package/build/dist/Server/Services/IoTDeviceCredentialService.js +321 -0
- package/build/dist/Server/Services/IoTDeviceCredentialService.js.map +1 -0
- package/build/dist/Server/Services/IoTDeviceService.js +49 -15
- package/build/dist/Server/Services/IoTDeviceService.js.map +1 -1
- package/build/dist/Server/Services/LlmLogService.js +29 -0
- package/build/dist/Server/Services/LlmLogService.js.map +1 -1
- package/build/dist/Server/Services/LlmProviderService.js +3 -0
- package/build/dist/Server/Services/LlmProviderService.js.map +1 -1
- package/build/dist/Server/Services/LogAggregationService.js +21 -7
- package/build/dist/Server/Services/LogAggregationService.js.map +1 -1
- package/build/dist/Server/Services/MetricService.js +449 -7
- package/build/dist/Server/Services/MetricService.js.map +1 -1
- package/build/dist/Server/Services/MonitorService.js +2 -1
- package/build/dist/Server/Services/MonitorService.js.map +1 -1
- package/build/dist/Server/Services/NetworkDeviceDiscoveryScanService.js +9 -0
- package/build/dist/Server/Services/NetworkDeviceDiscoveryScanService.js.map +1 -0
- package/build/dist/Server/Services/NetworkDeviceLabelRuleEngineService.js +166 -0
- package/build/dist/Server/Services/NetworkDeviceLabelRuleEngineService.js.map +1 -0
- package/build/dist/Server/Services/NetworkDeviceLabelRuleService.js +13 -0
- package/build/dist/Server/Services/NetworkDeviceLabelRuleService.js.map +1 -0
- package/build/dist/Server/Services/NetworkDeviceOwnerRuleEngineService.js +186 -0
- package/build/dist/Server/Services/NetworkDeviceOwnerRuleEngineService.js.map +1 -0
- package/build/dist/Server/Services/NetworkDeviceOwnerRuleService.js +13 -0
- package/build/dist/Server/Services/NetworkDeviceOwnerRuleService.js.map +1 -0
- package/build/dist/Server/Services/NetworkDeviceOwnerTeamService.js +9 -0
- package/build/dist/Server/Services/NetworkDeviceOwnerTeamService.js.map +1 -0
- package/build/dist/Server/Services/NetworkDeviceOwnerUserService.js +9 -0
- package/build/dist/Server/Services/NetworkDeviceOwnerUserService.js.map +1 -0
- package/build/dist/Server/Services/NetworkDeviceService.js +52 -0
- package/build/dist/Server/Services/NetworkDeviceService.js.map +1 -0
- package/build/dist/Server/Services/NetworkInterfaceService.js +9 -0
- package/build/dist/Server/Services/NetworkInterfaceService.js.map +1 -0
- package/build/dist/Server/Services/TelemetryEntityRelationshipService.js +22 -0
- package/build/dist/Server/Services/TelemetryEntityRelationshipService.js.map +1 -1
- package/build/dist/Server/Services/TelemetryEntityService.js +64 -2
- package/build/dist/Server/Services/TelemetryEntityService.js.map +1 -1
- package/build/dist/Server/Utils/AI/Sentinel/AlertInvestigationRunner.js +189 -9
- package/build/dist/Server/Utils/AI/Sentinel/AlertInvestigationRunner.js.map +1 -1
- package/build/dist/Server/Utils/AI/Sentinel/IncidentInvestigationRunner.js +84 -17
- package/build/dist/Server/Utils/AI/Sentinel/IncidentInvestigationRunner.js.map +1 -1
- package/build/dist/Server/Utils/AI/Sentinel/InvestigationQueue.js +428 -0
- package/build/dist/Server/Utils/AI/Sentinel/InvestigationQueue.js.map +1 -0
- package/build/dist/Server/Utils/AI/Sentinel/SentinelInvestigationEngine.js +63 -47
- package/build/dist/Server/Utils/AI/Sentinel/SentinelInvestigationEngine.js.map +1 -1
- package/build/dist/Server/Utils/AI/Toolbox/Index.js +2 -1
- package/build/dist/Server/Utils/AI/Toolbox/Index.js.map +1 -1
- package/build/dist/Server/Utils/AI/Toolbox/MetricTools.js +300 -0
- package/build/dist/Server/Utils/AI/Toolbox/MetricTools.js.map +1 -1
- package/build/dist/Server/Utils/LLM/LLMService.js +16 -0
- package/build/dist/Server/Utils/LLM/LLMService.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/Criteria/APIRequestCriteria.js +29 -0
- package/build/dist/Server/Utils/Monitor/Criteria/APIRequestCriteria.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/Criteria/SnmpMonitorCriteria.js +130 -2
- package/build/dist/Server/Utils/Monitor/Criteria/SnmpMonitorCriteria.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/IoTDeviceAbsenceSeries.js +81 -0
- package/build/dist/Server/Utils/Monitor/IoTDeviceAbsenceSeries.js.map +1 -0
- package/build/dist/Server/Utils/Monitor/MonitorAlert.js +18 -7
- package/build/dist/Server/Utils/Monitor/MonitorAlert.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaEvaluator.js +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaEvaluator.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorIncident.js +25 -10
- package/build/dist/Server/Utils/Monitor/MonitorIncident.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorMetricUtil.js +155 -5
- package/build/dist/Server/Utils/Monitor/MonitorMetricUtil.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorResource.js +76 -30
- package/build/dist/Server/Utils/Monitor/MonitorResource.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorTemplateUtil.js +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorTemplateUtil.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/NetworkDeviceHydrationUtil.js +147 -0
- package/build/dist/Server/Utils/Monitor/NetworkDeviceHydrationUtil.js.map +1 -0
- package/build/dist/Server/Utils/Monitor/NetworkInventoryUtil.js +167 -0
- package/build/dist/Server/Utils/Monitor/NetworkInventoryUtil.js.map +1 -0
- package/build/dist/Server/Utils/Monitor/SnmpInterfaceRateUtil.js +93 -0
- package/build/dist/Server/Utils/Monitor/SnmpInterfaceRateUtil.js.map +1 -0
- package/build/dist/Types/AI/AIRunStatus.js +9 -0
- package/build/dist/Types/AI/AIRunStatus.js.map +1 -1
- package/build/dist/Types/Dashboard/DashboardComponentType.js +1 -0
- package/build/dist/Types/Dashboard/DashboardComponentType.js.map +1 -1
- package/build/dist/Types/Dashboard/DashboardComponents/DashboardLogChartComponent.js +2 -0
- package/build/dist/Types/Dashboard/DashboardComponents/DashboardLogChartComponent.js.map +1 -0
- package/build/dist/Types/Dashboard/DashboardTemplates.js +9 -1
- package/build/dist/Types/Dashboard/DashboardTemplates.js.map +1 -1
- package/build/dist/Types/LlmLogStatus.js +1 -0
- package/build/dist/Types/LlmLogStatus.js.map +1 -1
- package/build/dist/Types/Monitor/CriteriaFilter.js +9 -0
- package/build/dist/Types/Monitor/CriteriaFilter.js.map +1 -1
- package/build/dist/Types/Monitor/HttpPhaseTimings.js +2 -0
- package/build/dist/Types/Monitor/HttpPhaseTimings.js.map +1 -0
- package/build/dist/Types/Monitor/IotAlertTemplates.js +7 -7
- package/build/dist/Types/Monitor/IotAlertTemplates.js.map +1 -1
- package/build/dist/Types/Monitor/LatencyMatrix.js +2 -0
- package/build/dist/Types/Monitor/LatencyMatrix.js.map +1 -0
- package/build/dist/Types/Monitor/MonitorCriteriaInstance.js +2 -2
- package/build/dist/Types/Monitor/MonitorCriteriaInstance.js.map +1 -1
- package/build/dist/Types/Monitor/MonitorMetricType.js +24 -0
- package/build/dist/Types/Monitor/MonitorMetricType.js.map +1 -1
- package/build/dist/Types/Monitor/MonitorStep.js +22 -9
- package/build/dist/Types/Monitor/MonitorStep.js.map +1 -1
- package/build/dist/Types/Monitor/MonitorStepNetworkDeviceMonitor.js +36 -0
- package/build/dist/Types/Monitor/MonitorStepNetworkDeviceMonitor.js.map +1 -0
- package/build/dist/Types/Monitor/MonitorStepSnmpMonitor.js +3 -0
- package/build/dist/Types/Monitor/MonitorStepSnmpMonitor.js.map +1 -1
- package/build/dist/Types/Monitor/MonitorType.js +14 -9
- package/build/dist/Types/Monitor/MonitorType.js.map +1 -1
- package/build/dist/Types/Monitor/PingMonitor/PingMonitorResponse.js +2 -0
- package/build/dist/Types/Monitor/PingMonitor/PingMonitorResponse.js.map +1 -0
- package/build/dist/Types/Monitor/SnmpMonitor/LldpNeighbor.js +2 -0
- package/build/dist/Types/Monitor/SnmpMonitor/LldpNeighbor.js.map +1 -0
- package/build/dist/Types/Monitor/SnmpMonitor/NetworkDeviceAlertPack.js +89 -0
- package/build/dist/Types/Monitor/SnmpMonitor/NetworkDeviceAlertPack.js.map +1 -0
- package/build/dist/Types/Monitor/SnmpMonitor/NetworkTopology.js +2 -0
- package/build/dist/Types/Monitor/SnmpMonitor/NetworkTopology.js.map +1 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpInterface.js +2 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpInterface.js.map +1 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpTrap.js +2 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpTrap.js.map +1 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpVendorTemplate.js +137 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpVendorTemplate.js.map +1 -0
- package/build/dist/Types/Permission.js +280 -0
- package/build/dist/Types/Permission.js.map +1 -1
- package/build/dist/UI/Components/Charts/ChartLibrary/AreaChart/AreaChart.js +7 -4
- package/build/dist/UI/Components/Charts/ChartLibrary/AreaChart/AreaChart.js.map +1 -1
- package/build/dist/UI/Components/Charts/ChartLibrary/BarChart/BarChart.js +4 -1
- package/build/dist/UI/Components/Charts/ChartLibrary/BarChart/BarChart.js.map +1 -1
- package/build/dist/UI/Components/Charts/ChartLibrary/LineChart/LineChart.js +6 -3
- package/build/dist/UI/Components/Charts/ChartLibrary/LineChart/LineChart.js.map +1 -1
- package/build/dist/UI/Components/CodeBlock/CodeBlock.js +1 -1
- package/build/dist/UI/Components/CodeBlock/CodeBlock.js.map +1 -1
- package/build/dist/UI/Components/CodeEditor/CodeEditor.js +3 -1
- package/build/dist/UI/Components/CodeEditor/CodeEditor.js.map +1 -1
- package/build/dist/UI/Components/Divider/Divider.js +1 -1
- package/build/dist/UI/Components/Divider/Divider.js.map +1 -1
- package/build/dist/UI/Components/Dropdown/Dropdown.js +10 -4
- package/build/dist/UI/Components/Dropdown/Dropdown.js.map +1 -1
- package/build/dist/UI/Components/EntityDropdown/EntityDropdown.js +76 -3
- package/build/dist/UI/Components/EntityDropdown/EntityDropdown.js.map +1 -1
- package/build/dist/UI/Components/ErrorBoundary.js +2 -1
- package/build/dist/UI/Components/ErrorBoundary.js.map +1 -1
- package/build/dist/UI/Components/EventItem/EventItem.js +2 -2
- package/build/dist/UI/Components/EventItem/EventItem.js.map +1 -1
- package/build/dist/UI/Components/GanttChart/Bar/Index.js +1 -1
- package/build/dist/UI/Components/GanttChart/Bar/Index.js.map +1 -1
- package/build/dist/UI/Components/Graphs/UptimeBarTooltip.js +29 -23
- package/build/dist/UI/Components/Graphs/UptimeBarTooltip.js.map +1 -1
- package/build/dist/UI/Components/Header/Header.js +1 -0
- package/build/dist/UI/Components/Header/Header.js.map +1 -1
- package/build/dist/UI/Components/Header/HeaderIconDropdownButton.js +1 -1
- package/build/dist/UI/Components/Header/HeaderIconDropdownButton.js.map +1 -1
- package/build/dist/UI/Components/Icon/Icon.js +8 -6
- package/build/dist/UI/Components/Icon/Icon.js.map +1 -1
- package/build/dist/UI/Components/Label/Label.js +2 -2
- package/build/dist/UI/Components/Label/Label.js.map +1 -1
- package/build/dist/UI/Components/LogsViewer/components/LogsAnalyticsView.js +20 -8
- package/build/dist/UI/Components/LogsViewer/components/LogsAnalyticsView.js.map +1 -1
- package/build/dist/UI/Components/LogsViewer/components/LogsHistogram.js +8 -2
- package/build/dist/UI/Components/LogsViewer/components/LogsHistogram.js.map +1 -1
- package/build/dist/UI/Components/Markdown.tsx/MarkdownEditor.js +8 -8
- package/build/dist/UI/Components/Markdown.tsx/MarkdownViewer.js +40 -20
- package/build/dist/UI/Components/Markdown.tsx/MarkdownViewer.js.map +1 -1
- package/build/dist/UI/Components/Modal/ConfirmModal.js +1 -1
- package/build/dist/UI/Components/Modal/ConfirmModal.js.map +1 -1
- package/build/dist/UI/Components/Modal/Modal.js +109 -51
- package/build/dist/UI/Components/Modal/Modal.js.map +1 -1
- package/build/dist/UI/Components/Modal/ModalFooter.js +13 -10
- package/build/dist/UI/Components/Modal/ModalFooter.js.map +1 -1
- package/build/dist/UI/Components/ModelTable/TableView.js +1 -1
- package/build/dist/UI/Components/ModelTable/TableView.js.map +1 -1
- package/build/dist/UI/Components/MonitorGraphs/UptimeBarDayModal.js +17 -12
- package/build/dist/UI/Components/MonitorGraphs/UptimeBarDayModal.js.map +1 -1
- package/build/dist/UI/Components/MonitorTemplateVariables/TemplateVariablesCatalog.js +2 -2
- package/build/dist/UI/Components/MonitorTemplateVariables/TemplateVariablesCatalog.js.map +1 -1
- package/build/dist/UI/Components/Pill/Pill.js +12 -13
- package/build/dist/UI/Components/Pill/Pill.js.map +1 -1
- package/build/dist/UI/Components/StatusBubble/StatusBubble.js +3 -3
- package/build/dist/UI/Components/StatusBubble/StatusBubble.js.map +1 -1
- package/build/dist/UI/Components/Tabs/Tabs.js +3 -1
- package/build/dist/UI/Components/Tabs/Tabs.js.map +1 -1
- package/build/dist/UI/Components/TelemetryViewer/TelemetryViewer.js +1 -1
- package/build/dist/UI/Components/TelemetryViewer/TelemetryViewer.js.map +1 -1
- package/build/dist/UI/Components/TelemetryViewer/components/TelemetryHistogram.js +8 -2
- package/build/dist/UI/Components/TelemetryViewer/components/TelemetryHistogram.js.map +1 -1
- package/build/dist/UI/Components/TelemetryViewer/components/TelemetrySearchBar.js +36 -6
- package/build/dist/UI/Components/TelemetryViewer/components/TelemetrySearchBar.js.map +1 -1
- package/build/dist/UI/Components/Workflow/Component.js +43 -33
- package/build/dist/UI/Components/Workflow/Component.js.map +1 -1
- package/build/dist/UI/Components/Workflow/ComponentPortViewer.js +6 -6
- package/build/dist/UI/Components/Workflow/ComponentPortViewer.js.map +1 -1
- package/build/dist/UI/Components/Workflow/ComponentReturnValueViewer.js +8 -8
- package/build/dist/UI/Components/Workflow/ComponentReturnValueViewer.js.map +1 -1
- package/build/dist/UI/Components/Workflow/ComponentsModal.js +15 -9
- package/build/dist/UI/Components/Workflow/ComponentsModal.js.map +1 -1
- package/build/dist/UI/Components/Workflow/Workflow.js +13 -11
- package/build/dist/UI/Components/Workflow/Workflow.js.map +1 -1
- package/build/dist/UI/Utils/Navigation.js +11 -1
- package/build/dist/UI/Utils/Navigation.js.map +1 -1
- package/build/dist/UI/Utils/Theme.js +106 -0
- package/build/dist/UI/Utils/Theme.js.map +1 -0
- package/build/dist/Utils/Dashboard/Components/DashboardLogChartComponent.js +89 -0
- package/build/dist/Utils/Dashboard/Components/DashboardLogChartComponent.js.map +1 -0
- package/build/dist/Utils/Dashboard/Components/Index.js +4 -0
- package/build/dist/Utils/Dashboard/Components/Index.js.map +1 -1
- package/build/dist/Utils/Monitor/LatencyMatrixUtil.js +89 -0
- package/build/dist/Utils/Monitor/LatencyMatrixUtil.js.map +1 -0
- package/build/dist/Utils/Monitor/MonitorMetricType.js +138 -4
- package/build/dist/Utils/Monitor/MonitorMetricType.js.map +1 -1
- package/build/dist/Utils/Monitor/NetworkTopologyUtil.js +112 -0
- package/build/dist/Utils/Monitor/NetworkTopologyUtil.js.map +1 -0
- package/build/dist/Utils/Telemetry/EntityRelationship.js.map +1 -1
- package/package.json +1 -1
|
@@ -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;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AAO;QACT,CAAC;QAED,+DAA+D;QAC/D,MAAM,YAAY,CAAC,uBAAuB,CAAC;YACzC,OAAO,EAAE,GAAG,CAAC,EAAE;YACf,UAAU,EAAE,WAAW,CAAC,OAAO;YAC/B,GAAG,EAAE;gBACH,MAAM,EAAE,WAAW,CAAC,KAAK;gBACzB,WAAW,EAAE,aAAa,CAAC,cAAc,EAAE;gBAC3C,YAAY,EAAE,qDAAqD;aACpE;SACF,CAAC,CAAC;IACL,CAAC;CACF;AAnZqB;IADnB,WAAW,EAAE;;;;+CAqEb;AASmB;IADnB,WAAW,EAAE;;;;kDAmBb;AAYmB;IADnB,WAAW,EAAE;;;;yDAkFb;AASmB;IADnB,WAAW,EAAE;;;;qDAoCb;AAQmB;IADnB,WAAW,EAAE;;;;0DAgCb"}
|
|
@@ -9,15 +9,14 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
};
|
|
10
10
|
import ObjectID from "../../../../Types/ObjectID";
|
|
11
11
|
import OneUptimeDate from "../../../../Types/Date";
|
|
12
|
-
import AIRunType from "../../../../Types/AI/AIRunType";
|
|
13
12
|
import AIRunStatus from "../../../../Types/AI/AIRunStatus";
|
|
14
13
|
import AIRunEventType from "../../../../Types/AI/AIRunEventType";
|
|
15
|
-
import AIRun from "../../../../Models/DatabaseModels/AIRun";
|
|
16
14
|
import AIRunEvent from "../../../../Models/DatabaseModels/AIRunEvent";
|
|
17
15
|
import AIRunService from "../../../Services/AIRunService";
|
|
18
16
|
import AIRunEventService from "../../../Services/AIRunEventService";
|
|
19
17
|
import ProjectService from "../../../Services/ProjectService";
|
|
20
18
|
import LlmProviderService from "../../../Services/LlmProviderService";
|
|
19
|
+
import SentinelInvestigationQueue from "./InvestigationQueue";
|
|
21
20
|
import ObservabilityAssistant from "../Chat/ObservabilityAssistant";
|
|
22
21
|
import logger from "../../Logger";
|
|
23
22
|
import CaptureSpan from "../../Telemetry/CaptureSpan";
|
|
@@ -47,6 +46,12 @@ const MAX_OUTPUT_TOKENS = 2000;
|
|
|
47
46
|
* a non-answer should never loudly page the on-call.
|
|
48
47
|
*/
|
|
49
48
|
const INCONCLUSIVE_RE = /inconclusive[^.\n]*insufficient signal/i;
|
|
49
|
+
/*
|
|
50
|
+
* Failures a retry cannot fix within the run's usefulness window: missing/
|
|
51
|
+
* broken provider configuration and budget exhaustion (both messages minted
|
|
52
|
+
* by our own gating in AIService/LLMService, so they are stable to match).
|
|
53
|
+
*/
|
|
54
|
+
const PERMANENT_FAILURE_RE = /no llm provider configured|llm provider type is not configured|token budget exhausted/i;
|
|
50
55
|
// Maps a live agent step to the AIRunEvent type persisted for the glass-box trail.
|
|
51
56
|
const STEP_EVENT_TYPE = {
|
|
52
57
|
llm_started: AIRunEventType.LlmCallStarted,
|
|
@@ -59,7 +64,7 @@ const INVESTIGATION_PERSONA = `You are "Sentinel", OneUptime's autonomous AI Sit
|
|
|
59
64
|
|
|
60
65
|
Investigate like a senior on-call engineer:
|
|
61
66
|
- Start from the affected monitors/services named in the signal.
|
|
62
|
-
- Use your read tools to inspect the telemetry AROUND the signal's creation time: recent exceptions and their trends, error/latency metrics versus their normal range, failing traces, relevant logs, and recent changes / deploys.
|
|
67
|
+
- Use your read tools to inspect the telemetry AROUND the signal's creation time: recent exceptions and their trends, error/latency metrics versus their normal range (use baseline_anomaly to judge a metric against its learned hour-of-week baseline quantitatively instead of eyeballing), failing traces, relevant logs, and recent changes / deploys.
|
|
63
68
|
- Form the single most likely root-cause hypothesis. If the evidence is inconclusive, say so plainly and list what you checked — do NOT guess a cause the data does not support.
|
|
64
69
|
- If the context lists past resolved incidents, check whether this is a RECURRENCE. If the current signal matches one, say so explicitly, reference that incident number, and note how it was resolved before — but still verify against the current telemetry.
|
|
65
70
|
|
|
@@ -107,37 +112,27 @@ export default class SentinelInvestigationEngine {
|
|
|
107
112
|
return true;
|
|
108
113
|
}
|
|
109
114
|
/*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
115
|
+
* Execute an already-CLAIMED (Running) investigation run end-to-end.
|
|
116
|
+
* Called by SentinelInvestigationQueue after a successful CAS claim —
|
|
117
|
+
* cap/budget gating and run creation live in the queue now. Never throws;
|
|
118
|
+
* failures are handed to the queue's retry policy (failOrRequeue).
|
|
112
119
|
*/
|
|
113
|
-
static async
|
|
114
|
-
const { projectId } =
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
run.startedAt = OneUptimeDate.getCurrentDate();
|
|
121
|
-
run.lastHeartbeatAt = OneUptimeDate.getCurrentDate();
|
|
122
|
-
if (request.subjectIncidentId) {
|
|
123
|
-
run.triggeredByIncidentId = request.subjectIncidentId;
|
|
124
|
-
}
|
|
125
|
-
if (request.subjectAlertId) {
|
|
126
|
-
run.triggeredByAlertId = request.subjectAlertId;
|
|
127
|
-
}
|
|
128
|
-
let createdRun;
|
|
120
|
+
static async executeRun(data) {
|
|
121
|
+
const { aiRunId, projectId, request } = data;
|
|
122
|
+
/*
|
|
123
|
+
* Retried runs already have events from earlier attempts; continue the
|
|
124
|
+
* sequence so the glass-box trail stays ordered and shows every attempt.
|
|
125
|
+
*/
|
|
126
|
+
let sequence = 0;
|
|
129
127
|
try {
|
|
130
|
-
|
|
131
|
-
|
|
128
|
+
sequence = (await AIRunEventService.countBy({
|
|
129
|
+
query: { aiRunId },
|
|
132
130
|
props: { isRoot: true },
|
|
133
|
-
});
|
|
131
|
+
})).toNumber();
|
|
134
132
|
}
|
|
135
133
|
catch (error) {
|
|
136
|
-
logger.error(`Sentinel: failed to
|
|
137
|
-
return;
|
|
134
|
+
logger.error(`Sentinel: failed to read event count for run ${aiRunId.toString()}; starting sequence at 0: ${error}`);
|
|
138
135
|
}
|
|
139
|
-
const aiRunId = createdRun.id;
|
|
140
|
-
let sequence = 0;
|
|
141
136
|
await this.emitEvent({
|
|
142
137
|
projectId,
|
|
143
138
|
aiRunId,
|
|
@@ -168,10 +163,12 @@ export default class SentinelInvestigationEngine {
|
|
|
168
163
|
resultSummary,
|
|
169
164
|
citationId: step.citationId,
|
|
170
165
|
});
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
166
|
+
/*
|
|
167
|
+
* Keep the run visibly alive for the stale-run sweeper + live UI on
|
|
168
|
+
* EVERY step — a slow self-hosted LLM call can approach the sweeper's
|
|
169
|
+
* timeout, so the heartbeat must be as frequent as we can make it.
|
|
170
|
+
*/
|
|
171
|
+
await this.touchHeartbeat(aiRunId);
|
|
175
172
|
};
|
|
176
173
|
try {
|
|
177
174
|
const result = await ObservabilityAssistant.answerQuestion({
|
|
@@ -187,9 +184,18 @@ export default class SentinelInvestigationEngine {
|
|
|
187
184
|
maxOutputTokens: MAX_OUTPUT_TOKENS,
|
|
188
185
|
onStep,
|
|
189
186
|
});
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
187
|
+
/*
|
|
188
|
+
* Atomic Running -> Completed. If we did NOT win this transition,
|
|
189
|
+
* another actor moved the run while we executed — most likely the
|
|
190
|
+
* stale sweeper falsely requeued it (slow LLM call outlasting the
|
|
191
|
+
* heartbeat window) and a second attempt is or will be running. In
|
|
192
|
+
* that case DO NOT post the analysis: the winning attempt will, and
|
|
193
|
+
* posting here would duplicate the RCA in the feed and workspace.
|
|
194
|
+
*/
|
|
195
|
+
const completedCount = await AIRunService.attemptStatusTransition({
|
|
196
|
+
aiRunId,
|
|
197
|
+
fromStatus: AIRunStatus.Running,
|
|
198
|
+
set: {
|
|
193
199
|
status: AIRunStatus.Completed,
|
|
194
200
|
completedAt: OneUptimeDate.getCurrentDate(),
|
|
195
201
|
lastHeartbeatAt: OneUptimeDate.getCurrentDate(),
|
|
@@ -197,8 +203,11 @@ export default class SentinelInvestigationEngine {
|
|
|
197
203
|
toolCallCount: result.toolCallCount,
|
|
198
204
|
totalTokens: result.totalTokens,
|
|
199
205
|
},
|
|
200
|
-
props: { isRoot: true },
|
|
201
206
|
});
|
|
207
|
+
if (completedCount === 0) {
|
|
208
|
+
logger.warn(`Sentinel: run ${aiRunId.toString()} finished but was no longer Running (likely requeued as stale mid-flight); skipping postAnalysis to avoid a duplicate RCA.`);
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
202
211
|
await this.emitEvent({
|
|
203
212
|
projectId,
|
|
204
213
|
aiRunId,
|
|
@@ -220,22 +229,29 @@ export default class SentinelInvestigationEngine {
|
|
|
220
229
|
}
|
|
221
230
|
catch (error) {
|
|
222
231
|
const message = error instanceof Error ? error.message : String(error);
|
|
223
|
-
await AIRunService.updateOneBy({
|
|
224
|
-
query: { _id: aiRunId.toString(), status: AIRunStatus.Running },
|
|
225
|
-
data: {
|
|
226
|
-
status: AIRunStatus.Error,
|
|
227
|
-
completedAt: OneUptimeDate.getCurrentDate(),
|
|
228
|
-
errorMessage: message.substring(0, 480),
|
|
229
|
-
},
|
|
230
|
-
props: { isRoot: true },
|
|
231
|
-
});
|
|
232
232
|
await this.emitEvent({
|
|
233
233
|
projectId,
|
|
234
234
|
aiRunId,
|
|
235
235
|
sequence: sequence++,
|
|
236
236
|
eventType: AIRunEventType.RunFailed,
|
|
237
237
|
});
|
|
238
|
-
|
|
238
|
+
/*
|
|
239
|
+
* Hand the failure to the queue's retry policy: transient errors
|
|
240
|
+
* requeue while attempts remain; permanent ones finalize as Error
|
|
241
|
+
* since retrying cannot help. Classification is by message, NOT by
|
|
242
|
+
* exception type: LLMService wraps transient provider failures (429s,
|
|
243
|
+
* 5xx, timeouts) in BadDataException too, so type-based classification
|
|
244
|
+
* would wrongly make the exact failures retries exist for permanent.
|
|
245
|
+
* Only configuration/budget gating — which a retry cannot change
|
|
246
|
+
* within the run's usefulness window — counts as permanent.
|
|
247
|
+
*/
|
|
248
|
+
await SentinelInvestigationQueue.failOrRequeue({
|
|
249
|
+
aiRunId,
|
|
250
|
+
attemptCount: data.attemptCount,
|
|
251
|
+
errorMessage: message,
|
|
252
|
+
isPermanent: PERMANENT_FAILURE_RE.test(message),
|
|
253
|
+
});
|
|
254
|
+
logger.error(`Sentinel: investigation attempt ${data.attemptCount} failed (run ${aiRunId.toString()}): ${message}`);
|
|
239
255
|
}
|
|
240
256
|
}
|
|
241
257
|
// Wrap the agent's analysis with Sentinel branding + an evidence list.
|
|
@@ -307,5 +323,5 @@ __decorate([
|
|
|
307
323
|
__metadata("design:type", Function),
|
|
308
324
|
__metadata("design:paramtypes", [Object]),
|
|
309
325
|
__metadata("design:returntype", Promise)
|
|
310
|
-
], SentinelInvestigationEngine, "
|
|
326
|
+
], SentinelInvestigationEngine, "executeRun", null);
|
|
311
327
|
//# sourceMappingURL=SentinelInvestigationEngine.js.map
|