@oneuptime/common 14.0.9 → 14.0.10
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/AutoRemediationSuggestion.ts +60 -0
- package/Models/DatabaseModels/CephCluster.ts +213 -0
- package/Models/DatabaseModels/DatabaseServer.ts +213 -0
- package/Models/DatabaseModels/DockerHost.ts +213 -0
- package/Models/DatabaseModels/DockerSwarmCluster.ts +213 -0
- package/Models/DatabaseModels/GlobalConfig.ts +1 -1
- package/Models/DatabaseModels/Host.ts +213 -0
- package/Models/DatabaseModels/Index.ts +2 -0
- package/Models/DatabaseModels/PodmanHost.ts +213 -0
- package/Models/DatabaseModels/ProxmoxCluster.ts +213 -0
- package/Models/DatabaseModels/ResourceAiAgent.ts +419 -0
- package/Models/DatabaseModels/RunnerJob.ts +144 -0
- package/Models/DatabaseModels/VMwareVCenter.ts +213 -0
- package/Server/API/AutoRemediationAPI.ts +392 -1
- package/Server/API/ResourceAiAccessAPI.ts +1669 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1796300000000-AddResourceAiAgents.ts +423 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +2 -0
- package/Server/Infrastructure/Semaphore.ts +22 -0
- package/Server/Middleware/TelemetryIngest.ts +15 -5
- package/Server/Services/AnalyticsDatabaseService.ts +45 -1
- package/Server/Services/AutoRemediationRuleEngineService.ts +940 -112
- package/Server/Services/CephClusterService.ts +109 -1
- package/Server/Services/DatabaseServerService.ts +116 -1
- package/Server/Services/DockerHostService.ts +109 -1
- package/Server/Services/DockerSwarmClusterService.ts +113 -1
- package/Server/Services/HostService.ts +126 -4
- package/Server/Services/MetricRecordingRuleService.ts +47 -0
- package/Server/Services/PodmanHostService.ts +109 -1
- package/Server/Services/ProxmoxClusterService.ts +110 -1
- package/Server/Services/ResourceAiAccessService.ts +1439 -0
- package/Server/Services/ResourceAiAgentJobService.ts +202 -0
- package/Server/Services/ResourceAiAgentService.ts +2432 -0
- package/Server/Services/RunnerJobService.ts +611 -4
- package/Server/Services/TelemetryUsageBillingService.ts +28 -0
- package/Server/Services/TraceRecordingRuleService.ts +33 -0
- package/Server/Services/VMwareVCenterService.ts +110 -1
- package/Server/Utils/AI/Remediation/RemediationCommandTools.ts +1434 -32
- package/Server/Utils/AI/Remediation/RemediationExecutionRunner.ts +935 -21
- package/Server/Utils/AI/Remediation/RemediationPlanRunner.ts +25 -1
- package/Server/Utils/AI/ResourceAccess/InfrastructureInvestigationToolkit.ts +577 -0
- package/Server/Utils/AI/ResourceAccess/ResourceAccessContext.ts +271 -0
- package/Server/Utils/AI/ResourceAccess/ResourceAccessToolNames.ts +45 -0
- package/Server/Utils/AI/ResourceAccess/ResourceAiAccessSettings.ts +964 -0
- package/Server/Utils/AI/ResourceAccess/ResourceAiDeleteCleanup.ts +333 -0
- package/Server/Utils/AI/ResourceAccess/ResourceCommandJobRunner.ts +873 -0
- package/Server/Utils/AI/SRE/AIInvestigationEngine.ts +72 -2
- package/Server/Utils/AI/SRE/AlertInvestigationRunner.ts +72 -5
- package/Server/Utils/AI/SRE/IncidentInvestigationRunner.ts +72 -5
- package/Server/Utils/AutoRemediation/CommandPlanExecutor.ts +396 -13
- package/Server/Utils/AutoRemediation/RemediationVerifier.ts +35 -2
- package/Server/Utils/Database/ProjectScopedReferenceValidator.ts +9 -1
- package/Server/Utils/SessionReplay/SessionReplayBudgetMetrics.ts +920 -0
- package/Server/Utils/SessionReplay/SessionReplayUsage.ts +84 -6
- package/Server/Utils/Workspace/MicrosoftTeams/Actions/Alert.ts +35 -15
- package/Server/Utils/Workspace/MicrosoftTeams/Actions/AlertEpisode.ts +33 -15
- package/Server/Utils/Workspace/MicrosoftTeams/Actions/Auth.ts +21 -1
- package/Server/Utils/Workspace/MicrosoftTeams/Actions/Incident.ts +298 -224
- package/Server/Utils/Workspace/MicrosoftTeams/Actions/IncidentEpisode.ts +35 -15
- package/Server/Utils/Workspace/MicrosoftTeams/Actions/ScheduledMaintenance.ts +389 -175
- package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.ts +366 -143
- package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsActivityDeduplicator.ts +163 -0
- package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsCardChoices.ts +396 -0
- package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsCreateCommands.ts +418 -0
- package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsMessageSize.ts +152 -0
- package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsReplies.ts +251 -0
- package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsTimezone.ts +214 -0
- package/Tests/App/Dashboard/ClusterAccessNotice.test.tsx +93 -0
- package/Tests/App/Dashboard/DatabaseDocumentationMarkdown.test.ts +18 -6
- package/Tests/App/Dashboard/InvestigationInfrastructureTools.test.tsx +506 -0
- package/Tests/App/Dashboard/RemediationSuggestionCardDescription.test.tsx +209 -0
- package/Tests/App/Dashboard/RemediationSuggestionCardResource.test.tsx +317 -0
- package/Tests/App/Dashboard/ResourceAiAccessSettingsUtil.test.ts +921 -0
- package/Tests/App/Dashboard/ResourceAiAgentInstall.test.ts +860 -0
- package/Tests/App/Dashboard/ResourceAiAgentPage.test.tsx +1721 -0
- package/Tests/App/Dashboard/ResourceAiAgentStatus.test.ts +1002 -0
- package/Tests/App/Dashboard/ResourceAiInsightsPage.test.tsx +931 -0
- package/Tests/App/Dashboard/ResourceAiNavigation.test.tsx +575 -0
- package/Tests/App/Dashboard/RunbookStepTypeMaps.test.ts +38 -7
- package/Tests/Models/DatabaseModels/DatabaseServerModels.test.ts +33 -1
- package/Tests/Models/DatabaseModels/ResourceAiAccessColumns.test.ts +738 -0
- package/Tests/Models/DatabaseModels/ResourceAiAgentModel.test.ts +842 -0
- package/Tests/Server/API/AutoRemediationApproveResourceRound.test.ts +835 -0
- package/Tests/Server/API/ResourceAiAccessAPI.test.ts +2730 -0
- package/Tests/Server/Infrastructure/Postgres/AddDatabaseServerTablesMigration.test.ts +60 -0
- package/Tests/Server/Infrastructure/Postgres/AddResourceAiAgentsMigration.test.ts +659 -0
- package/Tests/Server/Infrastructure/SemaphoreMutex.test.ts +31 -0
- package/Tests/Server/Middleware/TelemetryIngestBrowserKey.test.ts +63 -5
- package/Tests/Server/Middleware/TelemetryIngestKubernetesAgentRunnerPinnedKey.test.ts +103 -5
- package/Tests/Server/Middleware/TelemetryIngestKubernetesAgentRunnerRateLimit.test.ts +19 -1
- package/Tests/Server/Services/AutoRemediationResourceRuleEngine.test.ts +1279 -0
- package/Tests/Server/Services/DatabaseServerService.test.ts +55 -0
- package/Tests/Server/Services/GroupTelemetryUsageExcludeNames.test.ts +299 -0
- package/Tests/Server/Services/HostServiceFindOrCreateMemo.test.ts +44 -0
- package/Tests/Server/Services/MonitorProbeServiceIntervalScheduling.test.ts +45 -6
- package/Tests/Server/Services/RecordingRuleReservedMetricName.test.ts +171 -0
- package/Tests/Server/Services/ResourceAiAccessChangeAuthorization.test.ts +256 -0
- package/Tests/Server/Services/ResourceAiAccessService.test.ts +1373 -0
- package/Tests/Server/Services/ResourceAiAgentJobService.test.ts +375 -0
- package/Tests/Server/Services/ResourceAiAgentServiceHelpers.test.ts +1114 -0
- package/Tests/Server/Services/ResourceAiAgentServiceLifecycle.test.ts +1050 -0
- package/Tests/Server/Services/ResourceAiAgentServiceRegister.test.ts +2251 -0
- package/Tests/Server/Services/ResourceAiSettingsCreate.test.ts +373 -0
- package/Tests/Server/Services/ResourceAiSettingsPermission.test.ts +1042 -0
- package/Tests/Server/Services/ResourceServiceDeleteCleansUpAi.test.ts +319 -0
- package/Tests/Server/Services/RunnerJobEnqueueKubectl.test.ts +105 -0
- package/Tests/Server/Services/RunnerJobEnqueueResourceCommand.test.ts +986 -0
- package/Tests/Server/Services/RunnerJobResourceCommandLane.test.ts +211 -0
- package/Tests/Server/Services/RunnerJobResourceCommandTimeoutAndRedaction.test.ts +352 -0
- package/Tests/Server/Services/TelemetryUsageBillingSloExclusion.test.ts +218 -0
- package/Tests/Server/TestingUtils/Services/FakeRunnerJobCount.ts +145 -0
- package/Tests/Server/Utils/AI/InvestigationInfrastructureAccessWiring.test.ts +453 -0
- package/Tests/Server/Utils/AI/InvestigationInfrastructureReport.test.ts +721 -0
- package/Tests/Server/Utils/AI/RemediationCommandTools.test.ts +94 -1
- package/Tests/Server/Utils/AI/RemediationCommandToolsResource.test.ts +1530 -0
- package/Tests/Server/Utils/AI/RemediationExecutionRunnerResourceMode.test.ts +1249 -0
- package/Tests/Server/Utils/AI/RemediationPlanRunner.test.ts +117 -0
- package/Tests/Server/Utils/AI/RemediationResourceCopyParity.test.ts +463 -0
- package/Tests/Server/Utils/AI/ResourceAccess/InfrastructureInvestigationToolkit.test.ts +722 -0
- package/Tests/Server/Utils/AI/ResourceAccess/ResourceAccessContext.test.ts +266 -0
- package/Tests/Server/Utils/AI/ResourceAccess/ResourceAiAccessSettings.test.ts +1220 -0
- package/Tests/Server/Utils/AI/ResourceAccess/ResourceAiDeleteCleanup.test.ts +569 -0
- package/Tests/Server/Utils/AI/ResourceAccess/ResourceCommandJobRunner.test.ts +830 -0
- package/Tests/Server/Utils/AutoRemediation/CommandPlanExecutorResource.test.ts +717 -0
- package/Tests/Server/Utils/AutoRemediation/RemediationVerifierResourceFollowUp.test.ts +338 -0
- package/Tests/Server/Utils/Monitor/Criteria/SessionReplayBudgetTemplateCriteria.test.ts +422 -0
- package/Tests/Server/Utils/SessionReplay/SessionReplayBudgetMetrics.test.ts +1647 -0
- package/Tests/Server/Utils/SessionReplay/SessionReplayUsage.test.ts +143 -1
- package/Tests/Server/Utils/Telemetry/TelemetryIngestionKeyGuard.test.ts +33 -3
- package/Tests/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsAccountNotLinked.test.ts +1093 -0
- package/Tests/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsActivityDeduplicator.test.ts +1049 -0
- package/Tests/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsCardChoices.test.ts +1676 -0
- package/Tests/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsCreateCards.test.ts +2884 -0
- package/Tests/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsCreateCommands.test.ts +2490 -0
- package/Tests/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsCreateSubmit.test.ts +2293 -0
- package/Tests/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsCreateSubmitServerTimezone.test.ts +386 -0
- package/Tests/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsMessageSize.test.ts +1477 -0
- package/Tests/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsReplies.test.ts +1967 -0
- package/Tests/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsStripHtmlTags.test.ts +92 -0
- package/Tests/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsSubmittedFormRemoval.test.ts +1819 -0
- package/Tests/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsTimezone.test.ts +1033 -0
- package/Tests/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsTimezoneServerZone.test.ts +610 -0
- package/Tests/Server/Utils/Workspace/MicrosoftTeamsBotMessageHandling.test.ts +2610 -0
- package/Tests/Server/Utils/Workspace/MicrosoftTeamsCreateCommandsEndToEnd.test.ts +4672 -0
- package/Tests/Server/Utils/Workspace/WorkspaceCreateProjectReferences.test.ts +190 -65
- package/Tests/Types/AutoRemediation/AiRemediationCommandPlan.test.ts +10 -4
- package/Tests/Types/AutoRemediation/AiRemediationCommandPlanResourceCommand.test.ts +305 -0
- package/Tests/Types/Monitor/Recommendation/MonitorRecommendationCatalog.test.ts +277 -13
- package/Tests/Types/Monitor/Recommendation/MonitorRecommendationUtil.test.ts +113 -0
- package/Tests/Types/Monitor/RumAlertTemplates.test.ts +773 -2
- package/Tests/Types/ResourceAiAgent/AiResourceType.test.ts +419 -0
- package/Tests/Types/ResourceAiAgent/ResourceAiAccess.test.ts +517 -0
- package/Tests/Types/Runbook/RunbookStepType.test.ts +147 -8
- package/Tests/UI/Rum/RecordingHealthDashboard.test.tsx +769 -1
- package/Tests/Utils/AiRemediation/Resource/CephCommandPolicy.test.ts +1653 -0
- package/Tests/Utils/AiRemediation/Resource/CephOutputRedaction.test.ts +204 -0
- package/Tests/Utils/AiRemediation/Resource/DatabaseCommandPolicy.test.ts +1077 -0
- package/Tests/Utils/AiRemediation/Resource/DatabaseDiagnosticCatalog.test.ts +558 -0
- package/Tests/Utils/AiRemediation/Resource/DatabaseQueryRedactor.test.ts +834 -0
- package/Tests/Utils/AiRemediation/Resource/DockerCliGrammar.test.ts +747 -0
- package/Tests/Utils/AiRemediation/Resource/DockerEngineCommandPolicy.test.ts +1259 -0
- package/Tests/Utils/AiRemediation/Resource/DockerOutputRedaction.test.ts +386 -0
- package/Tests/Utils/AiRemediation/Resource/DockerSwarmCommandPolicy.test.ts +782 -0
- package/Tests/Utils/AiRemediation/Resource/GovcCommandPolicy.test.ts +2259 -0
- package/Tests/Utils/AiRemediation/Resource/HostCommandPolicy.test.ts +2019 -0
- package/Tests/Utils/AiRemediation/Resource/ProxmoxCommandPolicy.test.ts +2497 -0
- package/Tests/Utils/AiRemediation/Resource/ResourceCommandPolicy.test.ts +1305 -0
- package/Tests/Utils/AiRemediation/Resource/ResourceCommandPolicyCore.test.ts +585 -0
- package/Tests/Utils/AiRemediation/Resource/ResourceOutputRedactor.test.ts +334 -0
- package/Tests/Utils/AiRemediation/Resource/ResourceOutputRedactorCopyParity.test.ts +98 -0
- package/Tests/Utils/AiRemediation/Resource/ResourcePolicyImportClosure.test.ts +391 -0
- package/Tests/Utils/AiRemediation/ResourceAiAgentPolicyCopyParity.test.ts +497 -0
- package/Tests/Utils/SessionReplay/SessionReplayBudgetMetricType.test.ts +383 -0
- package/Types/AI/ResourceAiAccessApi.ts +140 -0
- package/Types/AI/ResourceAiAccessPermissions.ts +126 -0
- package/Types/AutoRemediation/AiRemediationCommandPlan.ts +183 -2
- package/Types/Monitor/Recommendation/MonitorRecommendationCatalog.ts +55 -22
- package/Types/Monitor/Recommendation/MonitorRecommendationTypes.ts +35 -3
- package/Types/Monitor/RumAlertTemplates.ts +351 -4
- package/Types/ResourceAiAgent/AiResourceType.ts +310 -0
- package/Types/ResourceAiAgent/ResourceAiAccess.ts +574 -0
- package/Types/Rum/SessionReplayBudgetMetricType.ts +47 -0
- package/Types/Runbook/RunbookStepType.ts +29 -0
- package/Types/Telemetry/TelemetryIngestSurface.ts +14 -2
- package/Utils/AI/InvestigationReport.ts +121 -15
- package/Utils/AiRemediation/Resource/CephCommandPolicy.ts +1936 -0
- package/Utils/AiRemediation/Resource/DatabaseCommandPolicy.ts +166 -0
- package/Utils/AiRemediation/Resource/DatabaseDiagnosticCatalog.ts +1532 -0
- package/Utils/AiRemediation/Resource/DatabaseQueryRedactor.ts +1394 -0
- package/Utils/AiRemediation/Resource/DockerCliGrammar.ts +1839 -0
- package/Utils/AiRemediation/Resource/DockerEngineCommandPolicy.ts +490 -0
- package/Utils/AiRemediation/Resource/DockerSwarmCommandPolicy.ts +687 -0
- package/Utils/AiRemediation/Resource/GovcCommandPolicy.ts +2096 -0
- package/Utils/AiRemediation/Resource/HostCommandPolicy.ts +2982 -0
- package/Utils/AiRemediation/Resource/ProxmoxCommandPolicy.ts +1679 -0
- package/Utils/AiRemediation/Resource/ResourceCommandPolicy.ts +851 -0
- package/Utils/AiRemediation/Resource/ResourceCommandPolicyCore.ts +593 -0
- package/Utils/AiRemediation/Resource/ResourceOutputRedactor.ts +2812 -0
- package/Utils/SessionReplay/SessionReplayBudgetMetricType.ts +184 -0
- package/build/dist/Models/DatabaseModels/AutoRemediationSuggestion.js +62 -0
- package/build/dist/Models/DatabaseModels/AutoRemediationSuggestion.js.map +1 -1
- package/build/dist/Models/DatabaseModels/CephCluster.js +219 -0
- package/build/dist/Models/DatabaseModels/CephCluster.js.map +1 -1
- package/build/dist/Models/DatabaseModels/DatabaseServer.js +219 -0
- package/build/dist/Models/DatabaseModels/DatabaseServer.js.map +1 -1
- package/build/dist/Models/DatabaseModels/DockerHost.js +219 -0
- package/build/dist/Models/DatabaseModels/DockerHost.js.map +1 -1
- package/build/dist/Models/DatabaseModels/DockerSwarmCluster.js +219 -0
- package/build/dist/Models/DatabaseModels/DockerSwarmCluster.js.map +1 -1
- package/build/dist/Models/DatabaseModels/GlobalConfig.js +1 -1
- package/build/dist/Models/DatabaseModels/GlobalConfig.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Host.js +219 -0
- package/build/dist/Models/DatabaseModels/Host.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Index.js +2 -0
- package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
- package/build/dist/Models/DatabaseModels/PodmanHost.js +219 -0
- package/build/dist/Models/DatabaseModels/PodmanHost.js.map +1 -1
- package/build/dist/Models/DatabaseModels/ProxmoxCluster.js +219 -0
- package/build/dist/Models/DatabaseModels/ProxmoxCluster.js.map +1 -1
- package/build/dist/Models/DatabaseModels/ResourceAiAgent.js +439 -0
- package/build/dist/Models/DatabaseModels/ResourceAiAgent.js.map +1 -0
- package/build/dist/Models/DatabaseModels/RunnerJob.js +145 -0
- package/build/dist/Models/DatabaseModels/RunnerJob.js.map +1 -1
- package/build/dist/Models/DatabaseModels/VMwareVCenter.js +219 -0
- package/build/dist/Models/DatabaseModels/VMwareVCenter.js.map +1 -1
- package/build/dist/Server/API/AutoRemediationAPI.js +231 -1
- package/build/dist/Server/API/AutoRemediationAPI.js.map +1 -1
- package/build/dist/Server/API/ResourceAiAccessAPI.js +1119 -0
- package/build/dist/Server/API/ResourceAiAccessAPI.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1796300000000-AddResourceAiAgents.js +168 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1796300000000-AddResourceAiAgents.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +2 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
- package/build/dist/Server/Infrastructure/Semaphore.js +6 -0
- package/build/dist/Server/Infrastructure/Semaphore.js.map +1 -1
- package/build/dist/Server/Middleware/TelemetryIngest.js +12 -5
- package/build/dist/Server/Middleware/TelemetryIngest.js.map +1 -1
- package/build/dist/Server/Services/AnalyticsDatabaseService.js +26 -1
- package/build/dist/Server/Services/AnalyticsDatabaseService.js.map +1 -1
- package/build/dist/Server/Services/AutoRemediationRuleEngineService.js +601 -3
- package/build/dist/Server/Services/AutoRemediationRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/CephClusterService.js +104 -0
- package/build/dist/Server/Services/CephClusterService.js.map +1 -1
- package/build/dist/Server/Services/DatabaseServerService.js +99 -0
- package/build/dist/Server/Services/DatabaseServerService.js.map +1 -1
- package/build/dist/Server/Services/DockerHostService.js +104 -0
- package/build/dist/Server/Services/DockerHostService.js.map +1 -1
- package/build/dist/Server/Services/DockerSwarmClusterService.js +104 -0
- package/build/dist/Server/Services/DockerSwarmClusterService.js.map +1 -1
- package/build/dist/Server/Services/HostService.js +114 -2
- package/build/dist/Server/Services/HostService.js.map +1 -1
- package/build/dist/Server/Services/MetricRecordingRuleService.js +46 -0
- package/build/dist/Server/Services/MetricRecordingRuleService.js.map +1 -1
- package/build/dist/Server/Services/PodmanHostService.js +104 -0
- package/build/dist/Server/Services/PodmanHostService.js.map +1 -1
- package/build/dist/Server/Services/ProxmoxClusterService.js +104 -0
- package/build/dist/Server/Services/ProxmoxClusterService.js.map +1 -1
- package/build/dist/Server/Services/ResourceAiAccessService.js +1028 -0
- package/build/dist/Server/Services/ResourceAiAccessService.js.map +1 -0
- package/build/dist/Server/Services/ResourceAiAgentJobService.js +173 -0
- package/build/dist/Server/Services/ResourceAiAgentJobService.js.map +1 -0
- package/build/dist/Server/Services/ResourceAiAgentService.js +1687 -0
- package/build/dist/Server/Services/ResourceAiAgentService.js.map +1 -0
- package/build/dist/Server/Services/RunnerJobService.js +344 -5
- package/build/dist/Server/Services/RunnerJobService.js.map +1 -1
- package/build/dist/Server/Services/TelemetryUsageBillingService.js +26 -0
- package/build/dist/Server/Services/TelemetryUsageBillingService.js.map +1 -1
- package/build/dist/Server/Services/TraceRecordingRuleService.js +37 -0
- package/build/dist/Server/Services/TraceRecordingRuleService.js.map +1 -1
- package/build/dist/Server/Services/VMwareVCenterService.js +104 -0
- package/build/dist/Server/Services/VMwareVCenterService.js.map +1 -1
- package/build/dist/Server/Utils/AI/Remediation/RemediationCommandTools.js +1029 -30
- package/build/dist/Server/Utils/AI/Remediation/RemediationCommandTools.js.map +1 -1
- package/build/dist/Server/Utils/AI/Remediation/RemediationExecutionRunner.js +633 -28
- package/build/dist/Server/Utils/AI/Remediation/RemediationExecutionRunner.js.map +1 -1
- package/build/dist/Server/Utils/AI/Remediation/RemediationPlanRunner.js +21 -1
- package/build/dist/Server/Utils/AI/Remediation/RemediationPlanRunner.js.map +1 -1
- package/build/dist/Server/Utils/AI/ResourceAccess/InfrastructureInvestigationToolkit.js +330 -0
- package/build/dist/Server/Utils/AI/ResourceAccess/InfrastructureInvestigationToolkit.js.map +1 -0
- package/build/dist/Server/Utils/AI/ResourceAccess/ResourceAccessContext.js +160 -0
- package/build/dist/Server/Utils/AI/ResourceAccess/ResourceAccessContext.js.map +1 -0
- package/build/dist/Server/Utils/AI/ResourceAccess/ResourceAccessToolNames.js +33 -0
- package/build/dist/Server/Utils/AI/ResourceAccess/ResourceAccessToolNames.js.map +1 -0
- package/build/dist/Server/Utils/AI/ResourceAccess/ResourceAiAccessSettings.js +640 -0
- package/build/dist/Server/Utils/AI/ResourceAccess/ResourceAiAccessSettings.js.map +1 -0
- package/build/dist/Server/Utils/AI/ResourceAccess/ResourceAiDeleteCleanup.js +226 -0
- package/build/dist/Server/Utils/AI/ResourceAccess/ResourceAiDeleteCleanup.js.map +1 -0
- package/build/dist/Server/Utils/AI/ResourceAccess/ResourceCommandJobRunner.js +600 -0
- package/build/dist/Server/Utils/AI/ResourceAccess/ResourceCommandJobRunner.js.map +1 -0
- package/build/dist/Server/Utils/AI/SRE/AIInvestigationEngine.js +50 -4
- package/build/dist/Server/Utils/AI/SRE/AIInvestigationEngine.js.map +1 -1
- package/build/dist/Server/Utils/AI/SRE/AlertInvestigationRunner.js +55 -4
- package/build/dist/Server/Utils/AI/SRE/AlertInvestigationRunner.js.map +1 -1
- package/build/dist/Server/Utils/AI/SRE/IncidentInvestigationRunner.js +55 -4
- package/build/dist/Server/Utils/AI/SRE/IncidentInvestigationRunner.js.map +1 -1
- package/build/dist/Server/Utils/AutoRemediation/CommandPlanExecutor.js +290 -13
- package/build/dist/Server/Utils/AutoRemediation/CommandPlanExecutor.js.map +1 -1
- package/build/dist/Server/Utils/AutoRemediation/RemediationVerifier.js +29 -1
- package/build/dist/Server/Utils/AutoRemediation/RemediationVerifier.js.map +1 -1
- package/build/dist/Server/Utils/Database/ProjectScopedReferenceValidator.js +9 -1
- package/build/dist/Server/Utils/Database/ProjectScopedReferenceValidator.js.map +1 -1
- package/build/dist/Server/Utils/SessionReplay/SessionReplayBudgetMetrics.js +627 -0
- package/build/dist/Server/Utils/SessionReplay/SessionReplayBudgetMetrics.js.map +1 -0
- package/build/dist/Server/Utils/SessionReplay/SessionReplayUsage.js +60 -5
- package/build/dist/Server/Utils/SessionReplay/SessionReplayUsage.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Alert.js +19 -15
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Alert.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/AlertEpisode.js +19 -15
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/AlertEpisode.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Auth.js +17 -1
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Auth.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Incident.js +183 -209
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Incident.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/IncidentEpisode.js +19 -15
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/IncidentEpisode.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/ScheduledMaintenance.js +233 -167
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/ScheduledMaintenance.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js +263 -110
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsActivityDeduplicator.js +129 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsActivityDeduplicator.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsCardChoices.js +266 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsCardChoices.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsCreateCommands.js +258 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsCreateCommands.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsMessageSize.js +104 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsMessageSize.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsReplies.js +183 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsReplies.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsTimezone.js +123 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsTimezone.js.map +1 -0
- package/build/dist/Types/AI/ResourceAiAccessApi.js +30 -0
- package/build/dist/Types/AI/ResourceAiAccessApi.js.map +1 -0
- package/build/dist/Types/AI/ResourceAiAccessPermissions.js +98 -0
- package/build/dist/Types/AI/ResourceAiAccessPermissions.js.map +1 -0
- package/build/dist/Types/AutoRemediation/AiRemediationCommandPlan.js +116 -29
- package/build/dist/Types/AutoRemediation/AiRemediationCommandPlan.js.map +1 -1
- package/build/dist/Types/Monitor/Recommendation/MonitorRecommendationCatalog.js +47 -21
- package/build/dist/Types/Monitor/Recommendation/MonitorRecommendationCatalog.js.map +1 -1
- package/build/dist/Types/Monitor/Recommendation/MonitorRecommendationTypes.js +5 -0
- package/build/dist/Types/Monitor/Recommendation/MonitorRecommendationTypes.js.map +1 -1
- package/build/dist/Types/Monitor/RumAlertTemplates.js +199 -3
- package/build/dist/Types/Monitor/RumAlertTemplates.js.map +1 -1
- package/build/dist/Types/ResourceAiAgent/AiResourceType.js +242 -0
- package/build/dist/Types/ResourceAiAgent/AiResourceType.js.map +1 -0
- package/build/dist/Types/ResourceAiAgent/ResourceAiAccess.js +275 -0
- package/build/dist/Types/ResourceAiAgent/ResourceAiAccess.js.map +1 -0
- package/build/dist/Types/Rum/SessionReplayBudgetMetricType.js +45 -0
- package/build/dist/Types/Rum/SessionReplayBudgetMetricType.js.map +1 -0
- package/build/dist/Types/Runbook/RunbookStepType.js +27 -0
- package/build/dist/Types/Runbook/RunbookStepType.js.map +1 -1
- package/build/dist/Types/Telemetry/TelemetryIngestSurface.js +13 -2
- package/build/dist/Types/Telemetry/TelemetryIngestSurface.js.map +1 -1
- package/build/dist/Utils/AI/InvestigationReport.js +71 -11
- package/build/dist/Utils/AI/InvestigationReport.js.map +1 -1
- package/build/dist/Utils/AiRemediation/Resource/CephCommandPolicy.js +1462 -0
- package/build/dist/Utils/AiRemediation/Resource/CephCommandPolicy.js.map +1 -0
- package/build/dist/Utils/AiRemediation/Resource/DatabaseCommandPolicy.js +122 -0
- package/build/dist/Utils/AiRemediation/Resource/DatabaseCommandPolicy.js.map +1 -0
- package/build/dist/Utils/AiRemediation/Resource/DatabaseDiagnosticCatalog.js +1139 -0
- package/build/dist/Utils/AiRemediation/Resource/DatabaseDiagnosticCatalog.js.map +1 -0
- package/build/dist/Utils/AiRemediation/Resource/DatabaseQueryRedactor.js +1060 -0
- package/build/dist/Utils/AiRemediation/Resource/DatabaseQueryRedactor.js.map +1 -0
- package/build/dist/Utils/AiRemediation/Resource/DockerCliGrammar.js +1301 -0
- package/build/dist/Utils/AiRemediation/Resource/DockerCliGrammar.js.map +1 -0
- package/build/dist/Utils/AiRemediation/Resource/DockerEngineCommandPolicy.js +370 -0
- package/build/dist/Utils/AiRemediation/Resource/DockerEngineCommandPolicy.js.map +1 -0
- package/build/dist/Utils/AiRemediation/Resource/DockerSwarmCommandPolicy.js +498 -0
- package/build/dist/Utils/AiRemediation/Resource/DockerSwarmCommandPolicy.js.map +1 -0
- package/build/dist/Utils/AiRemediation/Resource/GovcCommandPolicy.js +1565 -0
- package/build/dist/Utils/AiRemediation/Resource/GovcCommandPolicy.js.map +1 -0
- package/build/dist/Utils/AiRemediation/Resource/HostCommandPolicy.js +2206 -0
- package/build/dist/Utils/AiRemediation/Resource/HostCommandPolicy.js.map +1 -0
- package/build/dist/Utils/AiRemediation/Resource/ProxmoxCommandPolicy.js +1129 -0
- package/build/dist/Utils/AiRemediation/Resource/ProxmoxCommandPolicy.js.map +1 -0
- package/build/dist/Utils/AiRemediation/Resource/ResourceCommandPolicy.js +565 -0
- package/build/dist/Utils/AiRemediation/Resource/ResourceCommandPolicy.js.map +1 -0
- package/build/dist/Utils/AiRemediation/Resource/ResourceCommandPolicyCore.js +408 -0
- package/build/dist/Utils/AiRemediation/Resource/ResourceCommandPolicyCore.js.map +1 -0
- package/build/dist/Utils/AiRemediation/Resource/ResourceOutputRedactor.js +1910 -0
- package/build/dist/Utils/AiRemediation/Resource/ResourceOutputRedactor.js.map +1 -0
- package/build/dist/Utils/SessionReplay/SessionReplayBudgetMetricType.js +160 -0
- package/build/dist/Utils/SessionReplay/SessionReplayBudgetMetricType.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,453 @@
|
|
|
1
|
+
import AIIncidentInvestigationRunner from "../../../../Server/Utils/AI/SRE/IncidentInvestigationRunner";
|
|
2
|
+
import AIAlertInvestigationRunner from "../../../../Server/Utils/AI/SRE/AlertInvestigationRunner";
|
|
3
|
+
import AIInvestigationEngine, {
|
|
4
|
+
InvestigationRequest,
|
|
5
|
+
} from "../../../../Server/Utils/AI/SRE/AIInvestigationEngine";
|
|
6
|
+
import AIInvestigationQueue from "../../../../Server/Utils/AI/SRE/InvestigationQueue";
|
|
7
|
+
import IncidentAIContextBuilder, {
|
|
8
|
+
IncidentContextData,
|
|
9
|
+
} from "../../../../Server/Utils/AI/IncidentAIContextBuilder";
|
|
10
|
+
import AlertAIContextBuilder, {
|
|
11
|
+
AlertContextData,
|
|
12
|
+
} from "../../../../Server/Utils/AI/AlertAIContextBuilder";
|
|
13
|
+
import AIMemory from "../../../../Server/Utils/AI/SRE/AIMemory";
|
|
14
|
+
import { ObservabilityAssistantExtraTool } from "../../../../Server/Utils/AI/Chat/ObservabilityAssistant";
|
|
15
|
+
import ClusterAccessContext from "../../../../Server/Utils/AI/ClusterAccess/ClusterAccessContext";
|
|
16
|
+
import {
|
|
17
|
+
INVESTIGATION_MAX_WALL_CLOCK_MS,
|
|
18
|
+
LIST_CLUSTER_ACCESS_TOOL_NAME,
|
|
19
|
+
RUN_KUBECTL_TOOL_NAME,
|
|
20
|
+
} from "../../../../Server/Utils/AI/ClusterAccess/KubectlInvestigationToolkit";
|
|
21
|
+
import ResourceAccessContext from "../../../../Server/Utils/AI/ResourceAccess/ResourceAccessContext";
|
|
22
|
+
import {
|
|
23
|
+
LIST_INFRASTRUCTURE_ACCESS_TOOL_NAME,
|
|
24
|
+
RUN_INFRASTRUCTURE_COMMAND_TOOL_NAME,
|
|
25
|
+
} from "../../../../Server/Utils/AI/ResourceAccess/ResourceAccessToolNames";
|
|
26
|
+
import { ToolCallOutcome } from "../../../../Server/Utils/AI/Toolbox/Index";
|
|
27
|
+
import KubernetesClusterAiAccessService from "../../../../Server/Services/KubernetesClusterAiAccessService";
|
|
28
|
+
import ResourceAiAccessService from "../../../../Server/Services/ResourceAiAccessService";
|
|
29
|
+
import RunnerJobService from "../../../../Server/Services/RunnerJobService";
|
|
30
|
+
import logger from "../../../../Server/Utils/Logger";
|
|
31
|
+
import Alert from "../../../../Models/DatabaseModels/Alert";
|
|
32
|
+
import Incident from "../../../../Models/DatabaseModels/Incident";
|
|
33
|
+
import {
|
|
34
|
+
KubernetesAiRemediationMode,
|
|
35
|
+
KubernetesClusterAiAccessStatus,
|
|
36
|
+
} from "../../../../Types/Kubernetes/KubernetesClusterAiAccess";
|
|
37
|
+
import ObjectID from "../../../../Types/ObjectID";
|
|
38
|
+
import AiResourceType from "../../../../Types/ResourceAiAgent/AiResourceType";
|
|
39
|
+
import {
|
|
40
|
+
ResourceAiAccessStatus,
|
|
41
|
+
ResourceAiRemediationMode,
|
|
42
|
+
} from "../../../../Types/ResourceAiAgent/ResourceAiAccess";
|
|
43
|
+
import { afterEach, beforeEach, describe, expect, test } from "@jest/globals";
|
|
44
|
+
|
|
45
|
+
/*
|
|
46
|
+
* Infrastructure access (Docker, Podman, Swarm, Proxmox, VMware, Ceph,
|
|
47
|
+
* databases, hosts) reaches an investigation through the same four wires
|
|
48
|
+
* cluster access does — the tools, the persona addendum, the context block
|
|
49
|
+
* and the shared wall clock — BESIDE the cluster wiring, never instead of
|
|
50
|
+
* it:
|
|
51
|
+
*
|
|
52
|
+
* - with no linked resource, every request is exactly what it was (the
|
|
53
|
+
* cluster addendum alone, the kubectl tools alone);
|
|
54
|
+
* - the cluster rules come first, the infrastructure rules after;
|
|
55
|
+
* - a failed resource lookup never fails the run and never takes the
|
|
56
|
+
* cluster access away (and the other way round).
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
const projectId: ObjectID = ObjectID.generate();
|
|
60
|
+
const aiRunId: ObjectID = ObjectID.generate();
|
|
61
|
+
const incidentId: ObjectID = ObjectID.generate();
|
|
62
|
+
const alertId: ObjectID = ObjectID.generate();
|
|
63
|
+
const CLUSTER_ID: string = "33333333-3333-4333-8333-333333333333";
|
|
64
|
+
const RUNNER_ID: string = "44444444-4444-4444-8444-444444444444";
|
|
65
|
+
const DOCKER_ID: string = "55555555-5555-4555-8555-555555555555";
|
|
66
|
+
const AGENT_ID: string = "66666666-6666-4666-8666-666666666666";
|
|
67
|
+
const HOST_ID: string = "77777777-7777-4777-8777-777777777777";
|
|
68
|
+
|
|
69
|
+
type SubjectKind = "incident" | "alert";
|
|
70
|
+
|
|
71
|
+
const SUBJECT_KINDS: Array<SubjectKind> = ["incident", "alert"];
|
|
72
|
+
|
|
73
|
+
function clusterStatus(): KubernetesClusterAiAccessStatus {
|
|
74
|
+
return {
|
|
75
|
+
clusterId: CLUSTER_ID,
|
|
76
|
+
clusterName: "prod-us",
|
|
77
|
+
clusterIdentifier: "prod-us",
|
|
78
|
+
runner: {
|
|
79
|
+
id: RUNNER_ID,
|
|
80
|
+
name: "kubernetes-agent/prod-us",
|
|
81
|
+
isOnline: true,
|
|
82
|
+
canRunAiCommands: true,
|
|
83
|
+
posture: { inCluster: true, allowWrites: false },
|
|
84
|
+
},
|
|
85
|
+
accessMethod: "in_cluster",
|
|
86
|
+
aiAgent: null,
|
|
87
|
+
automaticInvestigation: { incidents: false, alerts: false },
|
|
88
|
+
kubectlAllowlist: [],
|
|
89
|
+
isInvestigationEnabled: true,
|
|
90
|
+
isInvestigationReady: true,
|
|
91
|
+
remediationMode: KubernetesAiRemediationMode.RequireApproval,
|
|
92
|
+
isRemediationReady: true,
|
|
93
|
+
gaps: [],
|
|
94
|
+
evaluatedAt: new Date().toISOString(),
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function resourceStatus(
|
|
99
|
+
overrides: Partial<ResourceAiAccessStatus> = {},
|
|
100
|
+
): ResourceAiAccessStatus {
|
|
101
|
+
return {
|
|
102
|
+
resourceType: AiResourceType.DockerHost,
|
|
103
|
+
resourceId: DOCKER_ID,
|
|
104
|
+
resourceName: "web-1",
|
|
105
|
+
isAiInvestigationEnabled: true,
|
|
106
|
+
aiRemediationMode: ResourceAiRemediationMode.Disabled,
|
|
107
|
+
aiCommandAllowlist: [],
|
|
108
|
+
agent: { agentId: AGENT_ID, connectionStatus: "connected", isOnline: true },
|
|
109
|
+
gaps: [],
|
|
110
|
+
isInvestigationReady: true,
|
|
111
|
+
isRemediationReady: false,
|
|
112
|
+
...overrides,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function unreachableHost(): ResourceAiAccessStatus {
|
|
117
|
+
return resourceStatus({
|
|
118
|
+
resourceType: AiResourceType.Host,
|
|
119
|
+
resourceId: HOST_ID,
|
|
120
|
+
resourceName: "db-host",
|
|
121
|
+
agent: null,
|
|
122
|
+
isInvestigationReady: false,
|
|
123
|
+
gaps: [
|
|
124
|
+
{
|
|
125
|
+
code: "ai_agent_not_connected",
|
|
126
|
+
title: "No Host AI agent is connected",
|
|
127
|
+
nextStep: "Install the Host AI agent.",
|
|
128
|
+
blocksInvestigation: true,
|
|
129
|
+
blocksRemediation: true,
|
|
130
|
+
},
|
|
131
|
+
],
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function sentRequest(executeRun: jest.SpyInstance): InvestigationRequest {
|
|
136
|
+
return (executeRun.mock.calls[0]![0] as { request: InvestigationRequest })
|
|
137
|
+
.request;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function toolNames(request: InvestigationRequest): Array<string> {
|
|
141
|
+
return (request.extraTools || []).map(
|
|
142
|
+
(tool: ObservabilityAssistantExtraTool) => {
|
|
143
|
+
return tool.definition.name;
|
|
144
|
+
},
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
async function investigate(kind: SubjectKind): Promise<void> {
|
|
149
|
+
if (kind === "incident") {
|
|
150
|
+
const incident: Incident = new Incident(incidentId);
|
|
151
|
+
incident.title = "web-1 is restarting";
|
|
152
|
+
jest
|
|
153
|
+
.spyOn(IncidentAIContextBuilder, "buildIncidentContext")
|
|
154
|
+
.mockResolvedValue({
|
|
155
|
+
incident,
|
|
156
|
+
stateTimeline: [],
|
|
157
|
+
internalNotes: [],
|
|
158
|
+
publicNotes: [],
|
|
159
|
+
workspaceMessages: [],
|
|
160
|
+
} as unknown as IncidentContextData);
|
|
161
|
+
jest
|
|
162
|
+
.spyOn(AIMemory, "getPriorSimilarIncidentsContext")
|
|
163
|
+
.mockResolvedValue("");
|
|
164
|
+
|
|
165
|
+
await AIIncidentInvestigationRunner.executeInvestigation({
|
|
166
|
+
aiRunId,
|
|
167
|
+
projectId,
|
|
168
|
+
incidentId,
|
|
169
|
+
attemptCount: 1,
|
|
170
|
+
});
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const alert: Alert = new Alert(alertId);
|
|
175
|
+
alert.title = "[Docker] Container restarting";
|
|
176
|
+
jest.spyOn(AlertAIContextBuilder, "buildAlertContext").mockResolvedValue({
|
|
177
|
+
alert,
|
|
178
|
+
stateTimeline: [],
|
|
179
|
+
internalNotes: [],
|
|
180
|
+
} as unknown as AlertContextData);
|
|
181
|
+
|
|
182
|
+
await AIAlertInvestigationRunner.executeInvestigation({
|
|
183
|
+
aiRunId,
|
|
184
|
+
projectId,
|
|
185
|
+
alertId,
|
|
186
|
+
attemptCount: 1,
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
describe("Investigation runners wire infrastructure access beside cluster access", () => {
|
|
191
|
+
let executeRun: jest.SpyInstance;
|
|
192
|
+
let clusterStatuses: jest.SpyInstance;
|
|
193
|
+
let resourceStatuses: jest.SpyInstance;
|
|
194
|
+
let failOrRequeue: jest.SpyInstance;
|
|
195
|
+
|
|
196
|
+
beforeEach(() => {
|
|
197
|
+
jest.spyOn(logger, "error").mockImplementation((): void => {
|
|
198
|
+
return undefined;
|
|
199
|
+
});
|
|
200
|
+
executeRun = jest
|
|
201
|
+
.spyOn(AIInvestigationEngine, "executeRun")
|
|
202
|
+
.mockResolvedValue(undefined);
|
|
203
|
+
clusterStatuses = jest
|
|
204
|
+
.spyOn(KubernetesClusterAiAccessService, "getStatusesForSubject")
|
|
205
|
+
.mockResolvedValue([]);
|
|
206
|
+
resourceStatuses = jest
|
|
207
|
+
.spyOn(ResourceAiAccessService, "getStatusesForSubject")
|
|
208
|
+
.mockResolvedValue([resourceStatus()]);
|
|
209
|
+
failOrRequeue = jest
|
|
210
|
+
.spyOn(AIInvestigationQueue, "failOrRequeue")
|
|
211
|
+
.mockResolvedValue("noop");
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
afterEach(() => {
|
|
215
|
+
jest.restoreAllMocks();
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
test.each(SUBJECT_KINDS)(
|
|
219
|
+
"a %s investigation gets the infrastructure tools, addendum, context block and the shared wall clock",
|
|
220
|
+
async (kind: SubjectKind) => {
|
|
221
|
+
await investigate(kind);
|
|
222
|
+
|
|
223
|
+
expect(resourceStatuses).toHaveBeenCalledWith(
|
|
224
|
+
kind === "incident"
|
|
225
|
+
? { projectId, incidentId }
|
|
226
|
+
: { projectId, alertId },
|
|
227
|
+
);
|
|
228
|
+
|
|
229
|
+
const request: InvestigationRequest = sentRequest(executeRun);
|
|
230
|
+
|
|
231
|
+
expect(toolNames(request)).toEqual([
|
|
232
|
+
LIST_INFRASTRUCTURE_ACCESS_TOOL_NAME,
|
|
233
|
+
RUN_INFRASTRUCTURE_COMMAND_TOOL_NAME,
|
|
234
|
+
]);
|
|
235
|
+
expect(request.additionalInstructions).toBe(
|
|
236
|
+
ResourceAccessContext.buildPersonaAddendum([resourceStatus()]),
|
|
237
|
+
);
|
|
238
|
+
expect(request.contextSummary).toContain("# Infrastructure access");
|
|
239
|
+
expect(request.contextSummary).toContain(
|
|
240
|
+
`- Docker host "web-1" (resourceId: ${DOCKER_ID}): READ access via run_infrastructure_command`,
|
|
241
|
+
);
|
|
242
|
+
expect(request.contextSummary).not.toContain("# Cluster access");
|
|
243
|
+
expect(request.maxWallClockMs).toBe(INVESTIGATION_MAX_WALL_CLOCK_MS);
|
|
244
|
+
expect(failOrRequeue).not.toHaveBeenCalled();
|
|
245
|
+
},
|
|
246
|
+
);
|
|
247
|
+
|
|
248
|
+
test.each(SUBJECT_KINDS)(
|
|
249
|
+
"a %s linked to a cluster and a resource gets both, cluster rules first",
|
|
250
|
+
async (kind: SubjectKind) => {
|
|
251
|
+
clusterStatuses.mockResolvedValue([clusterStatus()]);
|
|
252
|
+
|
|
253
|
+
await investigate(kind);
|
|
254
|
+
|
|
255
|
+
const request: InvestigationRequest = sentRequest(executeRun);
|
|
256
|
+
|
|
257
|
+
expect(toolNames(request)).toEqual([
|
|
258
|
+
LIST_CLUSTER_ACCESS_TOOL_NAME,
|
|
259
|
+
RUN_KUBECTL_TOOL_NAME,
|
|
260
|
+
LIST_INFRASTRUCTURE_ACCESS_TOOL_NAME,
|
|
261
|
+
RUN_INFRASTRUCTURE_COMMAND_TOOL_NAME,
|
|
262
|
+
]);
|
|
263
|
+
expect(request.additionalInstructions).toBe(
|
|
264
|
+
`${ClusterAccessContext.buildPersonaAddendum([
|
|
265
|
+
clusterStatus(),
|
|
266
|
+
])}\n\n${ResourceAccessContext.buildPersonaAddendum([
|
|
267
|
+
resourceStatus(),
|
|
268
|
+
])}`,
|
|
269
|
+
);
|
|
270
|
+
|
|
271
|
+
const summary: string = request.contextSummary;
|
|
272
|
+
expect(summary.indexOf("# Cluster access")).toBeGreaterThan(-1);
|
|
273
|
+
expect(summary.indexOf("# Infrastructure access")).toBeGreaterThan(
|
|
274
|
+
summary.indexOf("# Cluster access"),
|
|
275
|
+
);
|
|
276
|
+
},
|
|
277
|
+
);
|
|
278
|
+
|
|
279
|
+
test.each(SUBJECT_KINDS)(
|
|
280
|
+
"a %s with no linked resource is wired exactly as before",
|
|
281
|
+
async (kind: SubjectKind) => {
|
|
282
|
+
clusterStatuses.mockResolvedValue([clusterStatus()]);
|
|
283
|
+
resourceStatuses.mockResolvedValue([]);
|
|
284
|
+
|
|
285
|
+
await investigate(kind);
|
|
286
|
+
|
|
287
|
+
const request: InvestigationRequest = sentRequest(executeRun);
|
|
288
|
+
|
|
289
|
+
expect(toolNames(request)).toEqual([
|
|
290
|
+
LIST_CLUSTER_ACCESS_TOOL_NAME,
|
|
291
|
+
RUN_KUBECTL_TOOL_NAME,
|
|
292
|
+
]);
|
|
293
|
+
// Byte for byte the cluster addendum alone — nothing appended.
|
|
294
|
+
expect(request.additionalInstructions).toBe(
|
|
295
|
+
ClusterAccessContext.buildPersonaAddendum([clusterStatus()]),
|
|
296
|
+
);
|
|
297
|
+
expect(request.contextSummary).not.toContain("# Infrastructure access");
|
|
298
|
+
},
|
|
299
|
+
);
|
|
300
|
+
|
|
301
|
+
test.each(SUBJECT_KINDS)(
|
|
302
|
+
"a %s about nothing reachable carries no access wiring at all",
|
|
303
|
+
async (kind: SubjectKind) => {
|
|
304
|
+
resourceStatuses.mockResolvedValue([]);
|
|
305
|
+
|
|
306
|
+
await investigate(kind);
|
|
307
|
+
|
|
308
|
+
const request: InvestigationRequest = sentRequest(executeRun);
|
|
309
|
+
expect(request.extraTools).toBeUndefined();
|
|
310
|
+
expect(request.additionalInstructions).toBeUndefined();
|
|
311
|
+
expect(request.contextSummary).not.toContain("# Infrastructure access");
|
|
312
|
+
expect(request.contextSummary).not.toContain("# Cluster access");
|
|
313
|
+
},
|
|
314
|
+
);
|
|
315
|
+
|
|
316
|
+
test.each(SUBJECT_KINDS)(
|
|
317
|
+
"a %s linked only to a resource without an agent gets no tools, but is told why and what to install",
|
|
318
|
+
async (kind: SubjectKind) => {
|
|
319
|
+
resourceStatuses.mockResolvedValue([unreachableHost()]);
|
|
320
|
+
|
|
321
|
+
await investigate(kind);
|
|
322
|
+
|
|
323
|
+
const request: InvestigationRequest = sentRequest(executeRun);
|
|
324
|
+
expect(request.extraTools).toBeUndefined();
|
|
325
|
+
expect(request.additionalInstructions).toContain(
|
|
326
|
+
'CANNOT inspect directly: Host "db-host"',
|
|
327
|
+
);
|
|
328
|
+
expect(request.additionalInstructions).toContain(
|
|
329
|
+
"the operator should install the Host AI agent",
|
|
330
|
+
);
|
|
331
|
+
expect(request.contextSummary).toContain(
|
|
332
|
+
"NO direct access — No Host AI agent is connected. Install the Host AI agent.",
|
|
333
|
+
);
|
|
334
|
+
},
|
|
335
|
+
);
|
|
336
|
+
|
|
337
|
+
test.each(SUBJECT_KINDS)(
|
|
338
|
+
"a %s whose resource lookup fails keeps its cluster access and still runs",
|
|
339
|
+
async (kind: SubjectKind) => {
|
|
340
|
+
clusterStatuses.mockResolvedValue([clusterStatus()]);
|
|
341
|
+
resourceStatuses.mockRejectedValue(new Error("database unavailable"));
|
|
342
|
+
|
|
343
|
+
await investigate(kind);
|
|
344
|
+
|
|
345
|
+
expect(executeRun).toHaveBeenCalledTimes(1);
|
|
346
|
+
const request: InvestigationRequest = sentRequest(executeRun);
|
|
347
|
+
expect(toolNames(request)).toEqual([
|
|
348
|
+
LIST_CLUSTER_ACCESS_TOOL_NAME,
|
|
349
|
+
RUN_KUBECTL_TOOL_NAME,
|
|
350
|
+
]);
|
|
351
|
+
expect(request.additionalInstructions).toBe(
|
|
352
|
+
ClusterAccessContext.buildPersonaAddendum([clusterStatus()]),
|
|
353
|
+
);
|
|
354
|
+
expect(request.contextSummary).not.toContain("# Infrastructure access");
|
|
355
|
+
expect(failOrRequeue).not.toHaveBeenCalled();
|
|
356
|
+
},
|
|
357
|
+
);
|
|
358
|
+
|
|
359
|
+
test.each(SUBJECT_KINDS)(
|
|
360
|
+
"a %s whose cluster lookup fails keeps its infrastructure access",
|
|
361
|
+
async (kind: SubjectKind) => {
|
|
362
|
+
clusterStatuses.mockRejectedValue(new Error("cluster table unavailable"));
|
|
363
|
+
|
|
364
|
+
await investigate(kind);
|
|
365
|
+
|
|
366
|
+
const request: InvestigationRequest = sentRequest(executeRun);
|
|
367
|
+
expect(toolNames(request)).toEqual([
|
|
368
|
+
LIST_INFRASTRUCTURE_ACCESS_TOOL_NAME,
|
|
369
|
+
RUN_INFRASTRUCTURE_COMMAND_TOOL_NAME,
|
|
370
|
+
]);
|
|
371
|
+
expect(failOrRequeue).not.toHaveBeenCalled();
|
|
372
|
+
},
|
|
373
|
+
);
|
|
374
|
+
|
|
375
|
+
test.each(SUBJECT_KINDS)(
|
|
376
|
+
"a %s whose infrastructure context cannot be written drops the tools too, never the run",
|
|
377
|
+
async (kind: SubjectKind) => {
|
|
378
|
+
jest
|
|
379
|
+
.spyOn(ResourceAccessContext, "buildContextSection")
|
|
380
|
+
.mockImplementation((): string => {
|
|
381
|
+
throw new Error("cannot render");
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
await investigate(kind);
|
|
385
|
+
|
|
386
|
+
expect(executeRun).toHaveBeenCalledTimes(1);
|
|
387
|
+
const request: InvestigationRequest = sentRequest(executeRun);
|
|
388
|
+
expect(request.extraTools).toBeUndefined();
|
|
389
|
+
expect(request.additionalInstructions).toBeUndefined();
|
|
390
|
+
expect(failOrRequeue).not.toHaveBeenCalled();
|
|
391
|
+
},
|
|
392
|
+
);
|
|
393
|
+
|
|
394
|
+
test("both runners wire the same infrastructure access for the same statuses", async () => {
|
|
395
|
+
resourceStatuses.mockResolvedValue([resourceStatus(), unreachableHost()]);
|
|
396
|
+
|
|
397
|
+
await investigate("incident");
|
|
398
|
+
await investigate("alert");
|
|
399
|
+
|
|
400
|
+
const incidentRequest: InvestigationRequest = (
|
|
401
|
+
executeRun.mock.calls[0]![0] as { request: InvestigationRequest }
|
|
402
|
+
).request;
|
|
403
|
+
const alertRequest: InvestigationRequest = (
|
|
404
|
+
executeRun.mock.calls[1]![0] as { request: InvestigationRequest }
|
|
405
|
+
).request;
|
|
406
|
+
|
|
407
|
+
expect(toolNames(alertRequest)).toEqual(toolNames(incidentRequest));
|
|
408
|
+
expect(alertRequest.additionalInstructions).toBe(
|
|
409
|
+
incidentRequest.additionalInstructions,
|
|
410
|
+
);
|
|
411
|
+
|
|
412
|
+
const block: (summary: string) => string = (summary: string): string => {
|
|
413
|
+
return summary.slice(summary.indexOf("# Infrastructure access"));
|
|
414
|
+
};
|
|
415
|
+
expect(block(alertRequest.contextSummary)).toBe(
|
|
416
|
+
block(incidentRequest.contextSummary),
|
|
417
|
+
);
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
test.each(SUBJECT_KINDS)(
|
|
421
|
+
"a %s investigation's infrastructure tools are bound to this run and its deadline",
|
|
422
|
+
async (kind: SubjectKind) => {
|
|
423
|
+
const NOW_MS: number = 1_700_000_000_000;
|
|
424
|
+
const now: jest.SpyInstance = jest
|
|
425
|
+
.spyOn(Date, "now")
|
|
426
|
+
.mockReturnValue(NOW_MS);
|
|
427
|
+
const enqueue: jest.SpyInstance = jest.spyOn(
|
|
428
|
+
RunnerJobService,
|
|
429
|
+
"enqueueAiResourceCommand",
|
|
430
|
+
);
|
|
431
|
+
|
|
432
|
+
await investigate(kind);
|
|
433
|
+
|
|
434
|
+
const runCommand: ObservabilityAssistantExtraTool = (
|
|
435
|
+
sentRequest(executeRun).extraTools || []
|
|
436
|
+
).find((tool: ObservabilityAssistantExtraTool) => {
|
|
437
|
+
return tool.definition.name === RUN_INFRASTRUCTURE_COMMAND_TOOL_NAME;
|
|
438
|
+
})!;
|
|
439
|
+
|
|
440
|
+
// The run's wall clock has run out: the toolkit refuses on its own.
|
|
441
|
+
now.mockReturnValue(NOW_MS + INVESTIGATION_MAX_WALL_CLOCK_MS + 1);
|
|
442
|
+
const outcome: ToolCallOutcome = await runCommand.execute({
|
|
443
|
+
resourceId: DOCKER_ID,
|
|
444
|
+
command: "docker ps -a",
|
|
445
|
+
rationale: "see the containers",
|
|
446
|
+
});
|
|
447
|
+
|
|
448
|
+
expect(outcome.success).toBe(false);
|
|
449
|
+
expect(outcome.textForLlm).toContain("Not enough time is left");
|
|
450
|
+
expect(enqueue).not.toHaveBeenCalled();
|
|
451
|
+
},
|
|
452
|
+
);
|
|
453
|
+
});
|