@oneuptime/common 14.0.9 → 14.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1146) hide show
  1. package/Models/DatabaseModels/AIConversation.ts +127 -1
  2. package/Models/DatabaseModels/AutoRemediationSuggestion.ts +60 -0
  3. package/Models/DatabaseModels/CephCluster.ts +225 -0
  4. package/Models/DatabaseModels/CloudResource.ts +12 -0
  5. package/Models/DatabaseModels/DatabaseServer.ts +225 -0
  6. package/Models/DatabaseModels/DockerHost.ts +225 -0
  7. package/Models/DatabaseModels/DockerSwarmCluster.ts +225 -0
  8. package/Models/DatabaseModels/GlobalConfig.ts +1 -1
  9. package/Models/DatabaseModels/GlobalOidc.ts +0 -4
  10. package/Models/DatabaseModels/GlobalOidcProject.ts +0 -4
  11. package/Models/DatabaseModels/GlobalSso.ts +0 -4
  12. package/Models/DatabaseModels/GlobalSsoProject.ts +0 -4
  13. package/Models/DatabaseModels/Host.ts +225 -0
  14. package/Models/DatabaseModels/IncidentForm.ts +594 -0
  15. package/Models/DatabaseModels/IncidentFormSubmission.ts +283 -0
  16. package/Models/DatabaseModels/IncidentTemplate.ts +59 -0
  17. package/Models/DatabaseModels/Index.ts +16 -0
  18. package/Models/DatabaseModels/IoTFleet.ts +12 -0
  19. package/Models/DatabaseModels/KubernetesCluster.ts +12 -0
  20. package/Models/DatabaseModels/MessageQueue.ts +1102 -0
  21. package/Models/DatabaseModels/MessageQueueLabelRule.ts +553 -0
  22. package/Models/DatabaseModels/MessageQueueOwnerRule.ts +633 -0
  23. package/Models/DatabaseModels/MessageQueueOwnerTeam.ts +491 -0
  24. package/Models/DatabaseModels/MessageQueueOwnerUser.ts +490 -0
  25. package/Models/DatabaseModels/PodmanHost.ts +225 -0
  26. package/Models/DatabaseModels/Project.ts +59 -0
  27. package/Models/DatabaseModels/ProjectOidc.ts +0 -4
  28. package/Models/DatabaseModels/ProjectSso.ts +0 -4
  29. package/Models/DatabaseModels/ProxmoxCluster.ts +225 -0
  30. package/Models/DatabaseModels/ResourceAiAgent.ts +419 -0
  31. package/Models/DatabaseModels/RumApplication.ts +12 -0
  32. package/Models/DatabaseModels/RunnerJob.ts +144 -0
  33. package/Models/DatabaseModels/ServerlessFunction.ts +12 -0
  34. package/Models/DatabaseModels/Service.ts +12 -0
  35. package/Models/DatabaseModels/StatusPageOidc.ts +0 -4
  36. package/Models/DatabaseModels/StatusPageSso.ts +0 -4
  37. package/Models/DatabaseModels/TeamComplianceSetting.ts +47 -2
  38. package/Models/DatabaseModels/VMwareVCenter.ts +225 -0
  39. package/Server/API/AIChatAPI.ts +13 -114
  40. package/Server/API/AIInvestigationAPI.ts +3 -3
  41. package/Server/API/AIInvestigationConversationAPI.ts +266 -0
  42. package/Server/API/AutoRemediationAPI.ts +392 -1
  43. package/Server/API/IncidentFormAPI.ts +376 -0
  44. package/Server/API/ProjectOIDC.ts +16 -25
  45. package/Server/API/ProjectSSO.ts +16 -24
  46. package/Server/API/ResourceAiAccessAPI.ts +1669 -0
  47. package/Server/API/StatusPageAPI.ts +42 -77
  48. package/Server/Enterprise/EnterpriseEdition.ts +93 -28
  49. package/Server/Enterprise/EnterpriseFeature.ts +25 -3
  50. package/Server/Enterprise/EnterpriseLicenseSnapshot.ts +1 -1
  51. package/Server/Enterprise/EnterpriseServerModule.ts +4 -1
  52. package/Server/EnvironmentConfig.ts +1 -1
  53. package/Server/Infrastructure/Postgres/SchemaMigrations/1796300000000-AddResourceAiAgents.ts +423 -0
  54. package/Server/Infrastructure/Postgres/SchemaMigrations/1796400000000-AddIncidentForms.ts +129 -0
  55. package/Server/Infrastructure/Postgres/SchemaMigrations/1796500000000-AddTeamComplianceRuleNotificationChannels.ts +52 -0
  56. package/Server/Infrastructure/Postgres/SchemaMigrations/1796600000000-AddAIInvestigationConversationAndTimeLimits.ts +75 -0
  57. package/Server/Infrastructure/Postgres/SchemaMigrations/1796700000000-AddMessageQueueTables.ts +477 -0
  58. package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +10 -0
  59. package/Server/Infrastructure/Semaphore.ts +22 -0
  60. package/Server/Middleware/IncidentFormRateLimit.ts +847 -0
  61. package/Server/Middleware/TelemetryIngest.ts +15 -5
  62. package/Server/Middleware/UserAuthorization.ts +16 -38
  63. package/Server/Services/AIService.ts +10 -13
  64. package/Server/Services/AnalyticsDatabaseService.ts +45 -1
  65. package/Server/Services/AutoRemediationRuleEngineService.ts +940 -112
  66. package/Server/Services/CephClusterService.ts +109 -1
  67. package/Server/Services/DatabaseServerService.ts +116 -1
  68. package/Server/Services/DockerHostService.ts +109 -1
  69. package/Server/Services/DockerSwarmClusterService.ts +113 -1
  70. package/Server/Services/HostService.ts +126 -4
  71. package/Server/Services/IncidentCustomFieldService.ts +112 -2
  72. package/Server/Services/IncidentEpisodeMemberService.ts +24 -4
  73. package/Server/Services/IncidentEpisodeService.ts +10 -1
  74. package/Server/Services/IncidentFormService.ts +1566 -0
  75. package/Server/Services/IncidentFormSubmissionService.ts +97 -0
  76. package/Server/Services/IncidentGroupingEngineService.ts +45 -8
  77. package/Server/Services/IncidentService.ts +123 -5
  78. package/Server/Services/IncidentTemplateService.ts +22 -0
  79. package/Server/Services/Index.ts +14 -0
  80. package/Server/Services/MessageQueueLabelRuleEngineService.ts +321 -0
  81. package/Server/Services/MessageQueueLabelRuleService.ts +14 -0
  82. package/Server/Services/MessageQueueOwnerRuleEngineService.ts +412 -0
  83. package/Server/Services/MessageQueueOwnerRuleService.ts +14 -0
  84. package/Server/Services/MessageQueueOwnerTeamService.ts +62 -0
  85. package/Server/Services/MessageQueueOwnerUserService.ts +62 -0
  86. package/Server/Services/MessageQueueService.ts +1463 -0
  87. package/Server/Services/MetricRecordingRuleService.ts +47 -0
  88. package/Server/Services/OpenTelemetryIngestService.ts +37 -4
  89. package/Server/Services/PodmanHostService.ts +109 -1
  90. package/Server/Services/ProjectService.ts +0 -59
  91. package/Server/Services/ProxmoxClusterService.ts +110 -1
  92. package/Server/Services/ResourceAiAccessService.ts +1439 -0
  93. package/Server/Services/ResourceAiAgentJobService.ts +202 -0
  94. package/Server/Services/ResourceAiAgentService.ts +2432 -0
  95. package/Server/Services/RunnerJobService.ts +611 -4
  96. package/Server/Services/StatusPagePrivateUserService.ts +1 -4
  97. package/Server/Services/StatusPageService.ts +1 -51
  98. package/Server/Services/TeamComplianceSettingService.ts +163 -42
  99. package/Server/Services/TelemetryUsageBillingService.ts +28 -0
  100. package/Server/Services/TraceRecordingRuleService.ts +33 -0
  101. package/Server/Services/UserNotificationRuleService.ts +8 -1
  102. package/Server/Services/VMwareVCenterService.ts +110 -1
  103. package/Server/Services/WorkspaceNotificationSummaryService.ts +12 -3
  104. package/Server/Types/Database/Permissions/CreatePermission.ts +17 -3
  105. package/Server/Types/Database/Permissions/EditionPermission.ts +140 -38
  106. package/Server/Types/Database/Permissions/OwnerTableRegistry.ts +16 -0
  107. package/Server/Types/Database/Permissions/TablePermission.ts +3 -3
  108. package/Server/Types/Database/Permissions/UpdatePermission.ts +20 -6
  109. package/Server/Utils/AI/Chat/AgentContextCompactor.ts +200 -0
  110. package/Server/Utils/AI/Chat/ChatAgentRunner.ts +307 -48
  111. package/Server/Utils/AI/Chat/ChatRunCancellation.ts +156 -0
  112. package/Server/Utils/AI/Chat/ObservabilityAssistant.ts +78 -18
  113. package/Server/Utils/AI/Chat/ObservabilityChatPrompt.ts +1 -1
  114. package/Server/Utils/AI/Chat/ToolOutputPager.ts +322 -0
  115. package/Server/Utils/AI/ClusterAccess/KubectlInvestigationToolkit.ts +88 -30
  116. package/Server/Utils/AI/ClusterAccess/KubectlJobRunner.ts +13 -1
  117. package/Server/Utils/AI/CodeFix/CodeFixReadiness.ts +0 -32
  118. package/Server/Utils/AI/CodeFix/FixRunBudget.ts +27 -25
  119. package/Server/Utils/AI/Remediation/RemediationCommandTools.ts +1442 -34
  120. package/Server/Utils/AI/Remediation/RemediationExecutionRunner.ts +968 -34
  121. package/Server/Utils/AI/Remediation/RemediationPlanRunner.ts +25 -1
  122. package/Server/Utils/AI/ResourceAccess/InfrastructureInvestigationToolkit.ts +622 -0
  123. package/Server/Utils/AI/ResourceAccess/ResourceAccessContext.ts +271 -0
  124. package/Server/Utils/AI/ResourceAccess/ResourceAccessToolNames.ts +45 -0
  125. package/Server/Utils/AI/ResourceAccess/ResourceAiAccessSettings.ts +964 -0
  126. package/Server/Utils/AI/ResourceAccess/ResourceAiDeleteCleanup.ts +333 -0
  127. package/Server/Utils/AI/ResourceAccess/ResourceCommandJobRunner.ts +882 -0
  128. package/Server/Utils/AI/SRE/AIInvestigationEngine.ts +125 -12
  129. package/Server/Utils/AI/SRE/AlertInvestigationRunner.ts +99 -15
  130. package/Server/Utils/AI/SRE/IncidentInvestigationRunner.ts +99 -15
  131. package/Server/Utils/AI/SRE/InvestigationQueue.ts +16 -19
  132. package/Server/Utils/AI/SRE/InvestigationThread.ts +646 -0
  133. package/Server/Utils/AI/SRE/InvestigationThreadService.ts +715 -0
  134. package/Server/Utils/AI/Toolbox/Serializer.ts +10 -3
  135. package/Server/Utils/AutoRemediation/CommandPlanExecutor.ts +396 -13
  136. package/Server/Utils/AutoRemediation/RemediationVerifier.ts +35 -2
  137. package/Server/Utils/Database/ProjectScopedReferenceValidator.ts +9 -1
  138. package/Server/Utils/EditionEnforcement.ts +19 -202
  139. package/Server/Utils/LLM/LLMService.ts +259 -63
  140. package/Server/Utils/RelaxedScimTeamLocksReport.ts +245 -0
  141. package/Server/Utils/Rules/RuleRun/RuleRunRegistry.ts +25 -0
  142. package/Server/Utils/SameOriginRequest.ts +203 -0
  143. package/Server/Utils/SessionReplay/SessionReplayBudgetMetrics.ts +920 -0
  144. package/Server/Utils/SessionReplay/SessionReplayUsage.ts +84 -6
  145. package/Server/Utils/TeamMember/ProjectLeaveResourceCleanup.ts +2 -0
  146. package/Server/Utils/Telemetry/EntityRegistry.ts +4 -1
  147. package/Server/Utils/Telemetry/MessageQueueDiscovery.ts +1402 -0
  148. package/Server/Utils/Telemetry/ResourceEntityFilter.ts +4 -1
  149. package/Server/Utils/VendorAssets.ts +3 -3
  150. package/Server/Utils/Workspace/MicrosoftTeams/Actions/Alert.ts +35 -15
  151. package/Server/Utils/Workspace/MicrosoftTeams/Actions/AlertEpisode.ts +33 -15
  152. package/Server/Utils/Workspace/MicrosoftTeams/Actions/Auth.ts +21 -1
  153. package/Server/Utils/Workspace/MicrosoftTeams/Actions/Incident.ts +301 -225
  154. package/Server/Utils/Workspace/MicrosoftTeams/Actions/IncidentEpisode.ts +38 -16
  155. package/Server/Utils/Workspace/MicrosoftTeams/Actions/ScheduledMaintenance.ts +389 -175
  156. package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.ts +376 -144
  157. package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsActivityDeduplicator.ts +163 -0
  158. package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsCardChoices.ts +396 -0
  159. package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsCreateCommands.ts +418 -0
  160. package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsMessageSize.ts +152 -0
  161. package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsReplies.ts +251 -0
  162. package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsTimezone.ts +214 -0
  163. package/Tests/App/Accounts/IncidentFormPage.test.tsx +2036 -0
  164. package/Tests/App/Accounts/IncidentFormServerMessages.test.ts +119 -0
  165. package/Tests/App/Accounts/IncidentFormUtils.test.ts +1157 -0
  166. package/Tests/App/Accounts/LoginPasskey.test.tsx +6 -4
  167. package/Tests/App/Accounts/LoginSso.test.tsx +724 -0
  168. package/Tests/App/AdminDashboard/AdminAuthenticationRequireSso.test.tsx +338 -0
  169. package/Tests/App/AdminDashboard/AdminAuthenticationSsoCardLocales.test.tsx +331 -0
  170. package/Tests/App/AdminDashboard/AdminEnterprisePluginPage.test.tsx +47 -33
  171. package/Tests/App/AdminDashboard/GlobalSsoOidcPages.test.tsx +1021 -0
  172. package/Tests/App/Dashboard/AffectedResourcesDisplay.test.tsx +876 -78
  173. package/Tests/App/Dashboard/AffectedResourcesSlo.test.tsx +20 -3
  174. package/Tests/App/Dashboard/CephProxmoxVMwareDocumentationCards.test.tsx +359 -0
  175. package/Tests/App/Dashboard/CephSetupGuide.test.ts +961 -0
  176. package/Tests/App/Dashboard/CloudDocumentationCard.test.tsx +381 -95
  177. package/Tests/App/Dashboard/CloudSetupGuide.test.ts +1463 -0
  178. package/Tests/App/Dashboard/ClusterAccessNotice.test.tsx +267 -12
  179. package/Tests/App/Dashboard/ContainerSetupGuideCards.test.tsx +345 -0
  180. package/Tests/App/Dashboard/CoreListEmptyStates.test.tsx +501 -0
  181. package/Tests/App/Dashboard/DashboardLazyPages.test.tsx +0 -1
  182. package/Tests/App/Dashboard/DatabaseDocumentationCard.test.tsx +400 -0
  183. package/Tests/App/Dashboard/DatabaseDocumentationMarkdown.test.ts +23 -6
  184. package/Tests/App/Dashboard/DatabaseSetupGuide.test.ts +1869 -0
  185. package/Tests/App/Dashboard/DatabaseTelemetryScope.test.ts +44 -0
  186. package/Tests/App/Dashboard/DatabaseTelemetryTabs.test.tsx +50 -9
  187. package/Tests/App/Dashboard/DockerSetupGuide.test.ts +899 -0
  188. package/Tests/App/Dashboard/DockerSwarmSetupGuide.test.ts +964 -0
  189. package/Tests/App/Dashboard/EnterpriseFeatureUpgrade.test.tsx +141 -7
  190. package/Tests/App/Dashboard/EnterprisePluginPage.test.tsx +52 -39
  191. package/Tests/App/Dashboard/EventOverviewPages.test.tsx +7 -1
  192. package/Tests/App/Dashboard/GettingStartedTaskRoutes.test.tsx +331 -0
  193. package/Tests/App/Dashboard/HomeOverviewStatsFirstRun.test.tsx +925 -0
  194. package/Tests/App/Dashboard/HostDocumentationCard.test.tsx +225 -0
  195. package/Tests/App/Dashboard/HostSetupGuide.test.ts +1183 -0
  196. package/Tests/App/Dashboard/IdentityEnterpriseShells.test.tsx +69 -45
  197. package/Tests/App/Dashboard/IncidentCreateTemplateCustomFieldSettings.test.tsx +745 -0
  198. package/Tests/App/Dashboard/IncidentCreateTemplateOwners.test.tsx +414 -0
  199. package/Tests/App/Dashboard/IncidentCustomFieldCreateSettingsForm.test.ts +1042 -0
  200. package/Tests/App/Dashboard/IncidentCustomFieldSettingsCard.test.tsx +1816 -0
  201. package/Tests/App/Dashboard/IncidentFormPlan.test.ts +89 -0
  202. package/Tests/App/Dashboard/IncidentFormShareLinkCard.test.tsx +846 -0
  203. package/Tests/App/Dashboard/IncidentFormsPages.test.tsx +1324 -0
  204. package/Tests/App/Dashboard/IncidentTemplateCustomFieldSettings.test.tsx +630 -0
  205. package/Tests/App/Dashboard/IncidentsSideMenu.test.tsx +13 -0
  206. package/Tests/App/Dashboard/IncomingEmailMonitorLinkVerifyHint.test.tsx +104 -0
  207. package/Tests/App/Dashboard/InvestigationConversation.test.tsx +1107 -0
  208. package/Tests/App/Dashboard/InvestigationConversationData.test.ts +546 -0
  209. package/Tests/App/Dashboard/InvestigationEvidenceList.test.tsx +170 -5
  210. package/Tests/App/Dashboard/InvestigationInfrastructureTools.test.tsx +506 -0
  211. package/Tests/App/Dashboard/InvestigationNotStarted.test.tsx +207 -2
  212. package/Tests/App/Dashboard/InvestigationPanel.test.tsx +729 -34
  213. package/Tests/App/Dashboard/InvestigationPanelStatus.test.tsx +9 -21
  214. package/Tests/App/Dashboard/InvestigationReportView.test.tsx +274 -37
  215. package/Tests/App/Dashboard/InvestigationStatusBadge.test.tsx +130 -0
  216. package/Tests/App/Dashboard/IoTDocumentationCard.test.tsx +218 -0
  217. package/Tests/App/Dashboard/IoTSetupGuide.test.ts +1124 -0
  218. package/Tests/App/Dashboard/KubernetesClusterAiAccessSettings.test.ts +20 -6
  219. package/Tests/App/Dashboard/KubernetesClusterAiDocumentationMarkdown.test.ts +107 -83
  220. package/Tests/App/Dashboard/KubernetesSetupGuide.test.ts +787 -0
  221. package/Tests/App/Dashboard/MessageQueueBreadcrumbs.test.tsx +228 -0
  222. package/Tests/App/Dashboard/MessageQueueBrokerHealth.test.tsx +1538 -0
  223. package/Tests/App/Dashboard/MessageQueueBrokerHealthMetricChart.test.tsx +969 -0
  224. package/Tests/App/Dashboard/MessageQueueBrokerHealthReads.test.ts +889 -0
  225. package/Tests/App/Dashboard/MessageQueueBrokerMetricsReach.test.ts +236 -0
  226. package/Tests/App/Dashboard/MessageQueueDocumentationCard.test.tsx +479 -0
  227. package/Tests/App/Dashboard/MessageQueueListPages.test.tsx +1232 -0
  228. package/Tests/App/Dashboard/MessageQueueMetricDescriptions.test.ts +244 -0
  229. package/Tests/App/Dashboard/MessageQueueMonitorLink.test.ts +952 -0
  230. package/Tests/App/Dashboard/MessageQueueMonitorLinkMonitorCreate.test.tsx +859 -0
  231. package/Tests/App/Dashboard/MessageQueueOverview.test.tsx +1773 -0
  232. package/Tests/App/Dashboard/MessageQueueOverviewPresentation.test.ts +196 -0
  233. package/Tests/App/Dashboard/MessageQueuePresentation.test.ts +799 -0
  234. package/Tests/App/Dashboard/MessageQueueProducersConsumers.test.tsx +680 -0
  235. package/Tests/App/Dashboard/MessageQueueRoutes.test.tsx +383 -0
  236. package/Tests/App/Dashboard/MessageQueueRulePages.test.tsx +278 -0
  237. package/Tests/App/Dashboard/MessageQueueSetupGuide.test.ts +2778 -0
  238. package/Tests/App/Dashboard/MessageQueueSideMenus.test.tsx +273 -0
  239. package/Tests/App/Dashboard/MessageQueueSpanPopulations.test.ts +930 -0
  240. package/Tests/App/Dashboard/MessageQueueSpanStore.ts +351 -0
  241. package/Tests/App/Dashboard/MessageQueueTelemetryScope.test.ts +375 -0
  242. package/Tests/App/Dashboard/MessageQueueTelemetryScopeTabs.test.tsx +668 -0
  243. package/Tests/App/Dashboard/MessageQueueViewPages.test.tsx +685 -0
  244. package/Tests/App/Dashboard/MonitorAndHomeNotOperationalMenus.test.tsx +342 -0
  245. package/Tests/App/Dashboard/MonitorCreateFirstRunDefaults.test.tsx +623 -0
  246. package/Tests/App/Dashboard/MonitorCreateFromMonitorBackedDevice.test.tsx +442 -0
  247. package/Tests/App/Dashboard/MonitorLogsPageViewSummary.test.tsx +814 -0
  248. package/Tests/App/Dashboard/MonitorSetupCardBodies.test.tsx +246 -0
  249. package/Tests/App/Dashboard/NavigationSearchKeywords.test.tsx +8 -0
  250. package/Tests/App/Dashboard/OnboardingSsoEmptyState.test.tsx +27 -12
  251. package/Tests/App/Dashboard/PlanGatedPage.test.tsx +292 -0
  252. package/Tests/App/Dashboard/PodmanSetupGuide.test.ts +948 -0
  253. package/Tests/App/Dashboard/ProductOrientation.test.tsx +5 -4
  254. package/Tests/App/Dashboard/ProductSettingsSectionCollapsed.test.tsx +266 -0
  255. package/Tests/App/Dashboard/ProxmoxSetupGuide.test.ts +1318 -0
  256. package/Tests/App/Dashboard/RemediationSuggestionCardDescription.test.tsx +209 -0
  257. package/Tests/App/Dashboard/RemediationSuggestionCardResource.test.tsx +317 -0
  258. package/Tests/App/Dashboard/ResourceAiAccessSettingsUtil.test.ts +921 -0
  259. package/Tests/App/Dashboard/ResourceAiAgentAttentionServerParity.test.ts +555 -0
  260. package/Tests/App/Dashboard/ResourceAiAgentInstall.test.ts +860 -0
  261. package/Tests/App/Dashboard/ResourceAiAgentPage.test.tsx +2010 -0
  262. package/Tests/App/Dashboard/ResourceAiAgentStatus.test.ts +1455 -0
  263. package/Tests/App/Dashboard/ResourceAiInsightsPage.test.tsx +931 -0
  264. package/Tests/App/Dashboard/ResourceAiNavigation.test.tsx +575 -0
  265. package/Tests/App/Dashboard/ResourceArchiveSettings.test.tsx +16 -0
  266. package/Tests/App/Dashboard/ResourceConnectionGuideCard.test.tsx +444 -0
  267. package/Tests/App/Dashboard/ResourceConnectionGuideOverviewsInfra.test.tsx +798 -0
  268. package/Tests/App/Dashboard/ResourceConnectionGuideOverviewsPlatforms.test.tsx +717 -0
  269. package/Tests/App/Dashboard/ResourceConnectionGuides.test.ts +981 -0
  270. package/Tests/App/Dashboard/ResourceConnectionState.test.ts +132 -0
  271. package/Tests/App/Dashboard/RumDocumentationCard.test.tsx +293 -0
  272. package/Tests/App/Dashboard/RumSessionReplayRetentionSettings.test.tsx +467 -0
  273. package/Tests/App/Dashboard/RumSetupGuide.test.ts +758 -0
  274. package/Tests/App/Dashboard/RunbookStepTypeMaps.test.ts +38 -7
  275. package/Tests/App/Dashboard/ScheduledMaintenanceOverviewPage.test.tsx +25 -0
  276. package/Tests/App/Dashboard/ServerlessDocumentationCard.test.tsx +254 -0
  277. package/Tests/App/Dashboard/ServerlessSetupGuide.test.ts +1074 -0
  278. package/Tests/App/Dashboard/SetupGuide.test.ts +246 -0
  279. package/Tests/App/Dashboard/SetupGuideCard.test.tsx +756 -0
  280. package/Tests/App/Dashboard/SloListSideMenu.test.tsx +120 -0
  281. package/Tests/App/Dashboard/SsoPages.test.tsx +833 -0
  282. package/Tests/App/Dashboard/TelemetryDocumentation.test.tsx +253 -0
  283. package/Tests/App/Dashboard/TelemetryRetentionShells.test.tsx +730 -0
  284. package/Tests/App/Dashboard/VMwareSetupGuide.test.ts +1033 -0
  285. package/Tests/App/StatusPage/StatusPageSsoEmptyState.test.tsx +87 -7
  286. package/Tests/Models/DatabaseModels/DatabaseServerModels.test.ts +61 -10
  287. package/Tests/Models/DatabaseModels/IncidentFormModel.test.ts +1250 -0
  288. package/Tests/Models/DatabaseModels/MessageQueueModels.test.ts +1983 -0
  289. package/Tests/Models/DatabaseModels/ResourceAiAccessColumns.test.ts +738 -0
  290. package/Tests/Models/DatabaseModels/ResourceAiAgentModel.test.ts +842 -0
  291. package/Tests/Models/DatabaseModels/StaticRuleCriteriaInheritance.test.ts +4 -2
  292. package/Tests/Models/DatabaseModels/TeamComplianceSettingModel.test.ts +190 -14
  293. package/Tests/Models/IncidentTemplateCustomFieldSettingsColumn.test.ts +291 -0
  294. package/Tests/Server/API/AIInvestigationConversationAPI.test.ts +412 -0
  295. package/Tests/Server/API/AutoRemediationApproveResourceRound.test.ts +835 -0
  296. package/Tests/Server/API/GlobalConfigLicense.test.ts +38 -9
  297. package/Tests/Server/API/IncidentFormAPI.test.ts +942 -0
  298. package/Tests/Server/API/IncidentFormPublicRoutes.test.ts +1653 -0
  299. package/Tests/Server/API/KubernetesClusterAiAccessAPI.test.ts +2 -1
  300. package/Tests/Server/API/ResourceAiAccessAPI.test.ts +2730 -0
  301. package/Tests/Server/API/{SsoProviderListingsEdition.test.ts → SsoProviderListings.test.ts} +164 -110
  302. package/Tests/Server/Enterprise/EnterpriseEdition.test.ts +76 -54
  303. package/Tests/Server/Enterprise/EnterpriseFeatureActive.test.ts +125 -42
  304. package/Tests/Server/Enterprise/EnterpriseLicenseSnapshot.test.ts +36 -10
  305. package/Tests/Server/Enterprise/EnterpriseModelFeatureMap.test.ts +51 -9
  306. package/Tests/Server/Enterprise/FakeEnterpriseModule.ts +13 -8
  307. package/Tests/Server/Enterprise/SsoInCommunityEdition.test.ts +540 -0
  308. package/Tests/Server/Infrastructure/Postgres/AddConfigurableRuleCriteriaMigration.test.ts +3 -0
  309. package/Tests/Server/Infrastructure/Postgres/AddDatabaseServerTablesMigration.test.ts +60 -0
  310. package/Tests/Server/Infrastructure/Postgres/AddIncidentFormsMigration.test.ts +438 -0
  311. package/Tests/Server/Infrastructure/Postgres/AddResourceAiAgentsMigration.test.ts +659 -0
  312. package/Tests/Server/Infrastructure/Postgres/AddTeamComplianceRuleNotificationChannelsMigration.test.ts +255 -0
  313. package/Tests/Server/Infrastructure/Postgres/MessageQueueTablesMigration.test.ts +637 -0
  314. package/Tests/Server/Infrastructure/SemaphoreMutex.test.ts +31 -0
  315. package/Tests/Server/Middleware/IncidentFormRateLimit.test.ts +1630 -0
  316. package/Tests/Server/Middleware/TelemetryIngestBrowserKey.test.ts +63 -5
  317. package/Tests/Server/Middleware/TelemetryIngestKubernetesAgentRunnerPinnedKey.test.ts +103 -5
  318. package/Tests/Server/Middleware/TelemetryIngestKubernetesAgentRunnerRateLimit.test.ts +19 -1
  319. package/Tests/Server/Middleware/UserAuthorization.test.ts +16 -17
  320. package/Tests/Server/Middleware/UserAuthorizationSsoEnforcement.test.ts +544 -0
  321. package/Tests/Server/Services/AIServiceDailyBudget.test.ts +37 -8
  322. package/Tests/Server/Services/AutoRemediationResourceRuleEngine.test.ts +1279 -0
  323. package/Tests/Server/Services/DatabaseServerService.test.ts +55 -0
  324. package/Tests/Server/Services/GroupTelemetryUsageExcludeNames.test.ts +299 -0
  325. package/Tests/Server/Services/HostServiceFindOrCreateMemo.test.ts +44 -0
  326. package/Tests/Server/Services/IncidentCreatedFeedTitle.test.ts +212 -0
  327. package/Tests/Server/Services/IncidentCustomFieldDeleteFormQuestions.test.ts +297 -0
  328. package/Tests/Server/Services/IncidentFormOwnersCreatedNotification.test.ts +497 -0
  329. package/Tests/Server/Services/IncidentFormPostgres.test.ts +958 -0
  330. package/Tests/Server/Services/IncidentFormPublicForm.test.ts +1260 -0
  331. package/Tests/Server/Services/IncidentFormPublicSubmission.test.ts +2520 -0
  332. package/Tests/Server/Services/IncidentFormRegistration.test.ts +159 -0
  333. package/Tests/Server/Services/IncidentFormService.test.ts +663 -0
  334. package/Tests/Server/Services/IncidentFormSubmissionService.test.ts +430 -0
  335. package/Tests/Server/Services/IncidentFormSubmissionTemplateBranch.test.ts +473 -0
  336. package/Tests/Server/Services/IncidentGroupingTemplateSubstitution.test.ts +81 -0
  337. package/Tests/Server/Services/IncidentTemplateCustomFieldSettings.test.ts +262 -0
  338. package/Tests/Server/Services/IncidentTemplateOwnersOnDeclare.test.ts +566 -0
  339. package/Tests/Server/Services/IncidentTitleMarkdownSinks.test.ts +640 -0
  340. package/Tests/Server/Services/LlmLogServiceTokenAggregateParams.test.ts +3 -3
  341. package/Tests/Server/Services/MessageQueueOwnerServices.test.ts +440 -0
  342. package/Tests/Server/Services/MessageQueueRegistries.test.ts +577 -0
  343. package/Tests/Server/Services/MessageQueueRuleEngines.test.ts +900 -0
  344. package/Tests/Server/Services/MessageQueueService.test.ts +2210 -0
  345. package/Tests/Server/Services/MessageQueueSqlPostgres.test.ts +1271 -0
  346. package/Tests/Server/Services/MonitorProbeServiceIntervalScheduling.test.ts +45 -6
  347. package/Tests/Server/Services/OpenTelemetryResourceRetentionMemo.test.ts +28 -1
  348. package/Tests/Server/Services/OpenTelemetryRetentionOverrideEdition.test.ts +474 -0
  349. package/Tests/Server/Services/OpenTelemetryServiceResolutionCache.test.ts +21 -0
  350. package/Tests/Server/Services/OwnerRowUniqueness.test.ts +3 -0
  351. package/Tests/Server/Services/ProjectServiceAuditLogLicense.test.ts +0 -1
  352. package/Tests/Server/Services/RecordingRuleReservedMetricName.test.ts +171 -0
  353. package/Tests/Server/Services/ResourceAiAccessChangeAuthorization.test.ts +256 -0
  354. package/Tests/Server/Services/ResourceAiAccessService.test.ts +1373 -0
  355. package/Tests/Server/Services/ResourceAiAgentJobService.test.ts +375 -0
  356. package/Tests/Server/Services/ResourceAiAgentServiceHelpers.test.ts +1114 -0
  357. package/Tests/Server/Services/ResourceAiAgentServiceLifecycle.test.ts +1050 -0
  358. package/Tests/Server/Services/ResourceAiAgentServiceRegister.test.ts +2251 -0
  359. package/Tests/Server/Services/ResourceAiSettingsCreate.test.ts +373 -0
  360. package/Tests/Server/Services/ResourceAiSettingsPermission.test.ts +1042 -0
  361. package/Tests/Server/Services/ResourceServiceDeleteCleansUpAi.test.ts +319 -0
  362. package/Tests/Server/Services/RuleRun/LabelRuleEnginesGroupBRun.test.ts +56 -6
  363. package/Tests/Server/Services/RuleRun/OwnerRuleEnginesGroupBRun.test.ts +30 -1
  364. package/Tests/Server/Services/RunnerJobEnqueueKubectl.test.ts +105 -0
  365. package/Tests/Server/Services/RunnerJobEnqueueResourceCommand.test.ts +986 -0
  366. package/Tests/Server/Services/RunnerJobResourceCommandLane.test.ts +211 -0
  367. package/Tests/Server/Services/RunnerJobResourceCommandTimeoutAndRedaction.test.ts +352 -0
  368. package/Tests/Server/Services/SsoRequirementReads.test.ts +454 -0
  369. package/Tests/Server/Services/SsoRequirementWrites.test.ts +529 -0
  370. package/Tests/Server/Services/StaticRuleCriteriaRuntimeCoverage.test.ts +3 -3
  371. package/Tests/Server/Services/StatusPagePrivateUserInvitationPolicy.test.ts +107 -89
  372. package/Tests/Server/Services/TeamComplianceSettingPostgres.test.ts +1068 -176
  373. package/Tests/Server/Services/TeamComplianceSettingService.test.ts +1962 -200
  374. package/Tests/Server/Services/TelemetryUsageBillingSloExclusion.test.ts +218 -0
  375. package/Tests/Server/TestingUtils/Services/FakeRunnerJobCount.ts +145 -0
  376. package/Tests/Server/Types/Database/Permissions/EditionPermission.test.ts +654 -297
  377. package/Tests/Server/Types/Database/Permissions/RetentionOverrideColumns.test.ts +784 -0
  378. package/Tests/Server/Types/Database/Permissions/SsoScalePlanGate.test.ts +418 -0
  379. package/Tests/Server/Utils/AI/AIAlertGating.test.ts +0 -1
  380. package/Tests/Server/Utils/AI/AIInvestigationEngineRunLimits.test.ts +136 -0
  381. package/Tests/Server/Utils/AI/AIInvestigationQueue.test.ts +15 -14
  382. package/Tests/Server/Utils/AI/AgentContextCompactor.test.ts +351 -0
  383. package/Tests/Server/Utils/AI/ChatAgentRunnerSharedThread.test.ts +842 -0
  384. package/Tests/Server/Utils/AI/ChatRunCancellation.test.ts +195 -0
  385. package/Tests/Server/Utils/AI/CodeFixReadiness.test.ts +10 -57
  386. package/Tests/Server/Utils/AI/FixRunBudget.test.ts +20 -24
  387. package/Tests/Server/Utils/AI/Insights/InvestigationQueueInsightSubject.test.ts +7 -30
  388. package/Tests/Server/Utils/AI/InvestigationClusterAccessWiring.test.ts +225 -29
  389. package/Tests/Server/Utils/AI/InvestigationInfrastructureAccessWiring.test.ts +694 -0
  390. package/Tests/Server/Utils/AI/InvestigationInfrastructureReport.test.ts +721 -0
  391. package/Tests/Server/Utils/AI/InvestigationThread.test.ts +580 -0
  392. package/Tests/Server/Utils/AI/InvestigationThreadService.test.ts +801 -0
  393. package/Tests/Server/Utils/AI/KubectlInvestigationToolkit.test.ts +525 -43
  394. package/Tests/Server/Utils/AI/KubectlJobRunner.test.ts +4 -2
  395. package/Tests/Server/Utils/AI/LLMServiceUnreachableProvider.test.ts +435 -0
  396. package/Tests/Server/Utils/AI/ObservabilityAssistantLimits.test.ts +462 -0
  397. package/Tests/Server/Utils/AI/RemediationCommandTools.test.ts +94 -1
  398. package/Tests/Server/Utils/AI/RemediationCommandToolsResource.test.ts +1530 -0
  399. package/Tests/Server/Utils/AI/RemediationExecutionRunner.test.ts +14 -25
  400. package/Tests/Server/Utils/AI/RemediationExecutionRunnerResourceMode.test.ts +1251 -0
  401. package/Tests/Server/Utils/AI/RemediationPlanRunner.test.ts +117 -0
  402. package/Tests/Server/Utils/AI/RemediationResourceCopyParity.test.ts +463 -0
  403. package/Tests/Server/Utils/AI/ResourceAccess/InfrastructureInvestigationToolkit.test.ts +1004 -0
  404. package/Tests/Server/Utils/AI/ResourceAccess/ResourceAccessContext.test.ts +266 -0
  405. package/Tests/Server/Utils/AI/ResourceAccess/ResourceAiAccessSettings.test.ts +1220 -0
  406. package/Tests/Server/Utils/AI/ResourceAccess/ResourceAiDeleteCleanup.test.ts +569 -0
  407. package/Tests/Server/Utils/AI/ResourceAccess/ResourceCommandJobRunner.test.ts +834 -0
  408. package/Tests/Server/Utils/AI/ToolOutputPager.test.ts +382 -0
  409. package/Tests/Server/Utils/AI/ToolResultSerializer.test.ts +23 -4
  410. package/Tests/Server/Utils/AI/Toolbox/LogTools.test.ts +25 -6
  411. package/Tests/Server/Utils/AI/Toolbox/Serializer.test.ts +14 -3
  412. package/Tests/Server/Utils/AutoRemediation/CommandPlanExecutorResource.test.ts +717 -0
  413. package/Tests/Server/Utils/AutoRemediation/RemediationVerifierResourceFollowUp.test.ts +338 -0
  414. package/Tests/Server/Utils/EditionEnforcement.test.ts +107 -147
  415. package/Tests/Server/Utils/Monitor/Criteria/SessionReplayBudgetTemplateCriteria.test.ts +422 -0
  416. package/Tests/Server/Utils/{CommunityEditionSsoReport.test.ts → RelaxedScimTeamLocksReport.test.ts} +212 -208
  417. package/Tests/Server/Utils/SameOriginRequest.test.ts +372 -0
  418. package/Tests/Server/Utils/SessionReplay/SessionReplayBudgetMetrics.test.ts +1647 -0
  419. package/Tests/Server/Utils/SessionReplay/SessionReplayUsage.test.ts +143 -1
  420. package/Tests/Server/Utils/Telemetry/EntityRegistry.test.ts +20 -0
  421. package/Tests/Server/Utils/Telemetry/MessageQueueDiscovery.test.ts +2590 -0
  422. package/Tests/Server/Utils/Telemetry/MessageQueueSpanQueryTwin.ts +246 -0
  423. package/Tests/Server/Utils/Telemetry/TelemetryEntity.test.ts +23 -0
  424. package/Tests/Server/Utils/Telemetry/TelemetryIngestionKeyGuard.test.ts +33 -3
  425. package/Tests/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsAccountNotLinked.test.ts +1093 -0
  426. package/Tests/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsActivityDeduplicator.test.ts +1049 -0
  427. package/Tests/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsCardChoices.test.ts +1676 -0
  428. package/Tests/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsCreateCards.test.ts +2884 -0
  429. package/Tests/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsCreateCommands.test.ts +2490 -0
  430. package/Tests/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsCreateSubmit.test.ts +2293 -0
  431. package/Tests/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsCreateSubmitServerTimezone.test.ts +386 -0
  432. package/Tests/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsMessageSize.test.ts +1477 -0
  433. package/Tests/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsReplies.test.ts +1967 -0
  434. package/Tests/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsStripHtmlTags.test.ts +92 -0
  435. package/Tests/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsSubmittedFormRemoval.test.ts +1819 -0
  436. package/Tests/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsTimezone.test.ts +1033 -0
  437. package/Tests/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsTimezoneServerZone.test.ts +610 -0
  438. package/Tests/Server/Utils/Workspace/MicrosoftTeamsBotMessageHandling.test.ts +2610 -0
  439. package/Tests/Server/Utils/Workspace/MicrosoftTeamsCreateCommandsEndToEnd.test.ts +4672 -0
  440. package/Tests/Server/Utils/Workspace/WorkspaceCreateProjectReferences.test.ts +190 -65
  441. package/Tests/Types/AI/AIAgentRunLimits.test.ts +255 -0
  442. package/Tests/Types/AutoRemediation/AiRemediationCommandPlan.test.ts +10 -4
  443. package/Tests/Types/AutoRemediation/AiRemediationCommandPlanResourceCommand.test.ts +305 -0
  444. package/Tests/Types/Code/JsonSyntax.test.ts +1300 -0
  445. package/Tests/Types/CustomField/CustomFieldCreateSettings.test.ts +1113 -0
  446. package/Tests/Types/CustomField/CustomFieldMappingCatalog.test.ts +91 -0
  447. package/Tests/Types/CustomField/CustomFieldValueValidator.test.ts +30 -0
  448. package/Tests/Types/Incident/IncidentFormIpAllowlist.test.ts +227 -0
  449. package/Tests/Types/Incident/IncidentFormPublic.test.ts +1916 -0
  450. package/Tests/Types/MessageQueue/MessageQueueEntityKey.test.ts +916 -0
  451. package/Tests/Types/MessageQueue/MessageQueueIdentity.test.ts +567 -0
  452. package/Tests/Types/MessageQueue/MessageQueueManualIdentity.test.ts +686 -0
  453. package/Tests/Types/MessageQueue/MessageQueueMetricCatalog.test.ts +1726 -0
  454. package/Tests/Types/MessageQueue/MessageQueueMetricResolution.test.ts +1758 -0
  455. package/Tests/Types/MessageQueue/MessagingInstrumentationFixtures.test.ts +4686 -0
  456. package/Tests/Types/MessageQueue/MessagingSystem.test.ts +840 -0
  457. package/Tests/Types/MessageQueue/MessagingTelemetryFixtures.ts +3287 -0
  458. package/Tests/Types/MessageQueue/MessagingTelemetryResolver.test.ts +2966 -0
  459. package/Tests/Types/Monitor/MessageQueueAlertTemplates.test.ts +5401 -0
  460. package/Tests/Types/Monitor/MetricEngineFold.ts +154 -0
  461. package/Tests/Types/Monitor/Recommendation/MonitorRecommendationCatalog.test.ts +277 -13
  462. package/Tests/Types/Monitor/Recommendation/MonitorRecommendationUtil.test.ts +113 -0
  463. package/Tests/Types/Monitor/RumAlertTemplates.test.ts +773 -2
  464. package/Tests/Types/ResourceAiAgent/AiResourceType.test.ts +419 -0
  465. package/Tests/Types/ResourceAiAgent/ResourceAiAccess.test.ts +519 -0
  466. package/Tests/Types/Runbook/RunbookStepType.test.ts +147 -8
  467. package/Tests/Types/Team/ComplianceRule.test.ts +588 -37
  468. package/Tests/Types/Team/TeamComplianceStatus.test.ts +64 -11
  469. package/Tests/Types/XML.test.ts +51 -0
  470. package/Tests/UI/Components/CodeEditor/CodeEditor.test.tsx +2362 -0
  471. package/Tests/UI/Components/CodeEditor/CodeEditorCommands.test.ts +810 -0
  472. package/Tests/UI/Components/CodeEditor/CodeEditorHighlight.test.ts +338 -0
  473. package/Tests/UI/Components/CodeEditor/CodeEditorLanguages.test.ts +222 -0
  474. package/Tests/UI/Components/CodeEditor/CodeEditorStyles.test.ts +807 -0
  475. package/Tests/UI/Components/CodeEditor/NoMonaco.test.ts +245 -0
  476. package/Tests/UI/Components/CodeEditor/YamlEditor.test.tsx +729 -0
  477. package/Tests/UI/Components/CopyTextButton.test.tsx +76 -0
  478. package/Tests/UI/Components/EditionLabelLapseCopy.ts +51 -14
  479. package/Tests/UI/Components/EditionLabelLicenseStatus.test.tsx +131 -23
  480. package/Tests/UI/Components/ErrorMessageAction.test.tsx +142 -0
  481. package/Tests/UI/Components/FacetSidebarInScope.test.tsx +459 -0
  482. package/Tests/UI/Components/FacetValuesInScope.test.ts +270 -0
  483. package/Tests/UI/Components/Forms/FormFieldCodeEditors.test.tsx +294 -0
  484. package/Tests/UI/Components/Forms/FormFieldMarkdown.test.tsx +126 -0
  485. package/Tests/UI/Components/Forms/FormFieldYaml.test.tsx +22 -75
  486. package/Tests/UI/Components/Forms/ModelFormOnBeforeCreateMiscData.test.tsx +254 -0
  487. package/Tests/UI/Components/Icon.test.tsx +32 -0
  488. package/Tests/UI/Components/Input.test.tsx +31 -0
  489. package/Tests/UI/Components/LockedFilterChipScope.test.tsx +501 -0
  490. package/Tests/UI/Components/MarkdownConverters.test.ts +253 -1
  491. package/Tests/UI/Components/MarkdownEditor.test.tsx +2785 -2
  492. package/Tests/UI/Components/MarkdownEditorHistory.test.ts +243 -0
  493. package/Tests/UI/Components/MarkdownListEditing.test.ts +1118 -0
  494. package/Tests/UI/Components/MarkdownPaste.test.ts +1180 -0
  495. package/Tests/UI/Components/MarkdownViewerCopy.test.tsx +466 -0
  496. package/Tests/UI/Components/MarkdownVisualEditing.test.ts +1089 -0
  497. package/Tests/UI/Components/ModelTable/BaseModelTableEmptyStateAction.test.tsx +623 -0
  498. package/Tests/UI/Components/ResetObjectID.test.tsx +282 -0
  499. package/Tests/UI/Components/RuleCriteria/RuleCriteriaModelTable.test.tsx +3 -3
  500. package/Tests/UI/Components/Table/EmptyTableMessage.test.ts +439 -0
  501. package/Tests/UI/Components/Table/TableEmptyState.test.tsx +352 -0
  502. package/Tests/UI/Components/TableRowMobileTitles.test.tsx +78 -0
  503. package/Tests/UI/Components/TextArea.test.tsx +19 -0
  504. package/Tests/UI/Components/Workflow/ModelColumnEditor.render.test.tsx +12 -29
  505. package/Tests/UI/Components/fixtures/MarkdownPasteFixtures.ts +460 -0
  506. package/Tests/UI/EsbuildConfig.test.ts +115 -39
  507. package/Tests/UI/EsbuildEnterpriseAlias.test.ts +4 -4
  508. package/Tests/UI/Monitor/MonitorLogSummaryRender.test.tsx +377 -0
  509. package/Tests/UI/Rum/RecordingHealthDashboard.test.tsx +769 -1
  510. package/Tests/UI/Utils/Breadcrumb/fixtures/RealBreadcrumbTrails.ts +81 -1
  511. package/Tests/UI/Utils/Breadcrumb/fixtures/RealRoutePatterns.ts +17 -0
  512. package/Tests/Utils/AiRemediation/Resource/CephCommandPolicy.test.ts +1653 -0
  513. package/Tests/Utils/AiRemediation/Resource/CephOutputRedaction.test.ts +204 -0
  514. package/Tests/Utils/AiRemediation/Resource/DatabaseCommandPolicy.test.ts +1077 -0
  515. package/Tests/Utils/AiRemediation/Resource/DatabaseDiagnosticCatalog.test.ts +558 -0
  516. package/Tests/Utils/AiRemediation/Resource/DatabaseQueryRedactor.test.ts +834 -0
  517. package/Tests/Utils/AiRemediation/Resource/DockerCliGrammar.test.ts +747 -0
  518. package/Tests/Utils/AiRemediation/Resource/DockerEngineCommandPolicy.test.ts +1259 -0
  519. package/Tests/Utils/AiRemediation/Resource/DockerOutputRedaction.test.ts +386 -0
  520. package/Tests/Utils/AiRemediation/Resource/DockerSwarmCommandPolicy.test.ts +782 -0
  521. package/Tests/Utils/AiRemediation/Resource/GovcCommandPolicy.test.ts +2259 -0
  522. package/Tests/Utils/AiRemediation/Resource/HostCommandPolicy.test.ts +2019 -0
  523. package/Tests/Utils/AiRemediation/Resource/ProxmoxCommandPolicy.test.ts +2497 -0
  524. package/Tests/Utils/AiRemediation/Resource/ResourceCommandPolicy.test.ts +1305 -0
  525. package/Tests/Utils/AiRemediation/Resource/ResourceCommandPolicyCore.test.ts +585 -0
  526. package/Tests/Utils/AiRemediation/Resource/ResourceOutputRedactor.test.ts +334 -0
  527. package/Tests/Utils/AiRemediation/Resource/ResourceOutputRedactorCopyParity.test.ts +98 -0
  528. package/Tests/Utils/AiRemediation/Resource/ResourcePolicyImportClosure.test.ts +391 -0
  529. package/Tests/Utils/AiRemediation/ResourceAiAgentPolicyCopyParity.test.ts +497 -0
  530. package/Tests/Utils/LabelRuleImportExport.test.ts +5 -0
  531. package/Tests/Utils/Markdown/DashboardMarkdownRenderer.ts +81 -0
  532. package/Tests/Utils/Markdown/UntrustedMarkdown.test.ts +1339 -0
  533. package/Tests/Utils/Monitor/MonitorLogSummaryUtil.test.ts +862 -0
  534. package/Tests/Utils/SessionReplay/SessionReplayBudgetMetricType.test.ts +383 -0
  535. package/Types/AI/AIAgentRunLimits.ts +146 -0
  536. package/Types/AI/ResourceAiAccessApi.ts +140 -0
  537. package/Types/AI/ResourceAiAccessPermissions.ts +126 -0
  538. package/Types/AutoRemediation/AiRemediationCommandPlan.ts +183 -2
  539. package/Types/Code/CodeType.ts +2 -0
  540. package/Types/Code/JsonSyntax.ts +923 -0
  541. package/Types/CustomField/CustomFieldCreateSettings.ts +549 -0
  542. package/Types/CustomField/CustomFieldMappingCatalog.ts +77 -0
  543. package/Types/CustomField/CustomFieldValueValidator.ts +10 -7
  544. package/Types/EnterpriseLicense/EnterpriseLicensePeriods.ts +1 -1
  545. package/Types/Icon/IconProp.ts +2 -0
  546. package/Types/Incident/IncidentFormIpAllowlist.ts +206 -0
  547. package/Types/Incident/IncidentFormPublic.ts +1145 -0
  548. package/Types/Kubernetes/KubernetesClusterAiAccess.ts +10 -3
  549. package/Types/MessageQueue/MessageQueueIdentity.ts +256 -0
  550. package/Types/MessageQueue/MessageQueueManualIdentity.ts +325 -0
  551. package/Types/MessageQueue/MessageQueueMetricCatalog.ts +1357 -0
  552. package/Types/MessageQueue/MessagingSystem.ts +518 -0
  553. package/Types/MessageQueue/MessagingTelemetryResolver.ts +2311 -0
  554. package/Types/Monitor/MessageQueueAlertTemplates.ts +2128 -0
  555. package/Types/Monitor/Recommendation/MonitorRecommendationCatalog.ts +55 -22
  556. package/Types/Monitor/Recommendation/MonitorRecommendationTypes.ts +35 -3
  557. package/Types/Monitor/RumAlertTemplates.ts +351 -4
  558. package/Types/Permission.ts +310 -0
  559. package/Types/ResourceAiAgent/AiResourceType.ts +310 -0
  560. package/Types/ResourceAiAgent/ResourceAiAccess.ts +580 -0
  561. package/Types/Rules/RuleCriteriaFieldRegistry.ts +12 -0
  562. package/Types/Rules/RuleRun.ts +4 -0
  563. package/Types/Rum/SessionReplayBudgetMetricType.ts +47 -0
  564. package/Types/Runbook/RunbookStepType.ts +29 -0
  565. package/Types/Team/ComplianceNotificationChannel.ts +4 -3
  566. package/Types/Team/ComplianceRule.ts +71 -18
  567. package/Types/Team/ComplianceRuleType.ts +2 -2
  568. package/Types/Team/TeamComplianceStatus.ts +6 -2
  569. package/Types/Telemetry/EntityType.ts +16 -0
  570. package/Types/Telemetry/LockedFilterDetail.ts +22 -0
  571. package/Types/Telemetry/TelemetryIngestSurface.ts +14 -2
  572. package/Types/XML.ts +26 -0
  573. package/UI/Components/CodeEditor/CodeEditor.css +379 -0
  574. package/UI/Components/CodeEditor/CodeEditor.tsx +1128 -294
  575. package/UI/Components/CodeEditor/CodeEditorCommands.ts +774 -0
  576. package/UI/Components/CodeEditor/CodeEditorHighlight.ts +106 -0
  577. package/UI/Components/CodeEditor/CodeEditorLanguages.ts +164 -0
  578. package/UI/Components/CodeEditor/YamlEditor.tsx +28 -326
  579. package/UI/Components/CopyTextButton/CopyTextButton.tsx +5 -1
  580. package/UI/Components/CustomFields/CustomFieldModelFormFields.tsx +6 -25
  581. package/UI/Components/EditionLabel/EditionLabel.tsx +14 -13
  582. package/UI/Components/ErrorMessage/ErrorMessage.tsx +11 -1
  583. package/UI/Components/Forms/Fields/FormField.tsx +8 -0
  584. package/UI/Components/Forms/Types/Field.ts +8 -0
  585. package/UI/Components/Icon/Icon.tsx +18 -0
  586. package/UI/Components/Input/Input.tsx +11 -4
  587. package/UI/Components/LogsViewer/LogsViewer.tsx +4 -0
  588. package/UI/Components/LogsViewer/components/LogsFacetSidebar.tsx +21 -3
  589. package/UI/Components/Markdown.tsx/MarkdownConverters.ts +0 -0
  590. package/UI/Components/Markdown.tsx/MarkdownEditor.tsx +877 -79
  591. package/UI/Components/Markdown.tsx/MarkdownEditorHistory.ts +284 -0
  592. package/UI/Components/Markdown.tsx/MarkdownListEditing.ts +1362 -0
  593. package/UI/Components/Markdown.tsx/MarkdownPaste.ts +1326 -0
  594. package/UI/Components/Markdown.tsx/MarkdownViewer.tsx +106 -10
  595. package/UI/Components/Markdown.tsx/MarkdownVisualEditing.ts +1032 -0
  596. package/UI/Components/ModelTable/BaseModelTable.tsx +85 -7
  597. package/UI/Components/ResetObjectID/ResetObjectID.tsx +35 -9
  598. package/UI/Components/Table/EmptyTableMessage.ts +81 -0
  599. package/UI/Components/Table/Table.tsx +50 -21
  600. package/UI/Components/Table/TableRow.tsx +9 -1
  601. package/UI/Components/TelemetryViewer/FacetVisibility.ts +97 -2
  602. package/UI/Components/TelemetryViewer/TelemetryViewer.tsx +13 -0
  603. package/UI/Components/TelemetryViewer/components/LockedFilterChip.tsx +214 -7
  604. package/UI/Components/TelemetryViewer/components/TelemetryFacetSidebar.tsx +21 -3
  605. package/UI/Components/TextArea/TextArea.tsx +9 -2
  606. package/UI/Components/Workflow/ModelFieldPicker.tsx +10 -12
  607. package/UI/Styles/Theme.css +8 -0
  608. package/UI/esbuild-config.js +2 -32
  609. package/Utils/AI/InvestigationReport.ts +121 -15
  610. package/Utils/AiRemediation/Resource/CephCommandPolicy.ts +1936 -0
  611. package/Utils/AiRemediation/Resource/DatabaseCommandPolicy.ts +166 -0
  612. package/Utils/AiRemediation/Resource/DatabaseDiagnosticCatalog.ts +1532 -0
  613. package/Utils/AiRemediation/Resource/DatabaseQueryRedactor.ts +1394 -0
  614. package/Utils/AiRemediation/Resource/DockerCliGrammar.ts +1839 -0
  615. package/Utils/AiRemediation/Resource/DockerEngineCommandPolicy.ts +490 -0
  616. package/Utils/AiRemediation/Resource/DockerSwarmCommandPolicy.ts +687 -0
  617. package/Utils/AiRemediation/Resource/GovcCommandPolicy.ts +2096 -0
  618. package/Utils/AiRemediation/Resource/HostCommandPolicy.ts +2982 -0
  619. package/Utils/AiRemediation/Resource/ProxmoxCommandPolicy.ts +1679 -0
  620. package/Utils/AiRemediation/Resource/ResourceCommandPolicy.ts +851 -0
  621. package/Utils/AiRemediation/Resource/ResourceCommandPolicyCore.ts +593 -0
  622. package/Utils/AiRemediation/Resource/ResourceOutputRedactor.ts +2812 -0
  623. package/Utils/LabelRuleImportExport.ts +2 -0
  624. package/Utils/Markdown/UntrustedMarkdown.ts +1513 -0
  625. package/Utils/Monitor/IncomingEmailMonitorRequestUtil.ts +41 -0
  626. package/Utils/Monitor/MonitorLogSummaryUtil.ts +212 -0
  627. package/Utils/SessionReplay/SessionReplayBudgetMetricType.ts +184 -0
  628. package/Utils/Telemetry/EntityKey.ts +48 -0
  629. package/build/dist/Models/DatabaseModels/AIConversation.js +125 -1
  630. package/build/dist/Models/DatabaseModels/AIConversation.js.map +1 -1
  631. package/build/dist/Models/DatabaseModels/AutoRemediationSuggestion.js +62 -0
  632. package/build/dist/Models/DatabaseModels/AutoRemediationSuggestion.js.map +1 -1
  633. package/build/dist/Models/DatabaseModels/CephCluster.js +231 -0
  634. package/build/dist/Models/DatabaseModels/CephCluster.js.map +1 -1
  635. package/build/dist/Models/DatabaseModels/CloudResource.js +12 -0
  636. package/build/dist/Models/DatabaseModels/CloudResource.js.map +1 -1
  637. package/build/dist/Models/DatabaseModels/DatabaseServer.js +231 -0
  638. package/build/dist/Models/DatabaseModels/DatabaseServer.js.map +1 -1
  639. package/build/dist/Models/DatabaseModels/DockerHost.js +231 -0
  640. package/build/dist/Models/DatabaseModels/DockerHost.js.map +1 -1
  641. package/build/dist/Models/DatabaseModels/DockerSwarmCluster.js +231 -0
  642. package/build/dist/Models/DatabaseModels/DockerSwarmCluster.js.map +1 -1
  643. package/build/dist/Models/DatabaseModels/GlobalConfig.js +1 -1
  644. package/build/dist/Models/DatabaseModels/GlobalConfig.js.map +1 -1
  645. package/build/dist/Models/DatabaseModels/GlobalOidc.js +0 -4
  646. package/build/dist/Models/DatabaseModels/GlobalOidc.js.map +1 -1
  647. package/build/dist/Models/DatabaseModels/GlobalOidcProject.js +0 -4
  648. package/build/dist/Models/DatabaseModels/GlobalOidcProject.js.map +1 -1
  649. package/build/dist/Models/DatabaseModels/GlobalSso.js +0 -4
  650. package/build/dist/Models/DatabaseModels/GlobalSso.js.map +1 -1
  651. package/build/dist/Models/DatabaseModels/GlobalSsoProject.js +0 -4
  652. package/build/dist/Models/DatabaseModels/GlobalSsoProject.js.map +1 -1
  653. package/build/dist/Models/DatabaseModels/Host.js +231 -0
  654. package/build/dist/Models/DatabaseModels/Host.js.map +1 -1
  655. package/build/dist/Models/DatabaseModels/IncidentForm.js +605 -0
  656. package/build/dist/Models/DatabaseModels/IncidentForm.js.map +1 -0
  657. package/build/dist/Models/DatabaseModels/IncidentFormSubmission.js +299 -0
  658. package/build/dist/Models/DatabaseModels/IncidentFormSubmission.js.map +1 -0
  659. package/build/dist/Models/DatabaseModels/IncidentTemplate.js +60 -0
  660. package/build/dist/Models/DatabaseModels/IncidentTemplate.js.map +1 -1
  661. package/build/dist/Models/DatabaseModels/Index.js +16 -0
  662. package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
  663. package/build/dist/Models/DatabaseModels/IoTFleet.js +12 -0
  664. package/build/dist/Models/DatabaseModels/IoTFleet.js.map +1 -1
  665. package/build/dist/Models/DatabaseModels/KubernetesCluster.js +12 -0
  666. package/build/dist/Models/DatabaseModels/KubernetesCluster.js.map +1 -1
  667. package/build/dist/Models/DatabaseModels/MessageQueue.js +1106 -0
  668. package/build/dist/Models/DatabaseModels/MessageQueue.js.map +1 -0
  669. package/build/dist/Models/DatabaseModels/MessageQueueLabelRule.js +562 -0
  670. package/build/dist/Models/DatabaseModels/MessageQueueLabelRule.js.map +1 -0
  671. package/build/dist/Models/DatabaseModels/MessageQueueOwnerRule.js +643 -0
  672. package/build/dist/Models/DatabaseModels/MessageQueueOwnerRule.js.map +1 -0
  673. package/build/dist/Models/DatabaseModels/MessageQueueOwnerTeam.js +506 -0
  674. package/build/dist/Models/DatabaseModels/MessageQueueOwnerTeam.js.map +1 -0
  675. package/build/dist/Models/DatabaseModels/MessageQueueOwnerUser.js +505 -0
  676. package/build/dist/Models/DatabaseModels/MessageQueueOwnerUser.js.map +1 -0
  677. package/build/dist/Models/DatabaseModels/PodmanHost.js +231 -0
  678. package/build/dist/Models/DatabaseModels/PodmanHost.js.map +1 -1
  679. package/build/dist/Models/DatabaseModels/Project.js +61 -0
  680. package/build/dist/Models/DatabaseModels/Project.js.map +1 -1
  681. package/build/dist/Models/DatabaseModels/ProjectOidc.js +0 -4
  682. package/build/dist/Models/DatabaseModels/ProjectOidc.js.map +1 -1
  683. package/build/dist/Models/DatabaseModels/ProjectSso.js +0 -4
  684. package/build/dist/Models/DatabaseModels/ProjectSso.js.map +1 -1
  685. package/build/dist/Models/DatabaseModels/ProxmoxCluster.js +231 -0
  686. package/build/dist/Models/DatabaseModels/ProxmoxCluster.js.map +1 -1
  687. package/build/dist/Models/DatabaseModels/ResourceAiAgent.js +439 -0
  688. package/build/dist/Models/DatabaseModels/ResourceAiAgent.js.map +1 -0
  689. package/build/dist/Models/DatabaseModels/RumApplication.js +12 -0
  690. package/build/dist/Models/DatabaseModels/RumApplication.js.map +1 -1
  691. package/build/dist/Models/DatabaseModels/RunnerJob.js +145 -0
  692. package/build/dist/Models/DatabaseModels/RunnerJob.js.map +1 -1
  693. package/build/dist/Models/DatabaseModels/ServerlessFunction.js +12 -0
  694. package/build/dist/Models/DatabaseModels/ServerlessFunction.js.map +1 -1
  695. package/build/dist/Models/DatabaseModels/Service.js +12 -0
  696. package/build/dist/Models/DatabaseModels/Service.js.map +1 -1
  697. package/build/dist/Models/DatabaseModels/StatusPageOidc.js +0 -4
  698. package/build/dist/Models/DatabaseModels/StatusPageOidc.js.map +1 -1
  699. package/build/dist/Models/DatabaseModels/StatusPageSso.js +0 -4
  700. package/build/dist/Models/DatabaseModels/StatusPageSso.js.map +1 -1
  701. package/build/dist/Models/DatabaseModels/TeamComplianceSetting.js +49 -3
  702. package/build/dist/Models/DatabaseModels/TeamComplianceSetting.js.map +1 -1
  703. package/build/dist/Models/DatabaseModels/VMwareVCenter.js +231 -0
  704. package/build/dist/Models/DatabaseModels/VMwareVCenter.js.map +1 -1
  705. package/build/dist/Server/API/AIChatAPI.js +9 -103
  706. package/build/dist/Server/API/AIChatAPI.js.map +1 -1
  707. package/build/dist/Server/API/AIInvestigationAPI.js +3 -3
  708. package/build/dist/Server/API/AIInvestigationAPI.js.map +1 -1
  709. package/build/dist/Server/API/AIInvestigationConversationAPI.js +162 -0
  710. package/build/dist/Server/API/AIInvestigationConversationAPI.js.map +1 -0
  711. package/build/dist/Server/API/AutoRemediationAPI.js +231 -1
  712. package/build/dist/Server/API/AutoRemediationAPI.js.map +1 -1
  713. package/build/dist/Server/API/IncidentFormAPI.js +245 -0
  714. package/build/dist/Server/API/IncidentFormAPI.js.map +1 -0
  715. package/build/dist/Server/API/ProjectOIDC.js +16 -24
  716. package/build/dist/Server/API/ProjectOIDC.js.map +1 -1
  717. package/build/dist/Server/API/ProjectSSO.js +16 -24
  718. package/build/dist/Server/API/ProjectSSO.js.map +1 -1
  719. package/build/dist/Server/API/ResourceAiAccessAPI.js +1119 -0
  720. package/build/dist/Server/API/ResourceAiAccessAPI.js.map +1 -0
  721. package/build/dist/Server/API/StatusPageAPI.js +42 -75
  722. package/build/dist/Server/API/StatusPageAPI.js.map +1 -1
  723. package/build/dist/Server/Enterprise/EnterpriseEdition.js +79 -25
  724. package/build/dist/Server/Enterprise/EnterpriseEdition.js.map +1 -1
  725. package/build/dist/Server/Enterprise/EnterpriseFeature.js +24 -3
  726. package/build/dist/Server/Enterprise/EnterpriseFeature.js.map +1 -1
  727. package/build/dist/Server/Enterprise/EnterpriseLicenseSnapshot.js +1 -1
  728. package/build/dist/Server/Enterprise/EnterpriseServerModule.js.map +1 -1
  729. package/build/dist/Server/EnvironmentConfig.js +1 -1
  730. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1796300000000-AddResourceAiAgents.js +168 -0
  731. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1796300000000-AddResourceAiAgents.js.map +1 -0
  732. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1796400000000-AddIncidentForms.js +63 -0
  733. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1796400000000-AddIncidentForms.js.map +1 -0
  734. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1796500000000-AddTeamComplianceRuleNotificationChannels.js +41 -0
  735. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1796500000000-AddTeamComplianceRuleNotificationChannels.js.map +1 -0
  736. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1796600000000-AddAIInvestigationConversationAndTimeLimits.js +40 -0
  737. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1796600000000-AddAIInvestigationConversationAndTimeLimits.js.map +1 -0
  738. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1796700000000-AddMessageQueueTables.js +183 -0
  739. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1796700000000-AddMessageQueueTables.js.map +1 -0
  740. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +10 -0
  741. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
  742. package/build/dist/Server/Infrastructure/Semaphore.js +6 -0
  743. package/build/dist/Server/Infrastructure/Semaphore.js.map +1 -1
  744. package/build/dist/Server/Middleware/IncidentFormRateLimit.js +559 -0
  745. package/build/dist/Server/Middleware/IncidentFormRateLimit.js.map +1 -0
  746. package/build/dist/Server/Middleware/TelemetryIngest.js +12 -5
  747. package/build/dist/Server/Middleware/TelemetryIngest.js.map +1 -1
  748. package/build/dist/Server/Middleware/UserAuthorization.js +11 -30
  749. package/build/dist/Server/Middleware/UserAuthorization.js.map +1 -1
  750. package/build/dist/Server/Services/AIService.js +10 -13
  751. package/build/dist/Server/Services/AIService.js.map +1 -1
  752. package/build/dist/Server/Services/AnalyticsDatabaseService.js +26 -1
  753. package/build/dist/Server/Services/AnalyticsDatabaseService.js.map +1 -1
  754. package/build/dist/Server/Services/AutoRemediationRuleEngineService.js +601 -3
  755. package/build/dist/Server/Services/AutoRemediationRuleEngineService.js.map +1 -1
  756. package/build/dist/Server/Services/CephClusterService.js +104 -0
  757. package/build/dist/Server/Services/CephClusterService.js.map +1 -1
  758. package/build/dist/Server/Services/DatabaseServerService.js +99 -0
  759. package/build/dist/Server/Services/DatabaseServerService.js.map +1 -1
  760. package/build/dist/Server/Services/DockerHostService.js +104 -0
  761. package/build/dist/Server/Services/DockerHostService.js.map +1 -1
  762. package/build/dist/Server/Services/DockerSwarmClusterService.js +104 -0
  763. package/build/dist/Server/Services/DockerSwarmClusterService.js.map +1 -1
  764. package/build/dist/Server/Services/HostService.js +114 -2
  765. package/build/dist/Server/Services/HostService.js.map +1 -1
  766. package/build/dist/Server/Services/IncidentCustomFieldService.js +83 -0
  767. package/build/dist/Server/Services/IncidentCustomFieldService.js.map +1 -1
  768. package/build/dist/Server/Services/IncidentEpisodeMemberService.js +8 -4
  769. package/build/dist/Server/Services/IncidentEpisodeMemberService.js.map +1 -1
  770. package/build/dist/Server/Services/IncidentEpisodeService.js +10 -1
  771. package/build/dist/Server/Services/IncidentEpisodeService.js.map +1 -1
  772. package/build/dist/Server/Services/IncidentFormService.js +1202 -0
  773. package/build/dist/Server/Services/IncidentFormService.js.map +1 -0
  774. package/build/dist/Server/Services/IncidentFormSubmissionService.js +91 -0
  775. package/build/dist/Server/Services/IncidentFormSubmissionService.js.map +1 -0
  776. package/build/dist/Server/Services/IncidentGroupingEngineService.js +20 -8
  777. package/build/dist/Server/Services/IncidentGroupingEngineService.js.map +1 -1
  778. package/build/dist/Server/Services/IncidentService.js +106 -4
  779. package/build/dist/Server/Services/IncidentService.js.map +1 -1
  780. package/build/dist/Server/Services/IncidentTemplateService.js +18 -0
  781. package/build/dist/Server/Services/IncidentTemplateService.js.map +1 -1
  782. package/build/dist/Server/Services/Index.js +14 -0
  783. package/build/dist/Server/Services/Index.js.map +1 -1
  784. package/build/dist/Server/Services/MessageQueueLabelRuleEngineService.js +262 -0
  785. package/build/dist/Server/Services/MessageQueueLabelRuleEngineService.js.map +1 -0
  786. package/build/dist/Server/Services/MessageQueueLabelRuleService.js +13 -0
  787. package/build/dist/Server/Services/MessageQueueLabelRuleService.js.map +1 -0
  788. package/build/dist/Server/Services/MessageQueueOwnerRuleEngineService.js +334 -0
  789. package/build/dist/Server/Services/MessageQueueOwnerRuleEngineService.js.map +1 -0
  790. package/build/dist/Server/Services/MessageQueueOwnerRuleService.js +13 -0
  791. package/build/dist/Server/Services/MessageQueueOwnerRuleService.js.map +1 -0
  792. package/build/dist/Server/Services/MessageQueueOwnerTeamService.js +62 -0
  793. package/build/dist/Server/Services/MessageQueueOwnerTeamService.js.map +1 -0
  794. package/build/dist/Server/Services/MessageQueueOwnerUserService.js +62 -0
  795. package/build/dist/Server/Services/MessageQueueOwnerUserService.js.map +1 -0
  796. package/build/dist/Server/Services/MessageQueueService.js +1140 -0
  797. package/build/dist/Server/Services/MessageQueueService.js.map +1 -0
  798. package/build/dist/Server/Services/MetricRecordingRuleService.js +46 -0
  799. package/build/dist/Server/Services/MetricRecordingRuleService.js.map +1 -1
  800. package/build/dist/Server/Services/OpenTelemetryIngestService.js +25 -4
  801. package/build/dist/Server/Services/OpenTelemetryIngestService.js.map +1 -1
  802. package/build/dist/Server/Services/PodmanHostService.js +104 -0
  803. package/build/dist/Server/Services/PodmanHostService.js.map +1 -1
  804. package/build/dist/Server/Services/ProjectService.js +0 -54
  805. package/build/dist/Server/Services/ProjectService.js.map +1 -1
  806. package/build/dist/Server/Services/ProxmoxClusterService.js +104 -0
  807. package/build/dist/Server/Services/ProxmoxClusterService.js.map +1 -1
  808. package/build/dist/Server/Services/ResourceAiAccessService.js +1028 -0
  809. package/build/dist/Server/Services/ResourceAiAccessService.js.map +1 -0
  810. package/build/dist/Server/Services/ResourceAiAgentJobService.js +173 -0
  811. package/build/dist/Server/Services/ResourceAiAgentJobService.js.map +1 -0
  812. package/build/dist/Server/Services/ResourceAiAgentService.js +1687 -0
  813. package/build/dist/Server/Services/ResourceAiAgentService.js.map +1 -0
  814. package/build/dist/Server/Services/RunnerJobService.js +344 -5
  815. package/build/dist/Server/Services/RunnerJobService.js.map +1 -1
  816. package/build/dist/Server/Services/StatusPagePrivateUserService.js +1 -4
  817. package/build/dist/Server/Services/StatusPagePrivateUserService.js.map +1 -1
  818. package/build/dist/Server/Services/StatusPageService.js +0 -46
  819. package/build/dist/Server/Services/StatusPageService.js.map +1 -1
  820. package/build/dist/Server/Services/TeamComplianceSettingService.js +120 -31
  821. package/build/dist/Server/Services/TeamComplianceSettingService.js.map +1 -1
  822. package/build/dist/Server/Services/TelemetryUsageBillingService.js +26 -0
  823. package/build/dist/Server/Services/TelemetryUsageBillingService.js.map +1 -1
  824. package/build/dist/Server/Services/TraceRecordingRuleService.js +37 -0
  825. package/build/dist/Server/Services/TraceRecordingRuleService.js.map +1 -1
  826. package/build/dist/Server/Services/UserNotificationRuleService.js +8 -1
  827. package/build/dist/Server/Services/UserNotificationRuleService.js.map +1 -1
  828. package/build/dist/Server/Services/VMwareVCenterService.js +104 -0
  829. package/build/dist/Server/Services/VMwareVCenterService.js.map +1 -1
  830. package/build/dist/Server/Services/WorkspaceNotificationSummaryService.js +12 -3
  831. package/build/dist/Server/Services/WorkspaceNotificationSummaryService.js.map +1 -1
  832. package/build/dist/Server/Types/Database/Permissions/CreatePermission.js +6 -3
  833. package/build/dist/Server/Types/Database/Permissions/CreatePermission.js.map +1 -1
  834. package/build/dist/Server/Types/Database/Permissions/EditionPermission.js +109 -37
  835. package/build/dist/Server/Types/Database/Permissions/EditionPermission.js.map +1 -1
  836. package/build/dist/Server/Types/Database/Permissions/OwnerTableRegistry.js +16 -0
  837. package/build/dist/Server/Types/Database/Permissions/OwnerTableRegistry.js.map +1 -1
  838. package/build/dist/Server/Types/Database/Permissions/TablePermission.js +3 -3
  839. package/build/dist/Server/Types/Database/Permissions/UpdatePermission.js +9 -6
  840. package/build/dist/Server/Types/Database/Permissions/UpdatePermission.js.map +1 -1
  841. package/build/dist/Server/Utils/AI/Chat/AgentContextCompactor.js +128 -0
  842. package/build/dist/Server/Utils/AI/Chat/AgentContextCompactor.js.map +1 -0
  843. package/build/dist/Server/Utils/AI/Chat/ChatAgentRunner.js +192 -50
  844. package/build/dist/Server/Utils/AI/Chat/ChatAgentRunner.js.map +1 -1
  845. package/build/dist/Server/Utils/AI/Chat/ChatRunCancellation.js +133 -0
  846. package/build/dist/Server/Utils/AI/Chat/ChatRunCancellation.js.map +1 -0
  847. package/build/dist/Server/Utils/AI/Chat/ObservabilityAssistant.js +53 -13
  848. package/build/dist/Server/Utils/AI/Chat/ObservabilityAssistant.js.map +1 -1
  849. package/build/dist/Server/Utils/AI/Chat/ObservabilityChatPrompt.js +1 -1
  850. package/build/dist/Server/Utils/AI/Chat/ToolOutputPager.js +206 -0
  851. package/build/dist/Server/Utils/AI/Chat/ToolOutputPager.js.map +1 -0
  852. package/build/dist/Server/Utils/AI/ClusterAccess/KubectlInvestigationToolkit.js +53 -26
  853. package/build/dist/Server/Utils/AI/ClusterAccess/KubectlInvestigationToolkit.js.map +1 -1
  854. package/build/dist/Server/Utils/AI/ClusterAccess/KubectlJobRunner.js +4 -2
  855. package/build/dist/Server/Utils/AI/ClusterAccess/KubectlJobRunner.js.map +1 -1
  856. package/build/dist/Server/Utils/AI/CodeFix/CodeFixReadiness.js +1 -29
  857. package/build/dist/Server/Utils/AI/CodeFix/CodeFixReadiness.js.map +1 -1
  858. package/build/dist/Server/Utils/AI/CodeFix/FixRunBudget.js +24 -24
  859. package/build/dist/Server/Utils/AI/CodeFix/FixRunBudget.js.map +1 -1
  860. package/build/dist/Server/Utils/AI/Remediation/RemediationCommandTools.js +1036 -32
  861. package/build/dist/Server/Utils/AI/Remediation/RemediationCommandTools.js.map +1 -1
  862. package/build/dist/Server/Utils/AI/Remediation/RemediationExecutionRunner.js +661 -41
  863. package/build/dist/Server/Utils/AI/Remediation/RemediationExecutionRunner.js.map +1 -1
  864. package/build/dist/Server/Utils/AI/Remediation/RemediationPlanRunner.js +21 -1
  865. package/build/dist/Server/Utils/AI/Remediation/RemediationPlanRunner.js.map +1 -1
  866. package/build/dist/Server/Utils/AI/ResourceAccess/InfrastructureInvestigationToolkit.js +354 -0
  867. package/build/dist/Server/Utils/AI/ResourceAccess/InfrastructureInvestigationToolkit.js.map +1 -0
  868. package/build/dist/Server/Utils/AI/ResourceAccess/ResourceAccessContext.js +160 -0
  869. package/build/dist/Server/Utils/AI/ResourceAccess/ResourceAccessContext.js.map +1 -0
  870. package/build/dist/Server/Utils/AI/ResourceAccess/ResourceAccessToolNames.js +33 -0
  871. package/build/dist/Server/Utils/AI/ResourceAccess/ResourceAccessToolNames.js.map +1 -0
  872. package/build/dist/Server/Utils/AI/ResourceAccess/ResourceAiAccessSettings.js +640 -0
  873. package/build/dist/Server/Utils/AI/ResourceAccess/ResourceAiAccessSettings.js.map +1 -0
  874. package/build/dist/Server/Utils/AI/ResourceAccess/ResourceAiDeleteCleanup.js +226 -0
  875. package/build/dist/Server/Utils/AI/ResourceAccess/ResourceAiDeleteCleanup.js.map +1 -0
  876. package/build/dist/Server/Utils/AI/ResourceAccess/ResourceCommandJobRunner.js +602 -0
  877. package/build/dist/Server/Utils/AI/ResourceAccess/ResourceCommandJobRunner.js.map +1 -0
  878. package/build/dist/Server/Utils/AI/SRE/AIInvestigationEngine.js +90 -14
  879. package/build/dist/Server/Utils/AI/SRE/AIInvestigationEngine.js.map +1 -1
  880. package/build/dist/Server/Utils/AI/SRE/AlertInvestigationRunner.js +73 -10
  881. package/build/dist/Server/Utils/AI/SRE/AlertInvestigationRunner.js.map +1 -1
  882. package/build/dist/Server/Utils/AI/SRE/IncidentInvestigationRunner.js +73 -10
  883. package/build/dist/Server/Utils/AI/SRE/IncidentInvestigationRunner.js.map +1 -1
  884. package/build/dist/Server/Utils/AI/SRE/InvestigationQueue.js +15 -18
  885. package/build/dist/Server/Utils/AI/SRE/InvestigationQueue.js.map +1 -1
  886. package/build/dist/Server/Utils/AI/SRE/InvestigationThread.js +412 -0
  887. package/build/dist/Server/Utils/AI/SRE/InvestigationThread.js.map +1 -0
  888. package/build/dist/Server/Utils/AI/SRE/InvestigationThreadService.js +495 -0
  889. package/build/dist/Server/Utils/AI/SRE/InvestigationThreadService.js.map +1 -0
  890. package/build/dist/Server/Utils/AI/Toolbox/Serializer.js +10 -3
  891. package/build/dist/Server/Utils/AI/Toolbox/Serializer.js.map +1 -1
  892. package/build/dist/Server/Utils/AutoRemediation/CommandPlanExecutor.js +290 -13
  893. package/build/dist/Server/Utils/AutoRemediation/CommandPlanExecutor.js.map +1 -1
  894. package/build/dist/Server/Utils/AutoRemediation/RemediationVerifier.js +29 -1
  895. package/build/dist/Server/Utils/AutoRemediation/RemediationVerifier.js.map +1 -1
  896. package/build/dist/Server/Utils/Database/ProjectScopedReferenceValidator.js +9 -1
  897. package/build/dist/Server/Utils/Database/ProjectScopedReferenceValidator.js.map +1 -1
  898. package/build/dist/Server/Utils/EditionEnforcement.js +20 -158
  899. package/build/dist/Server/Utils/EditionEnforcement.js.map +1 -1
  900. package/build/dist/Server/Utils/LLM/LLMService.js +193 -54
  901. package/build/dist/Server/Utils/LLM/LLMService.js.map +1 -1
  902. package/build/dist/Server/Utils/RelaxedScimTeamLocksReport.js +160 -0
  903. package/build/dist/Server/Utils/RelaxedScimTeamLocksReport.js.map +1 -0
  904. package/build/dist/Server/Utils/Rules/RuleRun/RuleRunRegistry.js +25 -0
  905. package/build/dist/Server/Utils/Rules/RuleRun/RuleRunRegistry.js.map +1 -1
  906. package/build/dist/Server/Utils/SameOriginRequest.js +151 -0
  907. package/build/dist/Server/Utils/SameOriginRequest.js.map +1 -0
  908. package/build/dist/Server/Utils/SessionReplay/SessionReplayBudgetMetrics.js +627 -0
  909. package/build/dist/Server/Utils/SessionReplay/SessionReplayBudgetMetrics.js.map +1 -0
  910. package/build/dist/Server/Utils/SessionReplay/SessionReplayUsage.js +60 -5
  911. package/build/dist/Server/Utils/SessionReplay/SessionReplayUsage.js.map +1 -1
  912. package/build/dist/Server/Utils/TeamMember/ProjectLeaveResourceCleanup.js +2 -0
  913. package/build/dist/Server/Utils/TeamMember/ProjectLeaveResourceCleanup.js.map +1 -1
  914. package/build/dist/Server/Utils/Telemetry/EntityRegistry.js +4 -1
  915. package/build/dist/Server/Utils/Telemetry/EntityRegistry.js.map +1 -1
  916. package/build/dist/Server/Utils/Telemetry/MessageQueueDiscovery.js +1015 -0
  917. package/build/dist/Server/Utils/Telemetry/MessageQueueDiscovery.js.map +1 -0
  918. package/build/dist/Server/Utils/Telemetry/ResourceEntityFilter.js +4 -1
  919. package/build/dist/Server/Utils/Telemetry/ResourceEntityFilter.js.map +1 -1
  920. package/build/dist/Server/Utils/VendorAssets.js +3 -3
  921. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Alert.js +19 -15
  922. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Alert.js.map +1 -1
  923. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/AlertEpisode.js +19 -15
  924. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/AlertEpisode.js.map +1 -1
  925. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Auth.js +17 -1
  926. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Auth.js.map +1 -1
  927. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Incident.js +186 -210
  928. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Incident.js.map +1 -1
  929. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/IncidentEpisode.js +22 -16
  930. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/IncidentEpisode.js.map +1 -1
  931. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/ScheduledMaintenance.js +233 -167
  932. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/ScheduledMaintenance.js.map +1 -1
  933. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js +273 -111
  934. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js.map +1 -1
  935. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsActivityDeduplicator.js +129 -0
  936. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsActivityDeduplicator.js.map +1 -0
  937. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsCardChoices.js +266 -0
  938. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsCardChoices.js.map +1 -0
  939. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsCreateCommands.js +258 -0
  940. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsCreateCommands.js.map +1 -0
  941. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsMessageSize.js +104 -0
  942. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsMessageSize.js.map +1 -0
  943. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsReplies.js +183 -0
  944. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsReplies.js.map +1 -0
  945. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsTimezone.js +123 -0
  946. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsTimezone.js.map +1 -0
  947. package/build/dist/Types/AI/AIAgentRunLimits.js +91 -0
  948. package/build/dist/Types/AI/AIAgentRunLimits.js.map +1 -0
  949. package/build/dist/Types/AI/ResourceAiAccessApi.js +30 -0
  950. package/build/dist/Types/AI/ResourceAiAccessApi.js.map +1 -0
  951. package/build/dist/Types/AI/ResourceAiAccessPermissions.js +98 -0
  952. package/build/dist/Types/AI/ResourceAiAccessPermissions.js.map +1 -0
  953. package/build/dist/Types/AutoRemediation/AiRemediationCommandPlan.js +116 -29
  954. package/build/dist/Types/AutoRemediation/AiRemediationCommandPlan.js.map +1 -1
  955. package/build/dist/Types/Code/CodeType.js +2 -0
  956. package/build/dist/Types/Code/CodeType.js.map +1 -1
  957. package/build/dist/Types/Code/JsonSyntax.js +604 -0
  958. package/build/dist/Types/Code/JsonSyntax.js.map +1 -0
  959. package/build/dist/Types/CustomField/CustomFieldCreateSettings.js +310 -0
  960. package/build/dist/Types/CustomField/CustomFieldCreateSettings.js.map +1 -0
  961. package/build/dist/Types/CustomField/CustomFieldMappingCatalog.js +38 -0
  962. package/build/dist/Types/CustomField/CustomFieldMappingCatalog.js.map +1 -1
  963. package/build/dist/Types/CustomField/CustomFieldValueValidator.js +10 -7
  964. package/build/dist/Types/CustomField/CustomFieldValueValidator.js.map +1 -1
  965. package/build/dist/Types/EnterpriseLicense/EnterpriseLicensePeriods.js +1 -1
  966. package/build/dist/Types/Icon/IconProp.js +2 -0
  967. package/build/dist/Types/Icon/IconProp.js.map +1 -1
  968. package/build/dist/Types/Incident/IncidentFormIpAllowlist.js +119 -0
  969. package/build/dist/Types/Incident/IncidentFormIpAllowlist.js.map +1 -0
  970. package/build/dist/Types/Incident/IncidentFormPublic.js +678 -0
  971. package/build/dist/Types/Incident/IncidentFormPublic.js.map +1 -0
  972. package/build/dist/Types/Kubernetes/KubernetesClusterAiAccess.js +10 -3
  973. package/build/dist/Types/Kubernetes/KubernetesClusterAiAccess.js.map +1 -1
  974. package/build/dist/Types/MessageQueue/MessageQueueIdentity.js +184 -0
  975. package/build/dist/Types/MessageQueue/MessageQueueIdentity.js.map +1 -0
  976. package/build/dist/Types/MessageQueue/MessageQueueManualIdentity.js +190 -0
  977. package/build/dist/Types/MessageQueue/MessageQueueManualIdentity.js.map +1 -0
  978. package/build/dist/Types/MessageQueue/MessageQueueMetricCatalog.js +1057 -0
  979. package/build/dist/Types/MessageQueue/MessageQueueMetricCatalog.js.map +1 -0
  980. package/build/dist/Types/MessageQueue/MessagingSystem.js +394 -0
  981. package/build/dist/Types/MessageQueue/MessagingSystem.js.map +1 -0
  982. package/build/dist/Types/MessageQueue/MessagingTelemetryResolver.js +1768 -0
  983. package/build/dist/Types/MessageQueue/MessagingTelemetryResolver.js.map +1 -0
  984. package/build/dist/Types/Monitor/MessageQueueAlertTemplates.js +1207 -0
  985. package/build/dist/Types/Monitor/MessageQueueAlertTemplates.js.map +1 -0
  986. package/build/dist/Types/Monitor/Recommendation/MonitorRecommendationCatalog.js +47 -21
  987. package/build/dist/Types/Monitor/Recommendation/MonitorRecommendationCatalog.js.map +1 -1
  988. package/build/dist/Types/Monitor/Recommendation/MonitorRecommendationTypes.js +5 -0
  989. package/build/dist/Types/Monitor/Recommendation/MonitorRecommendationTypes.js.map +1 -1
  990. package/build/dist/Types/Monitor/RumAlertTemplates.js +199 -3
  991. package/build/dist/Types/Monitor/RumAlertTemplates.js.map +1 -1
  992. package/build/dist/Types/Permission.js +274 -0
  993. package/build/dist/Types/Permission.js.map +1 -1
  994. package/build/dist/Types/ResourceAiAgent/AiResourceType.js +242 -0
  995. package/build/dist/Types/ResourceAiAgent/AiResourceType.js.map +1 -0
  996. package/build/dist/Types/ResourceAiAgent/ResourceAiAccess.js +281 -0
  997. package/build/dist/Types/ResourceAiAgent/ResourceAiAccess.js.map +1 -0
  998. package/build/dist/Types/Rules/RuleCriteriaFieldRegistry.js +12 -0
  999. package/build/dist/Types/Rules/RuleCriteriaFieldRegistry.js.map +1 -1
  1000. package/build/dist/Types/Rules/RuleRun.js +4 -0
  1001. package/build/dist/Types/Rules/RuleRun.js.map +1 -1
  1002. package/build/dist/Types/Rum/SessionReplayBudgetMetricType.js +45 -0
  1003. package/build/dist/Types/Rum/SessionReplayBudgetMetricType.js.map +1 -0
  1004. package/build/dist/Types/Runbook/RunbookStepType.js +27 -0
  1005. package/build/dist/Types/Runbook/RunbookStepType.js.map +1 -1
  1006. package/build/dist/Types/Team/ComplianceNotificationChannel.js +4 -3
  1007. package/build/dist/Types/Team/ComplianceNotificationChannel.js.map +1 -1
  1008. package/build/dist/Types/Team/ComplianceRule.js +48 -14
  1009. package/build/dist/Types/Team/ComplianceRule.js.map +1 -1
  1010. package/build/dist/Types/Team/ComplianceRuleType.js +2 -2
  1011. package/build/dist/Types/Telemetry/EntityType.js +16 -0
  1012. package/build/dist/Types/Telemetry/EntityType.js.map +1 -1
  1013. package/build/dist/Types/Telemetry/TelemetryIngestSurface.js +13 -2
  1014. package/build/dist/Types/Telemetry/TelemetryIngestSurface.js.map +1 -1
  1015. package/build/dist/Types/XML.js +23 -0
  1016. package/build/dist/Types/XML.js.map +1 -1
  1017. package/build/dist/UI/Components/CodeEditor/CodeEditor.js +641 -266
  1018. package/build/dist/UI/Components/CodeEditor/CodeEditor.js.map +1 -1
  1019. package/build/dist/UI/Components/CodeEditor/CodeEditorCommands.js +464 -0
  1020. package/build/dist/UI/Components/CodeEditor/CodeEditorCommands.js.map +1 -0
  1021. package/build/dist/UI/Components/CodeEditor/CodeEditorHighlight.js +69 -0
  1022. package/build/dist/UI/Components/CodeEditor/CodeEditorHighlight.js.map +1 -0
  1023. package/build/dist/UI/Components/CodeEditor/CodeEditorLanguages.js +108 -0
  1024. package/build/dist/UI/Components/CodeEditor/CodeEditorLanguages.js.map +1 -0
  1025. package/build/dist/UI/Components/CodeEditor/YamlEditor.js +14 -186
  1026. package/build/dist/UI/Components/CodeEditor/YamlEditor.js.map +1 -1
  1027. package/build/dist/UI/Components/CopyTextButton/CopyTextButton.js +5 -1
  1028. package/build/dist/UI/Components/CopyTextButton/CopyTextButton.js.map +1 -1
  1029. package/build/dist/UI/Components/CustomFields/CustomFieldModelFormFields.js +5 -14
  1030. package/build/dist/UI/Components/CustomFields/CustomFieldModelFormFields.js.map +1 -1
  1031. package/build/dist/UI/Components/EditionLabel/EditionLabel.js +14 -13
  1032. package/build/dist/UI/Components/EditionLabel/EditionLabel.js.map +1 -1
  1033. package/build/dist/UI/Components/ErrorMessage/ErrorMessage.js +1 -1
  1034. package/build/dist/UI/Components/ErrorMessage/ErrorMessage.js.map +1 -1
  1035. package/build/dist/UI/Components/Forms/Fields/FormField.js +8 -3
  1036. package/build/dist/UI/Components/Forms/Fields/FormField.js.map +1 -1
  1037. package/build/dist/UI/Components/Icon/Icon.js +8 -0
  1038. package/build/dist/UI/Components/Icon/Icon.js.map +1 -1
  1039. package/build/dist/UI/Components/Input/Input.js +11 -3
  1040. package/build/dist/UI/Components/Input/Input.js.map +1 -1
  1041. package/build/dist/UI/Components/LogsViewer/LogsViewer.js +2 -1
  1042. package/build/dist/UI/Components/LogsViewer/LogsViewer.js.map +1 -1
  1043. package/build/dist/UI/Components/LogsViewer/components/LogsFacetSidebar.js +14 -4
  1044. package/build/dist/UI/Components/LogsViewer/components/LogsFacetSidebar.js.map +1 -1
  1045. package/build/dist/UI/Components/Markdown.tsx/MarkdownConverters.js +0 -0
  1046. package/build/dist/UI/Components/Markdown.tsx/MarkdownConverters.js.map +1 -1
  1047. package/build/dist/UI/Components/Markdown.tsx/MarkdownEditor.js +710 -65
  1048. package/build/dist/UI/Components/Markdown.tsx/MarkdownEditor.js.map +1 -1
  1049. package/build/dist/UI/Components/Markdown.tsx/MarkdownEditorHistory.js +238 -0
  1050. package/build/dist/UI/Components/Markdown.tsx/MarkdownEditorHistory.js.map +1 -0
  1051. package/build/dist/UI/Components/Markdown.tsx/MarkdownListEditing.js +1028 -0
  1052. package/build/dist/UI/Components/Markdown.tsx/MarkdownListEditing.js.map +1 -0
  1053. package/build/dist/UI/Components/Markdown.tsx/MarkdownPaste.js +1088 -0
  1054. package/build/dist/UI/Components/Markdown.tsx/MarkdownPaste.js.map +1 -0
  1055. package/build/dist/UI/Components/Markdown.tsx/MarkdownViewer.js +70 -10
  1056. package/build/dist/UI/Components/Markdown.tsx/MarkdownViewer.js.map +1 -1
  1057. package/build/dist/UI/Components/Markdown.tsx/MarkdownVisualEditing.js +887 -0
  1058. package/build/dist/UI/Components/Markdown.tsx/MarkdownVisualEditing.js.map +1 -0
  1059. package/build/dist/UI/Components/ModelTable/BaseModelTable.js +57 -6
  1060. package/build/dist/UI/Components/ModelTable/BaseModelTable.js.map +1 -1
  1061. package/build/dist/UI/Components/ResetObjectID/ResetObjectID.js +7 -5
  1062. package/build/dist/UI/Components/ResetObjectID/ResetObjectID.js.map +1 -1
  1063. package/build/dist/UI/Components/Table/EmptyTableMessage.js +51 -0
  1064. package/build/dist/UI/Components/Table/EmptyTableMessage.js.map +1 -0
  1065. package/build/dist/UI/Components/Table/Table.js +30 -11
  1066. package/build/dist/UI/Components/Table/Table.js.map +1 -1
  1067. package/build/dist/UI/Components/Table/TableRow.js +9 -2
  1068. package/build/dist/UI/Components/Table/TableRow.js.map +1 -1
  1069. package/build/dist/UI/Components/TelemetryViewer/FacetVisibility.js +63 -1
  1070. package/build/dist/UI/Components/TelemetryViewer/FacetVisibility.js.map +1 -1
  1071. package/build/dist/UI/Components/TelemetryViewer/TelemetryViewer.js +4 -2
  1072. package/build/dist/UI/Components/TelemetryViewer/TelemetryViewer.js.map +1 -1
  1073. package/build/dist/UI/Components/TelemetryViewer/components/LockedFilterChip.js +91 -10
  1074. package/build/dist/UI/Components/TelemetryViewer/components/LockedFilterChip.js.map +1 -1
  1075. package/build/dist/UI/Components/TelemetryViewer/components/TelemetryFacetSidebar.js +14 -4
  1076. package/build/dist/UI/Components/TelemetryViewer/components/TelemetryFacetSidebar.js.map +1 -1
  1077. package/build/dist/UI/Components/TextArea/TextArea.js +9 -3
  1078. package/build/dist/UI/Components/TextArea/TextArea.js.map +1 -1
  1079. package/build/dist/UI/Components/Workflow/ModelFieldPicker.js +1 -2
  1080. package/build/dist/UI/Components/Workflow/ModelFieldPicker.js.map +1 -1
  1081. package/build/dist/Utils/AI/InvestigationReport.js +71 -11
  1082. package/build/dist/Utils/AI/InvestigationReport.js.map +1 -1
  1083. package/build/dist/Utils/AiRemediation/Resource/CephCommandPolicy.js +1462 -0
  1084. package/build/dist/Utils/AiRemediation/Resource/CephCommandPolicy.js.map +1 -0
  1085. package/build/dist/Utils/AiRemediation/Resource/DatabaseCommandPolicy.js +122 -0
  1086. package/build/dist/Utils/AiRemediation/Resource/DatabaseCommandPolicy.js.map +1 -0
  1087. package/build/dist/Utils/AiRemediation/Resource/DatabaseDiagnosticCatalog.js +1139 -0
  1088. package/build/dist/Utils/AiRemediation/Resource/DatabaseDiagnosticCatalog.js.map +1 -0
  1089. package/build/dist/Utils/AiRemediation/Resource/DatabaseQueryRedactor.js +1060 -0
  1090. package/build/dist/Utils/AiRemediation/Resource/DatabaseQueryRedactor.js.map +1 -0
  1091. package/build/dist/Utils/AiRemediation/Resource/DockerCliGrammar.js +1301 -0
  1092. package/build/dist/Utils/AiRemediation/Resource/DockerCliGrammar.js.map +1 -0
  1093. package/build/dist/Utils/AiRemediation/Resource/DockerEngineCommandPolicy.js +370 -0
  1094. package/build/dist/Utils/AiRemediation/Resource/DockerEngineCommandPolicy.js.map +1 -0
  1095. package/build/dist/Utils/AiRemediation/Resource/DockerSwarmCommandPolicy.js +498 -0
  1096. package/build/dist/Utils/AiRemediation/Resource/DockerSwarmCommandPolicy.js.map +1 -0
  1097. package/build/dist/Utils/AiRemediation/Resource/GovcCommandPolicy.js +1565 -0
  1098. package/build/dist/Utils/AiRemediation/Resource/GovcCommandPolicy.js.map +1 -0
  1099. package/build/dist/Utils/AiRemediation/Resource/HostCommandPolicy.js +2206 -0
  1100. package/build/dist/Utils/AiRemediation/Resource/HostCommandPolicy.js.map +1 -0
  1101. package/build/dist/Utils/AiRemediation/Resource/ProxmoxCommandPolicy.js +1129 -0
  1102. package/build/dist/Utils/AiRemediation/Resource/ProxmoxCommandPolicy.js.map +1 -0
  1103. package/build/dist/Utils/AiRemediation/Resource/ResourceCommandPolicy.js +565 -0
  1104. package/build/dist/Utils/AiRemediation/Resource/ResourceCommandPolicy.js.map +1 -0
  1105. package/build/dist/Utils/AiRemediation/Resource/ResourceCommandPolicyCore.js +408 -0
  1106. package/build/dist/Utils/AiRemediation/Resource/ResourceCommandPolicyCore.js.map +1 -0
  1107. package/build/dist/Utils/AiRemediation/Resource/ResourceOutputRedactor.js +1910 -0
  1108. package/build/dist/Utils/AiRemediation/Resource/ResourceOutputRedactor.js.map +1 -0
  1109. package/build/dist/Utils/LabelRuleImportExport.js +2 -0
  1110. package/build/dist/Utils/LabelRuleImportExport.js.map +1 -1
  1111. package/build/dist/Utils/Markdown/UntrustedMarkdown.js +988 -0
  1112. package/build/dist/Utils/Markdown/UntrustedMarkdown.js.map +1 -0
  1113. package/build/dist/Utils/Monitor/IncomingEmailMonitorRequestUtil.js +34 -0
  1114. package/build/dist/Utils/Monitor/IncomingEmailMonitorRequestUtil.js.map +1 -0
  1115. package/build/dist/Utils/Monitor/MonitorLogSummaryUtil.js +148 -0
  1116. package/build/dist/Utils/Monitor/MonitorLogSummaryUtil.js.map +1 -0
  1117. package/build/dist/Utils/SessionReplay/SessionReplayBudgetMetricType.js +160 -0
  1118. package/build/dist/Utils/SessionReplay/SessionReplayBudgetMetricType.js.map +1 -0
  1119. package/build/dist/Utils/Telemetry/EntityKey.js +36 -0
  1120. package/build/dist/Utils/Telemetry/EntityKey.js.map +1 -1
  1121. package/package.json +1 -3
  1122. package/Server/Utils/CommunityEditionSsoReport.ts +0 -361
  1123. package/Tests/App/Accounts/LoginSsoEdition.test.tsx +0 -616
  1124. package/Tests/App/AdminDashboard/AdminAuthenticationSsoEdition.test.tsx +0 -217
  1125. package/Tests/App/AdminDashboard/GlobalSSOEnterpriseShells.test.tsx +0 -271
  1126. package/Tests/App/Dashboard/CloudDocumentationMarkdown.test.ts +0 -215
  1127. package/Tests/App/Dashboard/TelemetryResourceRetentionSettings.test.tsx +0 -784
  1128. package/Tests/Server/Middleware/UserAuthorizationEditionEnforcement.test.ts +0 -518
  1129. package/Tests/Server/Services/SsoRequirementReadMasking.test.ts +0 -419
  1130. package/Tests/Server/Services/SsoRequirementWriteGuard.test.ts +0 -769
  1131. package/Tests/UI/Components/CodeEditor.test.tsx +0 -638
  1132. package/Tests/UI/Components/MonacoLoader.test.ts +0 -67
  1133. package/Tests/UI/Components/MonacoRuntime.test.ts +0 -121
  1134. package/Tests/UI/Components/Telemetry/TelemetryRetentionConfigForm.test.tsx +0 -329
  1135. package/Tests/UI/Components/YamlEditor.test.tsx +0 -847
  1136. package/UI/Components/CodeEditor/MonacoLoader.ts +0 -36
  1137. package/UI/Components/Telemetry/TelemetryRetentionConfigForm.tsx +0 -319
  1138. package/UI/Components/Telemetry/TelemetryRetentionConfigSummary.tsx +0 -223
  1139. package/build/dist/Server/Utils/CommunityEditionSsoReport.js +0 -223
  1140. package/build/dist/Server/Utils/CommunityEditionSsoReport.js.map +0 -1
  1141. package/build/dist/UI/Components/CodeEditor/MonacoLoader.js +0 -34
  1142. package/build/dist/UI/Components/CodeEditor/MonacoLoader.js.map +0 -1
  1143. package/build/dist/UI/Components/Telemetry/TelemetryRetentionConfigForm.js +0 -171
  1144. package/build/dist/UI/Components/Telemetry/TelemetryRetentionConfigForm.js.map +0 -1
  1145. package/build/dist/UI/Components/Telemetry/TelemetryRetentionConfigSummary.js +0 -119
  1146. package/build/dist/UI/Components/Telemetry/TelemetryRetentionConfigSummary.js.map +0 -1
@@ -0,0 +1,1687 @@
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 CephClusterFeedService from "./CephClusterFeedService";
11
+ import CephClusterService from "./CephClusterService";
12
+ import DatabaseServerFeedService from "./DatabaseServerFeedService";
13
+ import DatabaseServerService from "./DatabaseServerService";
14
+ import DatabaseService from "./DatabaseService";
15
+ import DockerHostFeedService from "./DockerHostFeedService";
16
+ import DockerHostService from "./DockerHostService";
17
+ import DockerSwarmClusterFeedService from "./DockerSwarmClusterFeedService";
18
+ import DockerSwarmClusterService from "./DockerSwarmClusterService";
19
+ import HostFeedService from "./HostFeedService";
20
+ import HostService from "./HostService";
21
+ import PodmanHostFeedService from "./PodmanHostFeedService";
22
+ import PodmanHostService from "./PodmanHostService";
23
+ import ProxmoxClusterFeedService from "./ProxmoxClusterFeedService";
24
+ import ProxmoxClusterService from "./ProxmoxClusterService";
25
+ import UserService from "./UserService";
26
+ import VMwareVCenterFeedService from "./VMwareVCenterFeedService";
27
+ import VMwareVCenterService from "./VMwareVCenterService";
28
+ import { CephClusterFeedEventType } from "../../Models/DatabaseModels/CephClusterFeed";
29
+ import { DatabaseServerFeedEventType } from "../../Models/DatabaseModels/DatabaseServerFeed";
30
+ import { DockerHostFeedEventType } from "../../Models/DatabaseModels/DockerHostFeed";
31
+ import { DockerSwarmClusterFeedEventType } from "../../Models/DatabaseModels/DockerSwarmClusterFeed";
32
+ import { HostFeedEventType } from "../../Models/DatabaseModels/HostFeed";
33
+ import { PodmanHostFeedEventType } from "../../Models/DatabaseModels/PodmanHostFeed";
34
+ import { ProxmoxClusterFeedEventType } from "../../Models/DatabaseModels/ProxmoxClusterFeed";
35
+ import Model from "../../Models/DatabaseModels/ResourceAiAgent";
36
+ import { VMwareVCenterFeedEventType } from "../../Models/DatabaseModels/VMwareVCenterFeed";
37
+ import QueryHelper from "../Types/Database/QueryHelper";
38
+ import logger from "../Utils/Logger";
39
+ import CaptureSpan from "../Utils/Telemetry/CaptureSpan";
40
+ import { Blue500, Green500 } from "../../Types/BrandColors";
41
+ import ColumnLength from "../../Types/Database/ColumnLength";
42
+ import LIMIT_MAX from "../../Types/Database/LimitMax";
43
+ import { formatDatabaseEndpoint, } from "../../Types/DatabaseServer/DatabaseEndpoint";
44
+ import DatabaseServerDiscoverySource from "../../Types/DatabaseServer/DatabaseServerDiscoverySource";
45
+ import { DATABASE_AGENT_ATTRIBUTE, resolveDatabaseFromResourceAttributes, } from "../../Types/DatabaseServer/DatabaseTelemetryResolver";
46
+ import OneUptimeDate from "../../Types/Date";
47
+ import BadDataException from "../../Types/Exception/BadDataException";
48
+ import ForbiddenException from "../../Types/Exception/ForbiddenException";
49
+ import NotAuthenticatedException from "../../Types/Exception/NotAuthenticatedException";
50
+ import ObjectID from "../../Types/ObjectID";
51
+ import AiResourceType, { AI_RESOURCE_TYPE_INFO, ALL_AI_RESOURCE_TYPES, isAiResourceType, parseAiResourceType, } from "../../Types/ResourceAiAgent/AiResourceType";
52
+ import { MAX_POSTURE_STRING_LENGTH, RESOURCE_AI_AGENT_ALIVE_WINDOW_IN_MINUTES, RESOURCE_AI_AGENT_RESOURCE_NAME_ENV, RESOURCE_AI_AGENT_RESOURCE_TYPE_ENV, RESOURCE_AI_ALLOW_WRITES_ENV, ResourceAiRemediationMode, parseResourceAiAgentPosture, parseResourceAiRemediationMode, } from "../../Types/ResourceAiAgent/ResourceAiAccess";
53
+ import crypto from "crypto";
54
+ /*
55
+ * Every column of a ResourceAiAgent row a reader may need — everything
56
+ * except keyHash. The key hash is read only by the agent authentication
57
+ * path (and registration), which select it explicitly; nothing that builds
58
+ * a status, a list or a response ever loads it, so it cannot leak into one
59
+ * by accident.
60
+ */
61
+ export const RESOURCE_AI_AGENT_SELECT_WITHOUT_KEY = {
62
+ _id: true,
63
+ createdAt: true,
64
+ updatedAt: true,
65
+ projectId: true,
66
+ resourceType: true,
67
+ resourceId: true,
68
+ resourceIdentifier: true,
69
+ agentVersion: true,
70
+ posture: true,
71
+ lastAliveAt: true,
72
+ connectionStatus: true,
73
+ lastRegisteredAt: true,
74
+ registeredWithIngestionKeyId: true,
75
+ lastRefusedRegistrationAt: true,
76
+ lastRefusedRegistrationReason: true,
77
+ };
78
+ // 32 random bytes, hex: 64 characters, 256 bits.
79
+ const AGENT_KEY_BYTES = 32;
80
+ // What a stored key hash looks like: sha256, hex.
81
+ const SHA256_HEX_PATTERN = /^[0-9a-f]{64}$/i;
82
+ const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
83
+ function toDate(value) {
84
+ if (!value) {
85
+ return null;
86
+ }
87
+ const date = value instanceof Date ? value : new Date(value);
88
+ return Number.isNaN(date.getTime()) ? null : date;
89
+ }
90
+ function toIsoString(value) {
91
+ const date = toDate(value);
92
+ return date ? OneUptimeDate.toString(date) : null;
93
+ }
94
+ /*
95
+ * Ceiling on agent rows one project may hold, and on how many new ones may
96
+ * be created per hour. Registration is authenticated by the project's
97
+ * telemetry ingestion key — a credential every collector and CI job holds —
98
+ * and every distinct resource identity creates a row that is handed
99
+ * commands, so the rows are bounded like anything else an ingestion key can
100
+ * create. The same numbers as the Kubernetes AI agent's: a fleet-wide
101
+ * install that trips the hourly one is only delayed, the agent keeps
102
+ * retrying.
103
+ */
104
+ export const MAX_RESOURCE_AI_AGENTS_PER_PROJECT = 250;
105
+ export const MAX_NEW_RESOURCE_AI_AGENTS_PER_PROJECT_PER_HOUR = 30;
106
+ /*
107
+ * An agent row not heard from in this long is removed when the project's
108
+ * cap would otherwise refuse a new agent. Unlike a Kubernetes cluster, a
109
+ * Docker, Podman or Linux host runs one agent per machine, and machines
110
+ * come and go (an autoscaled fleet names every instance anew) while their
111
+ * resources, and so their agent rows, stay: without this, 250 machines
112
+ * that ever registered would lock every later one out for good. The rows
113
+ * still never pass the cap, and a row holds only the agent's connection
114
+ * (the resource keeps its AI settings); an agent that comes back simply
115
+ * registers again.
116
+ */
117
+ export const RESOURCE_AI_AGENT_RECLAIM_AFTER_DAYS = 7;
118
+ /*
119
+ * When a transient refusal (previous_instance_online) tells the agent to
120
+ * try again. It clears within seconds when a container is replaced, and an
121
+ * agent that is refused for longer just keeps asking at this pace.
122
+ */
123
+ export const RESOURCE_AI_AGENT_REGISTRATION_RETRY_AFTER_SECONDS = 20;
124
+ /*
125
+ * The longest identity registration accepts for a resource found by its
126
+ * name or host identifier: those columns are ShortText, so a longer
127
+ * identity could never become a resource row.
128
+ */
129
+ export const MAX_RESOURCE_AI_AGENT_IDENTIFIER_LENGTH = ColumnLength.ShortText;
130
+ /*
131
+ * A database registers by its endpoint ("<system>|<host>[:<port>]", a host
132
+ * name may be 253 characters) or its id, never by a ShortText name, so its
133
+ * limit is the posture's: the identity is stored in the posture too.
134
+ */
135
+ export const MAX_DATABASE_AI_AGENT_IDENTIFIER_LENGTH = MAX_POSTURE_STRING_LENGTH;
136
+ /*
137
+ * How often, per agent and per server process, a heartbeat checks that the
138
+ * agent's resource still exists. The resource has no foreign key to the
139
+ * agent row (ResourceAiAgent.resourceId is polymorphic), so a deleted
140
+ * resource leaves its agent heartbeating a row nothing can reach — and a
141
+ * collector that re-creates the resource under a new id would show "no
142
+ * agent connected" forever. A gone resource retires the agent row, and the
143
+ * agent's next registration attaches it to whatever row its identity
144
+ * resolves to now.
145
+ */
146
+ export const RESOURCE_AI_AGENT_RESOURCE_CHECK_INTERVAL_MS = 5 * 60 * 1000;
147
+ const MAX_RESOURCE_CHECKS_REMEMBERED = 10000;
148
+ /*
149
+ * A 403 from POST /resource-ai-agent-ingest/register that says WHICH
150
+ * refusal it is, so the agent can tell a wait that clears on its own (the
151
+ * transient reason, which also carries retryAfterSeconds) from one that
152
+ * needs an operator. The ingress sends { message, reason,
153
+ * retryAfterSeconds? } and a Retry-After header for the transient one.
154
+ */
155
+ export class ResourceAiAgentRegistrationRefusedException extends ForbiddenException {
156
+ constructor(data) {
157
+ super(data.message);
158
+ this.reason = data.reason;
159
+ this.retryAfterSeconds = data.retryAfterSeconds;
160
+ }
161
+ }
162
+ // What registration, the heartbeat and the defaults read off a resource row.
163
+ export const RESOURCE_AI_AGENT_RESOURCE_SELECT = {
164
+ _id: true,
165
+ projectId: true,
166
+ name: true,
167
+ isAiInvestigationEnabled: true,
168
+ aiRemediationMode: true,
169
+ aiAccessConfiguredAt: true,
170
+ };
171
+ function asService(service) {
172
+ return service;
173
+ }
174
+ /*
175
+ * The binding of one resource type (see ResourceAiAgentResourceBinding).
176
+ * Total over AiResourceType: adding a type without a binding fails to
177
+ * compile.
178
+ */
179
+ export function getResourceAiAgentResourceBinding(resourceType) {
180
+ switch (resourceType) {
181
+ case AiResourceType.DockerHost:
182
+ return {
183
+ resourceType,
184
+ getService: () => {
185
+ return asService(DockerHostService);
186
+ },
187
+ findOrCreateByIdentity: async (data) => {
188
+ return await DockerHostService.findOrCreateByHostIdentifier({
189
+ projectId: data.projectId,
190
+ hostIdentifier: data.identifier,
191
+ });
192
+ },
193
+ writeFeedItem: async (item) => {
194
+ await DockerHostFeedService.createDockerHostFeedItem({
195
+ dockerHostId: item.resourceId,
196
+ projectId: item.projectId,
197
+ dockerHostFeedEventType: DockerHostFeedEventType.DockerHostUpdated,
198
+ feedInfoInMarkdown: item.feedInfoInMarkdown,
199
+ moreInformationInMarkdown: item.moreInformationInMarkdown,
200
+ displayColor: item.displayColor,
201
+ userId: item.userId,
202
+ });
203
+ },
204
+ };
205
+ case AiResourceType.PodmanHost:
206
+ return {
207
+ resourceType,
208
+ getService: () => {
209
+ return asService(PodmanHostService);
210
+ },
211
+ findOrCreateByIdentity: async (data) => {
212
+ return await PodmanHostService.findOrCreateByHostIdentifier({
213
+ projectId: data.projectId,
214
+ hostIdentifier: data.identifier,
215
+ });
216
+ },
217
+ writeFeedItem: async (item) => {
218
+ await PodmanHostFeedService.createPodmanHostFeedItem({
219
+ podmanHostId: item.resourceId,
220
+ projectId: item.projectId,
221
+ podmanHostFeedEventType: PodmanHostFeedEventType.PodmanHostUpdated,
222
+ feedInfoInMarkdown: item.feedInfoInMarkdown,
223
+ moreInformationInMarkdown: item.moreInformationInMarkdown,
224
+ displayColor: item.displayColor,
225
+ userId: item.userId,
226
+ });
227
+ },
228
+ };
229
+ case AiResourceType.DockerSwarmCluster:
230
+ return {
231
+ resourceType,
232
+ getService: () => {
233
+ return asService(DockerSwarmClusterService);
234
+ },
235
+ findOrCreateByIdentity: async (data) => {
236
+ return await DockerSwarmClusterService.findOrCreateByName({
237
+ projectId: data.projectId,
238
+ name: data.identifier,
239
+ });
240
+ },
241
+ writeFeedItem: async (item) => {
242
+ await DockerSwarmClusterFeedService.createDockerSwarmClusterFeedItem({
243
+ dockerSwarmClusterId: item.resourceId,
244
+ projectId: item.projectId,
245
+ dockerSwarmClusterFeedEventType: DockerSwarmClusterFeedEventType.DockerSwarmClusterUpdated,
246
+ feedInfoInMarkdown: item.feedInfoInMarkdown,
247
+ moreInformationInMarkdown: item.moreInformationInMarkdown,
248
+ displayColor: item.displayColor,
249
+ userId: item.userId,
250
+ });
251
+ },
252
+ };
253
+ case AiResourceType.ProxmoxCluster:
254
+ return {
255
+ resourceType,
256
+ getService: () => {
257
+ return asService(ProxmoxClusterService);
258
+ },
259
+ findOrCreateByIdentity: async (data) => {
260
+ return await ProxmoxClusterService.findOrCreateByName({
261
+ projectId: data.projectId,
262
+ name: data.identifier,
263
+ });
264
+ },
265
+ writeFeedItem: async (item) => {
266
+ await ProxmoxClusterFeedService.createProxmoxClusterFeedItem({
267
+ proxmoxClusterId: item.resourceId,
268
+ projectId: item.projectId,
269
+ proxmoxClusterFeedEventType: ProxmoxClusterFeedEventType.ProxmoxClusterUpdated,
270
+ feedInfoInMarkdown: item.feedInfoInMarkdown,
271
+ moreInformationInMarkdown: item.moreInformationInMarkdown,
272
+ displayColor: item.displayColor,
273
+ userId: item.userId,
274
+ });
275
+ },
276
+ };
277
+ case AiResourceType.VMwareVCenter:
278
+ return {
279
+ resourceType,
280
+ getService: () => {
281
+ return asService(VMwareVCenterService);
282
+ },
283
+ findOrCreateByIdentity: async (data) => {
284
+ return await VMwareVCenterService.findOrCreateByName({
285
+ projectId: data.projectId,
286
+ name: data.identifier,
287
+ });
288
+ },
289
+ writeFeedItem: async (item) => {
290
+ await VMwareVCenterFeedService.createVMwareVCenterFeedItem({
291
+ vmwareVCenterId: item.resourceId,
292
+ projectId: item.projectId,
293
+ vmwareVCenterFeedEventType: VMwareVCenterFeedEventType.VMwareVCenterUpdated,
294
+ feedInfoInMarkdown: item.feedInfoInMarkdown,
295
+ moreInformationInMarkdown: item.moreInformationInMarkdown,
296
+ displayColor: item.displayColor,
297
+ userId: item.userId,
298
+ });
299
+ },
300
+ };
301
+ case AiResourceType.CephCluster:
302
+ return {
303
+ resourceType,
304
+ getService: () => {
305
+ return asService(CephClusterService);
306
+ },
307
+ findOrCreateByIdentity: async (data) => {
308
+ return await CephClusterService.findOrCreateByName({
309
+ projectId: data.projectId,
310
+ name: data.identifier,
311
+ });
312
+ },
313
+ writeFeedItem: async (item) => {
314
+ await CephClusterFeedService.createCephClusterFeedItem({
315
+ cephClusterId: item.resourceId,
316
+ projectId: item.projectId,
317
+ cephClusterFeedEventType: CephClusterFeedEventType.CephClusterUpdated,
318
+ feedInfoInMarkdown: item.feedInfoInMarkdown,
319
+ moreInformationInMarkdown: item.moreInformationInMarkdown,
320
+ displayColor: item.displayColor,
321
+ userId: item.userId,
322
+ });
323
+ },
324
+ };
325
+ case AiResourceType.DatabaseServer:
326
+ return {
327
+ resourceType,
328
+ getService: () => {
329
+ return asService(DatabaseServerService);
330
+ },
331
+ findOrCreateByIdentity: null,
332
+ writeFeedItem: async (item) => {
333
+ await DatabaseServerFeedService.createDatabaseServerFeedItem({
334
+ databaseServerId: item.resourceId,
335
+ projectId: item.projectId,
336
+ databaseServerFeedEventType: DatabaseServerFeedEventType.DatabaseServerUpdated,
337
+ feedInfoInMarkdown: item.feedInfoInMarkdown,
338
+ moreInformationInMarkdown: item.moreInformationInMarkdown,
339
+ displayColor: item.displayColor,
340
+ userId: item.userId,
341
+ });
342
+ },
343
+ };
344
+ case AiResourceType.Host:
345
+ return {
346
+ resourceType,
347
+ getService: () => {
348
+ return asService(HostService);
349
+ },
350
+ findOrCreateByIdentity: async (data) => {
351
+ return await HostService.findOrCreateByHostIdentifier(Object.assign({ projectId: data.projectId, hostIdentifier: data.identifier }, (data.fresh ? { bypassMemo: true } : {})));
352
+ },
353
+ writeFeedItem: async (item) => {
354
+ await HostFeedService.createHostFeedItem({
355
+ hostId: item.resourceId,
356
+ projectId: item.projectId,
357
+ hostFeedEventType: HostFeedEventType.HostUpdated,
358
+ feedInfoInMarkdown: item.feedInfoInMarkdown,
359
+ moreInformationInMarkdown: item.moreInformationInMarkdown,
360
+ displayColor: item.displayColor,
361
+ userId: item.userId,
362
+ });
363
+ },
364
+ };
365
+ }
366
+ }
367
+ /*
368
+ * How the resource is named mid-sentence: "Docker host", "Ceph cluster",
369
+ * but "host" and "database server" (common nouns, not product names).
370
+ */
371
+ const COMMON_NOUN_DISPLAY_NAME_PATTERN = /^(Host|Database)\b/;
372
+ export function describeResourceInSentence(resourceType) {
373
+ const displayName = AI_RESOURCE_TYPE_INFO[resourceType].displayName;
374
+ return COMMON_NOUN_DISPLAY_NAME_PATTERN.test(displayName)
375
+ ? `${displayName.charAt(0).toLowerCase()}${displayName.slice(1)}`
376
+ : displayName;
377
+ }
378
+ /*
379
+ * A key hash that no key can have (its preimage is unknown), compared
380
+ * against when the presented agent id matches no row, so an unknown id and
381
+ * a wrong key cost the same.
382
+ */
383
+ const UNMATCHABLE_KEY_HASH = "0".repeat(64);
384
+ /*
385
+ * The resource AI agent of one infrastructure resource (see the model): its
386
+ * identity, and everything the server does about it.
387
+ *
388
+ * - Shared helpers every caller needs: key minting and hashing, the one
389
+ * online rule, the summary the dashboard sees, and the reads the access
390
+ * status and the enqueue chokepoint use (findAgentForResource,
391
+ * findOnlineAgentForResource, findAgentsForResources).
392
+ * - The identity lifecycle behind /resource-ai-agent-ingest: register
393
+ * (with the project's telemetry ingestion key; hands out an agent key),
394
+ * authenticate (every later request, by agent id and key), heartbeat and
395
+ * sign-off — plus the admin reset on the resource's AI agent page.
396
+ *
397
+ * Registration never deletes or unbinds anything: the resource's settings
398
+ * are left as they are. The only resource setting it ever writes is the
399
+ * first-connection defaults, and only on a resource nobody configured.
400
+ */
401
+ export class Service extends DatabaseService {
402
+ constructor() {
403
+ super(Model);
404
+ // Agent id → when this process last checked the agent's resource (ms).
405
+ this.resourceCheckedAt = new Map();
406
+ }
407
+ /*
408
+ * sha256 (hex) of an agent key: what ResourceAiAgent.keyHash stores. The
409
+ * key itself is never stored.
410
+ */
411
+ static hashKey(key) {
412
+ return crypto.createHash("sha256").update(key, "utf8").digest("hex");
413
+ }
414
+ // A fresh agent key: 32 cryptographically random bytes, hex encoded.
415
+ static generateKey() {
416
+ return crypto.randomBytes(AGENT_KEY_BYTES).toString("hex");
417
+ }
418
+ /*
419
+ * Does this presented key match the stored hash? Timing-safe, and false —
420
+ * never a throw — for anything that is not a non-empty key and a stored
421
+ * sha256 hex hash (a reset row's hash is null, which nothing matches).
422
+ */
423
+ static doesKeyMatchHash(key, keyHash) {
424
+ if (typeof key !== "string" || key.length === 0) {
425
+ return false;
426
+ }
427
+ if (typeof keyHash !== "string" || !SHA256_HEX_PATTERN.test(keyHash)) {
428
+ return false;
429
+ }
430
+ const presented = Buffer.from(Service.hashKey(key), "hex");
431
+ const stored = Buffer.from(keyHash.toLowerCase(), "hex");
432
+ return (presented.length === stored.length &&
433
+ crypto.timingSafeEqual(presented, stored));
434
+ }
435
+ // Instance forms of the static helpers, for callers holding the default export.
436
+ hashKey(key) {
437
+ return Service.hashKey(key);
438
+ }
439
+ generateKey() {
440
+ return Service.generateKey();
441
+ }
442
+ doesKeyMatchHash(key, keyHash) {
443
+ return Service.doesKeyMatchHash(key, keyHash);
444
+ }
445
+ // The binding of a resource type (see getResourceAiAgentResourceBinding).
446
+ static getResourceBinding(resourceType) {
447
+ return getResourceAiAgentResourceBinding(resourceType);
448
+ }
449
+ /*
450
+ * The one "is the agent online?" rule: it says it is connected (it
451
+ * registered or heartbeated and has not signed off or been reset) AND it
452
+ * was heard from within RESOURCE_AI_AGENT_ALIVE_WINDOW_IN_MINUTES. A
453
+ * heartbeat stamped slightly in the future (another server's clock) still
454
+ * counts as recent.
455
+ */
456
+ isOnline(row, now) {
457
+ if (row.connectionStatus !== "connected") {
458
+ return false;
459
+ }
460
+ const lastAliveAt = toDate(row.lastAliveAt);
461
+ if (!lastAliveAt) {
462
+ return false;
463
+ }
464
+ const nowTime = (now || OneUptimeDate.getCurrentDate()).getTime();
465
+ return (nowTime - lastAliveAt.getTime() <=
466
+ RESOURCE_AI_AGENT_ALIVE_WINDOW_IN_MINUTES * 60 * 1000);
467
+ }
468
+ /*
469
+ * The row as the dashboard and the access status see it. Never carries
470
+ * the key hash; the posture is re-validated on the way out, so a stored
471
+ * value of the wrong shape is dropped (null) rather than trusted. Values
472
+ * that were never set are null.
473
+ */
474
+ getAgentSummary(row, now) {
475
+ const connectionStatus = row.connectionStatus === "connected" ? "connected" : "disconnected";
476
+ return {
477
+ agentId: row.id ? row.id.toString() : "",
478
+ connectionStatus,
479
+ isOnline: this.isOnline(row, now),
480
+ agentVersion: row.agentVersion || null,
481
+ lastAliveAt: toIsoString(row.lastAliveAt),
482
+ lastRegisteredAt: toIsoString(row.lastRegisteredAt),
483
+ posture: parseResourceAiAgentPosture(row.posture),
484
+ lastRefusedRegistrationAt: toIsoString(row.lastRefusedRegistrationAt),
485
+ lastRefusedRegistrationReason: row.lastRefusedRegistrationReason || null,
486
+ };
487
+ }
488
+ // The resource's agent row (as root, without the key hash), or null.
489
+ async findAgentForResource(data) {
490
+ if (!isAiResourceType(data.resourceType)) {
491
+ return null;
492
+ }
493
+ return await this.findOneBy({
494
+ query: {
495
+ projectId: data.projectId,
496
+ resourceType: data.resourceType,
497
+ resourceId: data.resourceId,
498
+ },
499
+ select: RESOURCE_AI_AGENT_SELECT_WITHOUT_KEY,
500
+ props: {
501
+ isRoot: true,
502
+ },
503
+ });
504
+ }
505
+ /*
506
+ * The resource's agent row when it is online right now (isOnline), else
507
+ * null — what the enqueue chokepoint and the access status route a
508
+ * command to.
509
+ */
510
+ async findOnlineAgentForResource(data) {
511
+ const agent = await this.findAgentForResource(data);
512
+ if (!agent || !this.isOnline(agent, data.now)) {
513
+ return null;
514
+ }
515
+ return agent;
516
+ }
517
+ /*
518
+ * The agent rows of several resources of one type in one project, in one
519
+ * query, keyed by resource id (lowercase string). Resources without an
520
+ * agent are simply absent.
521
+ */
522
+ async findAgentsForResources(data) {
523
+ var _a;
524
+ const byResourceId = new Map();
525
+ const resourceIds = Array.from(new Set(data.resourceIds.map((id) => {
526
+ return id.toString().toLowerCase();
527
+ })));
528
+ if (resourceIds.length === 0 || !isAiResourceType(data.resourceType)) {
529
+ return byResourceId;
530
+ }
531
+ const rows = await this.findBy({
532
+ query: {
533
+ projectId: data.projectId,
534
+ resourceType: data.resourceType,
535
+ resourceId: QueryHelper.any(resourceIds),
536
+ },
537
+ select: RESOURCE_AI_AGENT_SELECT_WITHOUT_KEY,
538
+ limit: LIMIT_MAX,
539
+ skip: 0,
540
+ props: {
541
+ isRoot: true,
542
+ },
543
+ });
544
+ for (const row of rows) {
545
+ const resourceId = (_a = row.resourceId) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase();
546
+ if (resourceId &&
547
+ resourceIds.includes(resourceId) &&
548
+ row.resourceType === data.resourceType) {
549
+ byResourceId.set(resourceId, row);
550
+ }
551
+ }
552
+ return byResourceId;
553
+ }
554
+ /*
555
+ * One resource row of a type, in its project, as root, with the columns
556
+ * registration and the defaults need; null when it does not exist.
557
+ */
558
+ async findResource(data) {
559
+ var _a;
560
+ if (!isAiResourceType(data.resourceType) || !data.resourceId) {
561
+ return null;
562
+ }
563
+ const row = await Service.getResourceBinding(data.resourceType)
564
+ .getService()
565
+ .findOneBy({
566
+ query: {
567
+ _id: data.resourceId.toString(),
568
+ projectId: data.projectId,
569
+ },
570
+ select: RESOURCE_AI_AGENT_RESOURCE_SELECT,
571
+ props: { isRoot: true },
572
+ });
573
+ if (!row || !row.id) {
574
+ return null;
575
+ }
576
+ const columns = row;
577
+ return {
578
+ resourceType: data.resourceType,
579
+ id: row.id,
580
+ projectId: columns.projectId || data.projectId,
581
+ name: ((_a = columns.name) === null || _a === void 0 ? void 0 : _a.trim()) || "",
582
+ isAiInvestigationEnabled: columns.isAiInvestigationEnabled,
583
+ aiRemediationMode: columns.aiRemediationMode,
584
+ aiAccessConfiguredAt: columns.aiAccessConfiguredAt,
585
+ };
586
+ }
587
+ /*
588
+ * ------------------------------------------------------------------
589
+ * Registration
590
+ * ------------------------------------------------------------------
591
+ */
592
+ /*
593
+ * The agent registering for its resource (POST
594
+ * /resource-ai-agent-ingest/register, authenticated by the project's
595
+ * telemetry ingestion key). Hands out a fresh agent key; only its hash is
596
+ * kept.
597
+ *
598
+ * Refused (ResourceAiAgentRegistrationRefusedException, a 403 with the
599
+ * reason) when:
600
+ * - the resource type is not one OneUptime knows (resource_type_invalid);
601
+ * - the identity is empty or too long (resource_identifier_invalid), or
602
+ * a database identity names no endpoint;
603
+ * - the resource cannot be resolved (resource_not_found): a
604
+ * DATABASE_SERVER_ID that is not this project's, or a database
605
+ * endpoint no row owns and none may be created for;
606
+ * - the resource's agent is online and the request did not present its
607
+ * current key (previous_instance_online) — recorded on the row so the
608
+ * AI agent page can say another agent tried;
609
+ * - a new row would pass the project's caps (agent_cap_reached).
610
+ *
611
+ * An existing row is re-keyed when the request proves continuity (its
612
+ * current key as previousAgentKey), or when the row was reset, or its
613
+ * agent signed off or went quiet: what a restarted container looks like.
614
+ *
615
+ * On a resource nobody configured it applies the first-connection
616
+ * defaults (applyFirstConnectionDefaults). It never deletes, unbinds or
617
+ * rebinds anything, and writes ONE feed item when a resource's agent
618
+ * first connects.
619
+ */
620
+ async register(data) {
621
+ const resourceType = this.getValidResourceType(data.resourceType);
622
+ const identifier = this.getValidResourceIdentifier({
623
+ resourceType,
624
+ raw: data.resourceIdentifier,
625
+ });
626
+ const agentVersion = Service.normalizeAgentVersion(data.agentVersion);
627
+ const posture = this.buildStoredPosture({
628
+ reported: data.posture,
629
+ resourceType,
630
+ resourceIdentifier: identifier,
631
+ });
632
+ const resource = await this.resolveResource({
633
+ projectId: data.projectId,
634
+ resourceType,
635
+ identifier,
636
+ resourceId: data.resourceId,
637
+ posture,
638
+ });
639
+ const info = AI_RESOURCE_TYPE_INFO[resourceType];
640
+ const agentKey = Service.generateKey();
641
+ const now = OneUptimeDate.getCurrentDate();
642
+ const existing = await this.findOneBy({
643
+ query: {
644
+ projectId: data.projectId,
645
+ resourceType,
646
+ resourceId: resource.id,
647
+ },
648
+ select: Object.assign(Object.assign({}, RESOURCE_AI_AGENT_SELECT_WITHOUT_KEY), { keyHash: true }),
649
+ props: { isRoot: true },
650
+ });
651
+ let agentId;
652
+ let admission;
653
+ if (existing && existing.id) {
654
+ admission = await this.admitReRegistration({
655
+ agent: existing,
656
+ previousAgentKey: data.previousAgentKey,
657
+ resourceType,
658
+ identifier,
659
+ projectId: data.projectId,
660
+ });
661
+ await this.updateOneById({
662
+ id: existing.id,
663
+ data: Object.assign({ keyHash: Service.hashKey(agentKey), resourceIdentifier: identifier, posture: posture, lastAliveAt: now, connectionStatus: "connected", lastRegisteredAt: now, registeredWithIngestionKeyId: data.ingestionKeyId || null }, (agentVersion ? { agentVersion } : {})),
664
+ props: { isRoot: true },
665
+ });
666
+ agentId = existing.id;
667
+ }
668
+ else {
669
+ await this.assertAgentMayBeCreated({
670
+ projectId: data.projectId,
671
+ resourceType,
672
+ identifier,
673
+ });
674
+ const row = new Model();
675
+ row.projectId = data.projectId;
676
+ row.resourceType = resourceType;
677
+ row.resourceId = resource.id;
678
+ row.resourceIdentifier = identifier;
679
+ row.keyHash = Service.hashKey(agentKey);
680
+ row.posture = posture;
681
+ row.lastAliveAt = now;
682
+ row.connectionStatus = "connected";
683
+ row.lastRegisteredAt = now;
684
+ if (agentVersion) {
685
+ row.agentVersion = agentVersion;
686
+ }
687
+ if (data.ingestionKeyId) {
688
+ row.registeredWithIngestionKeyId = data.ingestionKeyId;
689
+ }
690
+ const created = await this.createAgentRow({
691
+ row,
692
+ resourceType,
693
+ identifier,
694
+ });
695
+ agentId = created.id;
696
+ admission = "created";
697
+ }
698
+ logger.info(`ResourceAiAgent: the ${info.agentDisplayName} of ${info.displayName} "${identifier}" (${resource.id.toString()}) in project ${data.projectId.toString()} registered (${admission}).`);
699
+ /*
700
+ * The new key's hash is stored: from here on nothing may fail the
701
+ * registration, or the agent never receives a key the row now demands
702
+ * (see applyFirstConnectionDefaultsSafely). The feed items are safe
703
+ * already — the resource feed services never throw.
704
+ */
705
+ const defaultsApplied = await this.applyFirstConnectionDefaultsSafely({
706
+ resource,
707
+ allowWrites: posture.allowWrites === true,
708
+ });
709
+ if (admission === "created") {
710
+ await this.writeConnectedFeedItem({
711
+ resource,
712
+ agentId,
713
+ posture,
714
+ agentVersion,
715
+ defaultsApplied,
716
+ });
717
+ }
718
+ else if (Service.didApplyDefaults(defaultsApplied)) {
719
+ await this.writeDefaultsFeedItem({ resource, posture, defaultsApplied });
720
+ }
721
+ return {
722
+ agentId,
723
+ agentKey,
724
+ resourceType,
725
+ resourceId: resource.id,
726
+ resourceName: resource.name || identifier,
727
+ admission,
728
+ };
729
+ }
730
+ /*
731
+ * How a registration for a resource that already has an agent row is
732
+ * admitted, or null when it must be refused (the row's agent is online
733
+ * and the request did not prove it is that agent). A reset row admits
734
+ * anyone: no key is valid for it, and the admin reset is exactly the
735
+ * "let the real agent back in" action.
736
+ */
737
+ getReRegistrationAdmission(data) {
738
+ if (!data.agent.keyHash) {
739
+ return "reset";
740
+ }
741
+ if (Service.doesKeyMatchHash(data.previousAgentKey, data.agent.keyHash)) {
742
+ return "continuity";
743
+ }
744
+ if (data.agent.connectionStatus !== "connected") {
745
+ return "signed_off";
746
+ }
747
+ if (!this.isOnline(data.agent, data.now)) {
748
+ return "offline";
749
+ }
750
+ return null;
751
+ }
752
+ /*
753
+ * The first-connection defaults, applied ONLY to a resource nobody
754
+ * configured (aiAccessConfiguredAt is null — an operator's write of any
755
+ * AI setting stamps it): investigating through the agent on, and, when
756
+ * the agent allows writes (ONEUPTIME_AI_ALLOW_WRITES=true on the agent),
757
+ * fixes "Ask for approval" instead of Off. Allowing writes on the agent is
758
+ * the operator's consent for that; a human still approves every fix.
759
+ * Never sets aiAccessConfiguredAt, so these stay defaults — and never
760
+ * touches a mode an operator chose.
761
+ *
762
+ * Registration applies them every time; a heartbeat applies them when the
763
+ * agent's write access appears (the agent was restarted with writes
764
+ * allowed). The update is conditioned on the resource still being
765
+ * unconfigured, so an operator's choice made a moment earlier is never
766
+ * overwritten. It is a root write: the resource services neither gate nor
767
+ * mark root writes of AI settings (they are the server's own).
768
+ */
769
+ async applyFirstConnectionDefaults(data) {
770
+ const defaults = this.getFirstConnectionDefaults(data);
771
+ if (!Service.didApplyDefaults(defaults) || !data.resource.id) {
772
+ return { turnedOnInvestigation: false };
773
+ }
774
+ const updated = await Service.getResourceBinding(data.resource.resourceType)
775
+ .getService()
776
+ .updateOneBy({
777
+ query: Object.assign({ _id: data.resource.id.toString(), aiAccessConfiguredAt: QueryHelper.isNull() }, (data.resource.projectId
778
+ ? { projectId: data.resource.projectId }
779
+ : {})),
780
+ data: Object.assign(Object.assign({}, (defaults.turnedOnInvestigation
781
+ ? { isAiInvestigationEnabled: true }
782
+ : {})), (defaults.remediationMode
783
+ ? { aiRemediationMode: defaults.remediationMode }
784
+ : {})),
785
+ props: { isRoot: true },
786
+ });
787
+ if (updated === 0) {
788
+ return { turnedOnInvestigation: false };
789
+ }
790
+ logger.info(`ResourceAiAgent: applied the first-connection defaults to ${AI_RESOURCE_TYPE_INFO[data.resource.resourceType].displayName} ${data.resource.id.toString()} (${[
791
+ defaults.turnedOnInvestigation ? "investigation on" : "",
792
+ defaults.remediationMode
793
+ ? `remediation ${defaults.remediationMode}`
794
+ : "",
795
+ ]
796
+ .filter(Boolean)
797
+ .join(", ")}).`);
798
+ return defaults;
799
+ }
800
+ /*
801
+ * applyFirstConnectionDefaults for a request whose real work is already
802
+ * written — registration stored the new key's hash and marked the row
803
+ * connected, a heartbeat stored the liveness. A failure here must not
804
+ * fail that request: a registration that answered 500 after storing the
805
+ * hash would leave a row that reads online and holds a key nobody
806
+ * received, so every retry would be refused as previous_instance_online
807
+ * (and recorded as another agent's attempt) until the alive window
808
+ * lapsed. Nothing is lost by skipping the defaults: the next
809
+ * registration applies them again. Logged, and reported as "nothing
810
+ * changed", so no feed item claims a change that did not happen.
811
+ */
812
+ async applyFirstConnectionDefaultsSafely(data) {
813
+ var _a;
814
+ try {
815
+ return await this.applyFirstConnectionDefaults(data);
816
+ }
817
+ catch (error) {
818
+ logger.error(`ResourceAiAgent: could not apply the first-connection defaults to ${data.resource.resourceType} ${(_a = data.resource.id) === null || _a === void 0 ? void 0 : _a.toString()}; the next registration tries again: ${error}`);
819
+ return { turnedOnInvestigation: false };
820
+ }
821
+ }
822
+ // What applyFirstConnectionDefaults would change, without writing it.
823
+ getFirstConnectionDefaults(data) {
824
+ if (data.resource.aiAccessConfiguredAt) {
825
+ return { turnedOnInvestigation: false };
826
+ }
827
+ const isRemediationOff = parseResourceAiRemediationMode(data.resource.aiRemediationMode) ===
828
+ ResourceAiRemediationMode.Disabled;
829
+ return Object.assign({ turnedOnInvestigation: data.resource.isAiInvestigationEnabled !== true }, (data.allowWrites && isRemediationOff
830
+ ? { remediationMode: ResourceAiRemediationMode.RequireApproval }
831
+ : {}));
832
+ }
833
+ static didApplyDefaults(defaults) {
834
+ return defaults.turnedOnInvestigation || Boolean(defaults.remediationMode);
835
+ }
836
+ /*
837
+ * The posture a row stores: what the agent reported, validated field by
838
+ * field (parseResourceAiAgentPosture: allowWrites only for a literal true,
839
+ * malformed target lists force it off, strings capped), with the two
840
+ * facts the server decides itself forced — WHICH kind of resource, and
841
+ * WHICH identity (the one the agent registered with). A body can never
842
+ * make the agent the executor of another resource.
843
+ */
844
+ buildStoredPosture(data) {
845
+ const reported = data.reported &&
846
+ typeof data.reported === "object" &&
847
+ !Array.isArray(data.reported)
848
+ ? data.reported
849
+ : {};
850
+ const parsed = parseResourceAiAgentPosture(Object.assign(Object.assign({}, reported), { resourceType: data.resourceType, resourceIdentifier: data.resourceIdentifier }));
851
+ const posture = parsed || {
852
+ resourceType: data.resourceType,
853
+ resourceIdentifier: data.resourceIdentifier.trim(),
854
+ allowWrites: false,
855
+ writeTargets: [],
856
+ protectedTargets: [],
857
+ reachable: false,
858
+ };
859
+ // A JSON column: store only what is known, never `undefined` keys.
860
+ for (const key of Object.keys(posture)) {
861
+ if (posture[key] === undefined) {
862
+ delete posture[key];
863
+ }
864
+ }
865
+ return posture;
866
+ }
867
+ /*
868
+ * The version string the agent reports, bounded to its ShortText column
869
+ * (an over-long value would fail the whole write); undefined when absent.
870
+ */
871
+ static normalizeAgentVersion(value) {
872
+ if (typeof value !== "string") {
873
+ return undefined;
874
+ }
875
+ const trimmed = value.trim();
876
+ return trimmed ? trimmed.substring(0, ColumnLength.ShortText) : undefined;
877
+ }
878
+ // The longest identity registration accepts for a type.
879
+ static getMaxIdentifierLength(resourceType) {
880
+ return resourceType === AiResourceType.DatabaseServer
881
+ ? MAX_DATABASE_AI_AGENT_IDENTIFIER_LENGTH
882
+ : MAX_RESOURCE_AI_AGENT_IDENTIFIER_LENGTH;
883
+ }
884
+ getValidResourceType(raw) {
885
+ const resourceType = parseAiResourceType(raw);
886
+ if (!resourceType) {
887
+ const aliases = ALL_AI_RESOURCE_TYPES.map((type) => {
888
+ return AI_RESOURCE_TYPE_INFO[type].agentAlias;
889
+ }).join(", ");
890
+ throw new ResourceAiAgentRegistrationRefusedException({
891
+ reason: "resource_type_invalid",
892
+ message: `The agent did not say which kind of resource it serves${typeof raw === "string" && raw.trim()
893
+ ? ` ("${raw.trim().substring(0, 64)}" is not one OneUptime knows)`
894
+ : ""}. Set ${RESOURCE_AI_AGENT_RESOURCE_TYPE_ENV} on the agent to one of: ${aliases}.`,
895
+ });
896
+ }
897
+ return resourceType;
898
+ }
899
+ getValidResourceIdentifier(data) {
900
+ const info = AI_RESOURCE_TYPE_INFO[data.resourceType];
901
+ const identifier = typeof data.raw === "string" ? data.raw.trim() : "";
902
+ const variables = `${info.identityEnvVars.join(" / ")} (or ${RESOURCE_AI_AGENT_RESOURCE_NAME_ENV})`;
903
+ if (!identifier) {
904
+ throw new ResourceAiAgentRegistrationRefusedException({
905
+ reason: "resource_identifier_invalid",
906
+ message: `The ${info.agentDisplayName} did not say which ${describeResourceInSentence(data.resourceType)} it serves. Set ${variables} on the agent.`,
907
+ });
908
+ }
909
+ const limit = Service.getMaxIdentifierLength(data.resourceType);
910
+ if (identifier.length > limit) {
911
+ throw new ResourceAiAgentRegistrationRefusedException({
912
+ reason: "resource_identifier_invalid",
913
+ message: `The ${describeResourceInSentence(data.resourceType)} identity is ${identifier.length} characters long; the limit is ${limit}. Set a shorter ${variables} on the agent.`,
914
+ });
915
+ }
916
+ return identifier;
917
+ }
918
+ /*
919
+ * The resource the agent names, created when OneUptime has not seen it
920
+ * yet (the agent may register before the collector's first telemetry),
921
+ * then re-read for the AI columns registration needs.
922
+ */
923
+ async resolveResource(data) {
924
+ const info = AI_RESOURCE_TYPE_INFO[data.resourceType];
925
+ if (data.resourceType === AiResourceType.DatabaseServer) {
926
+ const databaseServerId = await this.resolveDatabaseServerId(data);
927
+ const databaseServer = await this.findResource({
928
+ projectId: data.projectId,
929
+ resourceType: data.resourceType,
930
+ resourceId: databaseServerId,
931
+ });
932
+ if (!databaseServer) {
933
+ throw new BadDataException(`The ${info.displayName} could not be resolved.`);
934
+ }
935
+ return databaseServer;
936
+ }
937
+ const resourceId = await this.findOrCreateResourceId(Object.assign(Object.assign({}, data), { fresh: false }));
938
+ let resource = await this.findResource({
939
+ projectId: data.projectId,
940
+ resourceType: data.resourceType,
941
+ resourceId,
942
+ });
943
+ /*
944
+ * The id can come from an in-process memo (HostService keeps a host's
945
+ * id for a minute, and a delete does not clear it) and name a resource
946
+ * deleted since: an operator deleted it while its agent ran, and the
947
+ * agent registers again within seconds. Resolve it once more past the
948
+ * memo, which creates the resource anew, as a first registration does.
949
+ */
950
+ if (!resource) {
951
+ const freshId = await this.findOrCreateResourceId(Object.assign(Object.assign({}, data), { fresh: true }));
952
+ if (freshId.toString() !== resourceId.toString()) {
953
+ resource = await this.findResource({
954
+ projectId: data.projectId,
955
+ resourceType: data.resourceType,
956
+ resourceId: freshId,
957
+ });
958
+ }
959
+ }
960
+ if (!resource) {
961
+ throw new BadDataException(`The ${info.displayName} could not be resolved.`);
962
+ }
963
+ return resource;
964
+ }
965
+ // The id of the row a named type's identity finds or creates.
966
+ async findOrCreateResourceId(data) {
967
+ const binding = Service.getResourceBinding(data.resourceType);
968
+ const found = binding.findOrCreateByIdentity
969
+ ? await binding.findOrCreateByIdentity(Object.assign({ projectId: data.projectId, identifier: data.identifier }, (data.fresh ? { fresh: true } : {})))
970
+ : null;
971
+ if (!found || !found.id) {
972
+ throw new BadDataException(`The ${AI_RESOURCE_TYPE_INFO[data.resourceType].displayName} could not be resolved.`);
973
+ }
974
+ return found.id;
975
+ }
976
+ /*
977
+ * The DatabaseServer a Database AI agent serves:
978
+ *
979
+ * 1. a pinned id (DATABASE_SERVER_ID, sent as resourceId — or an identity
980
+ * that is itself a database id): that row, if it is in this project,
981
+ * else resource_not_found. Never a fallback to the endpoint: the
982
+ * operator pinned THAT database.
983
+ * 2. otherwise the endpoint, read from "<system>|<address>[:<port>]"
984
+ * (the identity the agent sends), else from the posture's details
985
+ * (databaseSystem, serverAddress, serverPort), and canonicalized
986
+ * exactly as the Database Agent collector's telemetry is (engine
987
+ * family, default port, the same stability rules): the row that owns
988
+ * it, or a new one when the endpoint may create one.
989
+ */
990
+ async resolveDatabaseServerId(data) {
991
+ const pinned = Service.readPinnedDatabaseServerId({
992
+ resourceId: data.resourceId,
993
+ identifier: data.identifier,
994
+ });
995
+ if (pinned !== null) {
996
+ const row = UUID_PATTERN.test(pinned)
997
+ ? await DatabaseServerService.findByIdInProject(data.projectId, new ObjectID(pinned))
998
+ : null;
999
+ if (!row || !row.id) {
1000
+ throw new ResourceAiAgentRegistrationRefusedException({
1001
+ reason: "resource_not_found",
1002
+ message: `DATABASE_SERVER_ID "${pinned.substring(0, 64)}" is not a database in this project. Copy the id from the database's page in OneUptime, or unset DATABASE_SERVER_ID to register the database by its endpoint.`,
1003
+ });
1004
+ }
1005
+ return row.id;
1006
+ }
1007
+ const endpointIdentity = Service.parseDatabaseEndpointIdentity(data.identifier) ||
1008
+ Service.readDatabaseEndpointFromPosture(data.posture);
1009
+ if (!endpointIdentity) {
1010
+ throw new ResourceAiAgentRegistrationRefusedException({
1011
+ reason: "resource_identifier_invalid",
1012
+ message: `The Database AI agent's identity "${data.identifier.substring(0, 64)}" names neither a database id nor an endpoint. Set DATABASE_SERVER_ID to the database's id in OneUptime, or DATABASE_SYSTEM, DATABASE_SERVER_ADDRESS and DATABASE_SERVER_PORT to its endpoint.`,
1013
+ });
1014
+ }
1015
+ const attributes = {
1016
+ "db.system.name": endpointIdentity.system,
1017
+ "server.address": endpointIdentity.address,
1018
+ [DATABASE_AGENT_ATTRIBUTE]: "true",
1019
+ };
1020
+ if (endpointIdentity.port !== null) {
1021
+ attributes["server.port"] = String(endpointIdentity.port);
1022
+ }
1023
+ const resolved = resolveDatabaseFromResourceAttributes({ attributes });
1024
+ const endpoint = (resolved === null || resolved === void 0 ? void 0 : resolved.endpoint) || null;
1025
+ if (!resolved || !endpoint) {
1026
+ throw new ResourceAiAgentRegistrationRefusedException({
1027
+ reason: "resource_not_found",
1028
+ message: `"${endpointIdentity.address.substring(0, 128)}" is not an address OneUptime can identify a database server by (a loopback or unreadable address). Set DATABASE_SERVER_ADDRESS to the host name your applications use for this database, or DATABASE_SERVER_ID to its id in OneUptime.`,
1029
+ });
1030
+ }
1031
+ const row = await DatabaseServerService.findOrCreateByEndpoint({
1032
+ projectId: data.projectId,
1033
+ dbSystem: resolved.system,
1034
+ endpoint,
1035
+ discoverySource: DatabaseServerDiscoverySource.Collector,
1036
+ displayName: resolved.displayName || undefined,
1037
+ allowCreate: resolved.allowCreate,
1038
+ /*
1039
+ * An agent registering (every restart, and every refused retry of
1040
+ * a duplicate) is no sign the database is in use: it must not
1041
+ * restore a database discovery archived for going quiet, nor move
1042
+ * its endpoint's last match or weigh its engine.
1043
+ */
1044
+ isSighting: false,
1045
+ });
1046
+ if (!row || !row.id) {
1047
+ throw new ResourceAiAgentRegistrationRefusedException({
1048
+ reason: "resource_not_found",
1049
+ message: `No database in this project owns ${formatDatabaseEndpoint(endpoint)}, and OneUptime could not add one for it (a private or single-label address, an engine it does not add automatically, or the project's automatic-add budget). Add the database in OneUptime (or wait for its collector to report it), then set DATABASE_SERVER_ID to its id.`,
1050
+ });
1051
+ }
1052
+ return row.id;
1053
+ }
1054
+ /*
1055
+ * The database id an agent pinned: its resourceId, else an identity that
1056
+ * is itself an id (ONEUPTIME_AI_AGENT_RESOURCE_NAME set to one). Null
1057
+ * when neither pins a row; a pinned value that is not a UUID is returned
1058
+ * as is, so the caller refuses it rather than silently using the
1059
+ * endpoint.
1060
+ */
1061
+ static readPinnedDatabaseServerId(data) {
1062
+ if (typeof data.resourceId === "string" && data.resourceId.trim()) {
1063
+ return data.resourceId.trim().toLowerCase();
1064
+ }
1065
+ if (UUID_PATTERN.test(data.identifier.trim())) {
1066
+ return data.identifier.trim().toLowerCase();
1067
+ }
1068
+ return null;
1069
+ }
1070
+ /*
1071
+ * "<system>|<address>[:<port>]" (the agent's endpoint identity, the form
1072
+ * DatabaseServer.databaseIdentifier takes) as its parts; the address
1073
+ * keeps its port (parsed with the rest when it is canonicalized). Null
1074
+ * when the value has no system or no address.
1075
+ */
1076
+ static parseDatabaseEndpointIdentity(identifier) {
1077
+ const separator = identifier.indexOf("|");
1078
+ if (separator <= 0) {
1079
+ return null;
1080
+ }
1081
+ const system = identifier.substring(0, separator).trim();
1082
+ const address = identifier.substring(separator + 1).trim();
1083
+ if (!system || !address || address.includes("|")) {
1084
+ return null;
1085
+ }
1086
+ return { system: system.toLowerCase(), address, port: null };
1087
+ }
1088
+ // The endpoint the agent's posture details describe, or null.
1089
+ static readDatabaseEndpointFromPosture(posture) {
1090
+ const details = (posture === null || posture === void 0 ? void 0 : posture.details) || {};
1091
+ const system = details["databaseSystem"];
1092
+ const address = details["serverAddress"];
1093
+ const port = details["serverPort"];
1094
+ if (typeof system !== "string" ||
1095
+ !system.trim() ||
1096
+ typeof address !== "string" ||
1097
+ !address.trim()) {
1098
+ return null;
1099
+ }
1100
+ return {
1101
+ system: system.trim().toLowerCase(),
1102
+ address: address.trim(),
1103
+ port: typeof port === "number" &&
1104
+ Number.isInteger(port) &&
1105
+ port >= 1 &&
1106
+ port <= 65535
1107
+ ? port
1108
+ : null,
1109
+ };
1110
+ }
1111
+ /*
1112
+ * An existing row: admitted per getReRegistrationAdmission, or refused
1113
+ * with previous_instance_online — which is recorded on the row (when, and
1114
+ * why) so the AI agent page can warn that another agent tried to register
1115
+ * while this one was online. Nothing about the current key is disclosed.
1116
+ */
1117
+ async admitReRegistration(data) {
1118
+ var _a;
1119
+ const admission = this.getReRegistrationAdmission({
1120
+ agent: data.agent,
1121
+ previousAgentKey: data.previousAgentKey,
1122
+ });
1123
+ if (admission) {
1124
+ return admission;
1125
+ }
1126
+ logger.warn(`ResourceAiAgent: refused a registration for ${AI_RESOURCE_TYPE_INFO[data.resourceType].displayName} "${data.identifier}" in project ${data.projectId.toString()}: its agent (${(_a = data.agent.id) === null || _a === void 0 ? void 0 : _a.toString()}) is online and the request did not present its current key.`);
1127
+ await this.recordRefusedRegistration({
1128
+ agentId: data.agent.id,
1129
+ reason: "previous_instance_online",
1130
+ });
1131
+ throw this.getPreviousInstanceOnlineRefusal({
1132
+ resourceType: data.resourceType,
1133
+ identifier: data.identifier,
1134
+ });
1135
+ }
1136
+ getPreviousInstanceOnlineRefusal(data) {
1137
+ const info = AI_RESOURCE_TYPE_INFO[data.resourceType];
1138
+ return new ResourceAiAgentRegistrationRefusedException({
1139
+ reason: "previous_instance_online",
1140
+ retryAfterSeconds: RESOURCE_AI_AGENT_REGISTRATION_RETRY_AFTER_SECONDS,
1141
+ message: `Another ${info.agentDisplayName} for ${describeResourceInSentence(data.resourceType)} "${data.identifier}" is online. This is normal for a moment while its container restarts, and the agent retries on its own. If it lasts, make sure only one ${info.agentDisplayName} is installed for "${data.identifier}".`,
1142
+ });
1143
+ }
1144
+ // Best-effort: recording a refusal must never turn it into a 500.
1145
+ async recordRefusedRegistration(data) {
1146
+ try {
1147
+ await this.updateColumnsByIdWithoutHooks({
1148
+ id: data.agentId,
1149
+ data: {
1150
+ lastRefusedRegistrationAt: OneUptimeDate.getCurrentDate(),
1151
+ lastRefusedRegistrationReason: data.reason,
1152
+ },
1153
+ });
1154
+ }
1155
+ catch (error) {
1156
+ logger.error(`ResourceAiAgent: could not record a refused registration on agent ${data.agentId.toString()}: ${error}`);
1157
+ }
1158
+ }
1159
+ /*
1160
+ * Bounds what an ingestion key can create (see the caps above). One
1161
+ * table serves every resource type, so the caps count every type's
1162
+ * agents together. At the cap, agents not heard from in
1163
+ * RESOURCE_AI_AGENT_RECLAIM_AFTER_DAYS make room first.
1164
+ */
1165
+ async assertAgentMayBeCreated(data) {
1166
+ const displayName = AI_RESOURCE_TYPE_INFO[data.resourceType].displayName;
1167
+ let total = await this.countAgentsInProject(data.projectId);
1168
+ if (total >= MAX_RESOURCE_AI_AGENTS_PER_PROJECT &&
1169
+ (await this.reclaimLongOfflineAgents(data.projectId)) > 0) {
1170
+ total = await this.countAgentsInProject(data.projectId);
1171
+ }
1172
+ if (total >= MAX_RESOURCE_AI_AGENTS_PER_PROJECT) {
1173
+ logger.warn(`ResourceAiAgent: refused to create an agent for ${displayName} "${data.identifier}" in project ${data.projectId.toString()}: the project already has ${total} (limit ${MAX_RESOURCE_AI_AGENTS_PER_PROJECT}).`);
1174
+ throw new ResourceAiAgentRegistrationRefusedException({
1175
+ reason: "agent_cap_reached",
1176
+ message: `This project already has ${total} resource AI agents, which is its limit (${MAX_RESOURCE_AI_AGENTS_PER_PROJECT}). An agent not heard from in ${RESOURCE_AI_AGENT_RECLAIM_AFTER_DAYS} days makes room for a new one; to make room now, delete the resources you no longer use in OneUptime. The agent connects on its next retry.`,
1177
+ });
1178
+ }
1179
+ const createdInLastHour = (await this.countBy({
1180
+ query: {
1181
+ projectId: data.projectId,
1182
+ createdAt: QueryHelper.greaterThan(OneUptimeDate.getSomeHoursAgo(1)),
1183
+ },
1184
+ props: { isRoot: true },
1185
+ })).toNumber();
1186
+ if (createdInLastHour >= MAX_NEW_RESOURCE_AI_AGENTS_PER_PROJECT_PER_HOUR) {
1187
+ logger.warn(`ResourceAiAgent: refused to create an agent for ${displayName} "${data.identifier}" in project ${data.projectId.toString()}: ${createdInLastHour} were created in the last hour (limit ${MAX_NEW_RESOURCE_AI_AGENTS_PER_PROJECT_PER_HOUR}).`);
1188
+ throw new ResourceAiAgentRegistrationRefusedException({
1189
+ reason: "agent_cap_reached",
1190
+ message: `${createdInLastHour} resource AI agents connected to this project in the last hour, which is its limit (${MAX_NEW_RESOURCE_AI_AGENTS_PER_PROJECT_PER_HOUR}). The agent connects on a later retry.`,
1191
+ });
1192
+ }
1193
+ }
1194
+ async countAgentsInProject(projectId) {
1195
+ return (await this.countBy({
1196
+ query: { projectId },
1197
+ props: { isRoot: true },
1198
+ })).toNumber();
1199
+ }
1200
+ /*
1201
+ * Removes the project's agent rows not heard from in
1202
+ * RESOURCE_AI_AGENT_RECLAIM_AFTER_DAYS; how many. Best-effort: a failure
1203
+ * leaves the cap to refuse as before.
1204
+ */
1205
+ async reclaimLongOfflineAgents(projectId) {
1206
+ try {
1207
+ const reclaimed = await this.deleteBy({
1208
+ query: {
1209
+ projectId,
1210
+ lastAliveAt: QueryHelper.lessThanOrNull(OneUptimeDate.getSomeDaysAgo(RESOURCE_AI_AGENT_RECLAIM_AFTER_DAYS)),
1211
+ },
1212
+ limit: LIMIT_MAX,
1213
+ skip: 0,
1214
+ props: { isRoot: true },
1215
+ });
1216
+ if (reclaimed > 0) {
1217
+ logger.info(`ResourceAiAgent: removed ${reclaimed} agent(s) of project ${projectId.toString()} not heard from in ${RESOURCE_AI_AGENT_RECLAIM_AFTER_DAYS} days, to make room for a new one.`);
1218
+ }
1219
+ return reclaimed;
1220
+ }
1221
+ catch (error) {
1222
+ logger.error(`ResourceAiAgent: could not remove the long-offline agents of project ${projectId.toString()}: ${error}`);
1223
+ return 0;
1224
+ }
1225
+ }
1226
+ /*
1227
+ * Creates the resource's agent row. The database allows one per live
1228
+ * resource, so when two agents register for a new resource at once one
1229
+ * create loses; that agent is told the other agent is online (it is — it
1230
+ * just registered), exactly as if it had arrived a moment later.
1231
+ */
1232
+ async createAgentRow(data) {
1233
+ try {
1234
+ return await this.create({
1235
+ data: data.row,
1236
+ props: { isRoot: true },
1237
+ });
1238
+ }
1239
+ catch (error) {
1240
+ const winner = await this.findOneBy({
1241
+ query: {
1242
+ projectId: data.row.projectId,
1243
+ resourceType: data.resourceType,
1244
+ resourceId: data.row.resourceId,
1245
+ },
1246
+ select: { _id: true },
1247
+ props: { isRoot: true },
1248
+ });
1249
+ if (!winner) {
1250
+ throw error;
1251
+ }
1252
+ logger.info(`ResourceAiAgent: two agents registered for ${AI_RESOURCE_TYPE_INFO[data.resourceType].displayName} "${data.identifier}" at once; the other one was admitted.`);
1253
+ throw this.getPreviousInstanceOnlineRefusal({
1254
+ resourceType: data.resourceType,
1255
+ identifier: data.identifier,
1256
+ });
1257
+ }
1258
+ }
1259
+ /*
1260
+ * ------------------------------------------------------------------
1261
+ * The registered agent
1262
+ * ------------------------------------------------------------------
1263
+ */
1264
+ /*
1265
+ * The agent a request's id and key belong to, or null. Every request
1266
+ * after registration is authenticated here: the key's sha256 must match
1267
+ * the row's hash (timing-safe). A reset row (null hash) matches nothing,
1268
+ * and an unknown id costs the same comparison as a wrong key. The row is
1269
+ * returned without its key hash.
1270
+ */
1271
+ async authenticate(data) {
1272
+ var _a;
1273
+ const agentId = typeof data.agentId === "string"
1274
+ ? data.agentId
1275
+ : ((_a = data.agentId) === null || _a === void 0 ? void 0 : _a.toString()) || "";
1276
+ if (!agentId ||
1277
+ !ObjectID.isValidUUID(agentId) ||
1278
+ typeof data.agentKey !== "string" ||
1279
+ !data.agentKey) {
1280
+ return null;
1281
+ }
1282
+ const agent = await this.findOneBy({
1283
+ query: { _id: agentId },
1284
+ select: Object.assign(Object.assign({}, RESOURCE_AI_AGENT_SELECT_WITHOUT_KEY), { keyHash: true }),
1285
+ props: { isRoot: true },
1286
+ });
1287
+ const matches = Service.doesKeyMatchHash(data.agentKey, (agent === null || agent === void 0 ? void 0 : agent.keyHash) || UNMATCHABLE_KEY_HASH);
1288
+ if (!agent || !matches) {
1289
+ return null;
1290
+ }
1291
+ delete agent.keyHash;
1292
+ return agent;
1293
+ }
1294
+ /*
1295
+ * A heartbeat from the authenticated agent: it is alive and connected,
1296
+ * and this is what it can do now. The posture is stored the way
1297
+ * registration stores it (validated, with the resource type and the
1298
+ * identity the agent registered with forced); a heartbeat without one
1299
+ * keeps the stored posture.
1300
+ *
1301
+ * When the agent's write access appears (it was restarted with
1302
+ * ONEUPTIME_AI_ALLOW_WRITES=true) on a resource nobody configured, the
1303
+ * first-connection defaults apply again, so fixes move from Off to "Ask
1304
+ * for approval" without anyone visiting the AI agent page.
1305
+ *
1306
+ * This runs every 30 seconds per resource, so a normal heartbeat is one
1307
+ * UPDATE without hooks and no read: the agent row holds the identity it
1308
+ * registered with. The resource row is read only every
1309
+ * RESOURCE_AI_AGENT_RESOURCE_CHECK_INTERVAL_MS (is it still there?) and
1310
+ * when write access just appeared. An agent whose resource is gone is
1311
+ * retired: its row is deleted and the heartbeat answered 401, so the
1312
+ * agent registers again and is attached to whatever row its identity
1313
+ * resolves to now.
1314
+ */
1315
+ async heartbeat(data) {
1316
+ var _a, _b;
1317
+ const agentId = data.agent.id;
1318
+ if (!agentId) {
1319
+ throw new BadDataException("The agent is missing its id.");
1320
+ }
1321
+ const now = data.now || OneUptimeDate.getCurrentDate();
1322
+ let resource = undefined;
1323
+ if (this.isResourceCheckDue(agentId.toString(), now)) {
1324
+ resource = await this.findAgentResourceSafely(data.agent);
1325
+ if (resource === null) {
1326
+ await this.retireAgentOfGoneResource(data.agent);
1327
+ throw new NotAuthenticatedException(`This agent's ${isAiResourceType(data.agent.resourceType)
1328
+ ? describeResourceInSentence(data.agent.resourceType)
1329
+ : "resource"} no longer exists in OneUptime. Register again.`);
1330
+ }
1331
+ }
1332
+ const storedPosture = parseResourceAiAgentPosture(data.agent.posture);
1333
+ const isPostureReported = Boolean(data.posture &&
1334
+ typeof data.posture === "object" &&
1335
+ !Array.isArray(data.posture));
1336
+ const resourceType = isAiResourceType(data.agent.resourceType)
1337
+ ? data.agent.resourceType
1338
+ : null;
1339
+ const identifier = ((_a = data.agent.resourceIdentifier) === null || _a === void 0 ? void 0 : _a.trim()) ||
1340
+ ((_b = storedPosture === null || storedPosture === void 0 ? void 0 : storedPosture.resourceIdentifier) === null || _b === void 0 ? void 0 : _b.trim()) ||
1341
+ "";
1342
+ /*
1343
+ * The identity is the registered one, never the body's; a row that
1344
+ * somehow lacks it keeps its stored posture rather than trusting one.
1345
+ */
1346
+ const posture = isPostureReported && resourceType && identifier
1347
+ ? this.buildStoredPosture({
1348
+ reported: data.posture,
1349
+ resourceType,
1350
+ resourceIdentifier: identifier,
1351
+ })
1352
+ : undefined;
1353
+ const agentVersion = Service.normalizeAgentVersion(data.agentVersion);
1354
+ const update = {
1355
+ lastAliveAt: now,
1356
+ connectionStatus: "connected",
1357
+ };
1358
+ if (posture) {
1359
+ update["posture"] = posture;
1360
+ }
1361
+ if (agentVersion) {
1362
+ update["agentVersion"] = agentVersion;
1363
+ }
1364
+ await this.updateColumnsByIdWithoutHooks({
1365
+ id: agentId,
1366
+ data: update,
1367
+ });
1368
+ const writesAppeared = (posture === null || posture === void 0 ? void 0 : posture.allowWrites) === true && (storedPosture === null || storedPosture === void 0 ? void 0 : storedPosture.allowWrites) !== true;
1369
+ if (!writesAppeared || !posture) {
1370
+ return;
1371
+ }
1372
+ // The defaults read the resource's current AI settings.
1373
+ resource = resource || (await this.findAgentResource(data.agent));
1374
+ if (!resource) {
1375
+ return;
1376
+ }
1377
+ // The liveness is written; a failure here must not fail the heartbeat.
1378
+ const defaultsApplied = await this.applyFirstConnectionDefaultsSafely({
1379
+ resource,
1380
+ allowWrites: true,
1381
+ });
1382
+ if (Service.didApplyDefaults(defaultsApplied)) {
1383
+ await this.writeDefaultsFeedItem({ resource, posture, defaultsApplied });
1384
+ }
1385
+ }
1386
+ // The agent's own resource (in its project, as root), or null.
1387
+ async findAgentResource(agent) {
1388
+ if (!isAiResourceType(agent.resourceType) ||
1389
+ !agent.resourceId ||
1390
+ !agent.projectId) {
1391
+ return null;
1392
+ }
1393
+ return await this.findResource({
1394
+ projectId: agent.projectId,
1395
+ resourceType: agent.resourceType,
1396
+ resourceId: agent.resourceId,
1397
+ });
1398
+ }
1399
+ /*
1400
+ * findAgentResource for the heartbeat's periodic check: a failed read is
1401
+ * "not known" (undefined), never "gone" — only a read that found nothing
1402
+ * retires an agent.
1403
+ */
1404
+ async findAgentResourceSafely(agent) {
1405
+ var _a;
1406
+ try {
1407
+ return await this.findAgentResource(agent);
1408
+ }
1409
+ catch (error) {
1410
+ logger.error(`ResourceAiAgent: could not check the resource of agent ${(_a = agent.id) === null || _a === void 0 ? void 0 : _a.toString()}; the next check tries again: ${error}`);
1411
+ return undefined;
1412
+ }
1413
+ }
1414
+ /*
1415
+ * The resource of this agent is gone: the agent row goes too (the agent
1416
+ * registers again and gets a row for whatever its identity resolves to
1417
+ * now). Jobs still targeted at the row lose their target (the foreign key
1418
+ * sets it null) and time out unclaimed. Best-effort: a failed delete is
1419
+ * logged, and the next check tries again.
1420
+ */
1421
+ async retireAgentOfGoneResource(agent) {
1422
+ var _a, _b, _c;
1423
+ logger.info(`ResourceAiAgent: agent ${(_a = agent.id) === null || _a === void 0 ? void 0 : _a.toString()} serves ${String(agent.resourceType)} ${(_b = agent.resourceId) === null || _b === void 0 ? void 0 : _b.toString()}, which no longer exists; removing the agent row so the agent registers again.`);
1424
+ try {
1425
+ await this.deleteOneBy({
1426
+ query: Object.assign({ _id: agent.id.toString() }, (agent.projectId ? { projectId: agent.projectId } : {})),
1427
+ props: { isRoot: true },
1428
+ });
1429
+ }
1430
+ catch (error) {
1431
+ logger.error(`ResourceAiAgent: could not remove agent ${(_c = agent.id) === null || _c === void 0 ? void 0 : _c.toString()} of a deleted resource: ${error}`);
1432
+ }
1433
+ }
1434
+ /*
1435
+ * At most one resource check per interval per agent in this process.
1436
+ * Stamped before the check runs, so heartbeats that overlap it do not
1437
+ * start a second one.
1438
+ */
1439
+ isResourceCheckDue(agentId, now) {
1440
+ const lastCheckedAt = this.resourceCheckedAt.get(agentId);
1441
+ if (lastCheckedAt !== undefined &&
1442
+ now.getTime() - lastCheckedAt <
1443
+ RESOURCE_AI_AGENT_RESOURCE_CHECK_INTERVAL_MS) {
1444
+ return false;
1445
+ }
1446
+ // Bounded: a long-lived process forgets old agents rather than growing.
1447
+ if (this.resourceCheckedAt.size >= MAX_RESOURCE_CHECKS_REMEMBERED) {
1448
+ this.resourceCheckedAt.clear();
1449
+ }
1450
+ this.resourceCheckedAt.set(agentId, now.getTime());
1451
+ return true;
1452
+ }
1453
+ /*
1454
+ * The agent signing off on a clean shutdown. lastAliveAt is left alone
1455
+ * (it is when the agent was last heard from); the disconnected status is
1456
+ * what lets its replacement container register at once instead of
1457
+ * waiting for the alive window to lapse, and what makes the AI agent page
1458
+ * say "Offline" straight away. Its next heartbeat or registration flips
1459
+ * it back.
1460
+ */
1461
+ async markDisconnected(data) {
1462
+ if (!data.resourceAiAgentId) {
1463
+ throw new BadDataException("resourceAiAgentId is required");
1464
+ }
1465
+ await this.updateColumnsByIdWithoutHooks({
1466
+ id: data.resourceAiAgentId,
1467
+ data: { connectionStatus: "disconnected" },
1468
+ });
1469
+ }
1470
+ /*
1471
+ * An admin's "Reset agent" on the resource's AI agent page: the agent's
1472
+ * key stops working at once (keyHash null matches nothing) and the row
1473
+ * reads as disconnected. The real agent fails authentication on its next
1474
+ * request, registers again and — the row being reset — is admitted, so it
1475
+ * comes back by itself within a few minutes. Whoever else held the key
1476
+ * (an agent that registered with a leaked ingestion key) is locked out
1477
+ * the same way; rotating that ingestion key keeps it out. The caller
1478
+ * checks the user may do this (see the resource AI access API).
1479
+ */
1480
+ async resetAgent(data) {
1481
+ const info = isAiResourceType(data.resourceType)
1482
+ ? AI_RESOURCE_TYPE_INFO[data.resourceType]
1483
+ : undefined;
1484
+ if (!info) {
1485
+ throw new BadDataException("This is not a resource type with AI agents.");
1486
+ }
1487
+ const agent = await this.findAgentForResource({
1488
+ projectId: data.projectId,
1489
+ resourceType: data.resourceType,
1490
+ resourceId: data.resourceId,
1491
+ });
1492
+ if (!agent || !agent.id) {
1493
+ throw new BadDataException(`This ${describeResourceInSentence(data.resourceType)} has no ${info.agentDisplayName} to reset.`);
1494
+ }
1495
+ await this.updateOneById({
1496
+ id: agent.id,
1497
+ data: {
1498
+ keyHash: null,
1499
+ connectionStatus: "disconnected",
1500
+ },
1501
+ props: { isRoot: true },
1502
+ });
1503
+ logger.info(`ResourceAiAgent: the ${info.agentDisplayName} of ${info.displayName} ${data.resourceId.toString()} in project ${data.projectId.toString()} was reset${data.userId ? ` by user ${data.userId.toString()}` : ""}.`);
1504
+ const resetBy = data.userId
1505
+ ? await this.getUserMarkdownForFeed({
1506
+ userId: data.userId,
1507
+ projectId: data.projectId,
1508
+ })
1509
+ : "";
1510
+ await Service.getResourceBinding(data.resourceType).writeFeedItem(Object.assign({ resourceId: data.resourceId, projectId: data.projectId, displayColor: Blue500, feedInfoInMarkdown: `🔄 The ${info.agentDisplayName} was reset${resetBy ? ` by **${resetBy}**` : ""}. It reconnects on its own within a few minutes.`, moreInformationInMarkdown: `**Agent**: ${info.agentDisplayName} (${agent.id.toString()})` }, (data.userId ? { userId: data.userId } : {})));
1511
+ }
1512
+ /*
1513
+ * The agent rows of a resource, removed — for a resource's delete path:
1514
+ * ResourceAiAgent.resourceId has no foreign key, so nothing else removes
1515
+ * them. Jobs still targeted at them lose their target (SET NULL). Returns
1516
+ * how many rows went.
1517
+ */
1518
+ async deleteAgentsForResources(data) {
1519
+ if (!isAiResourceType(data.resourceType) || data.resourceIds.length === 0) {
1520
+ return 0;
1521
+ }
1522
+ return await this.deleteBy({
1523
+ query: Object.assign({ resourceType: data.resourceType, resourceId: QueryHelper.any(data.resourceIds.map((id) => {
1524
+ return id.toString();
1525
+ })) }, (data.projectId ? { projectId: data.projectId } : {})),
1526
+ limit: LIMIT_MAX,
1527
+ skip: 0,
1528
+ props: { isRoot: true },
1529
+ });
1530
+ }
1531
+ /*
1532
+ * The user's name as a feed link, or "" when it cannot be had (no such
1533
+ * user, or the lookup failed). Only ever wording: the action it describes
1534
+ * is already done, so a failed lookup must not fail it.
1535
+ */
1536
+ async getUserMarkdownForFeed(data) {
1537
+ try {
1538
+ return await UserService.getUserMarkdownString(data);
1539
+ }
1540
+ catch (error) {
1541
+ logger.error(`ResourceAiAgent: could not look up user ${data.userId.toString()} for a feed item: ${error}`);
1542
+ return "";
1543
+ }
1544
+ }
1545
+ /*
1546
+ * ------------------------------------------------------------------
1547
+ * Feed
1548
+ * ------------------------------------------------------------------
1549
+ */
1550
+ // What the agent may change, in the feed's words.
1551
+ static describeWriteAccess(posture) {
1552
+ if (posture.allowWrites !== true) {
1553
+ return "read-only";
1554
+ }
1555
+ return `can make changes ${Service.describeWriteScope(posture)}`;
1556
+ }
1557
+ // Which targets a writing agent may change: its globs, or any.
1558
+ static describeWriteScope(posture) {
1559
+ const targets = posture.writeTargets || [];
1560
+ return targets.length > 0
1561
+ ? `to ${targets.join(", ")}`
1562
+ : "to anything but its protected targets";
1563
+ }
1564
+ // The first successful registration of a resource's agent. Best-effort.
1565
+ async writeConnectedFeedItem(data) {
1566
+ const info = AI_RESOURCE_TYPE_INFO[data.resource.resourceType];
1567
+ const noun = describeResourceInSentence(data.resource.resourceType);
1568
+ const isInvestigationOn = data.resource.isAiInvestigationEnabled === true ||
1569
+ data.defaultsApplied.turnedOnInvestigation;
1570
+ const sentences = [
1571
+ `🤖 The ${info.agentDisplayName} connected (${Service.describeWriteAccess(data.posture)}).`,
1572
+ isInvestigationOn
1573
+ ? `AI can now use it to investigate this ${noun}.`
1574
+ : `Investigating through the agent is off for this ${noun}; turn it on on the ${noun}'s AI agent page.`,
1575
+ ];
1576
+ if (data.defaultsApplied.remediationMode) {
1577
+ sentences.push(`Fixes are set to "Ask for approval", because the agent allows changes (${RESOURCE_AI_ALLOW_WRITES_ENV}=true).`);
1578
+ }
1579
+ const reachability = data.posture.reachable
1580
+ ? "yes"
1581
+ : `no${data.posture.reachError ? ` (${data.posture.reachError})` : ""}`;
1582
+ await Service.getResourceBinding(data.resource.resourceType).writeFeedItem({
1583
+ resourceId: data.resource.id,
1584
+ projectId: data.resource.projectId,
1585
+ displayColor: Green500,
1586
+ feedInfoInMarkdown: sentences.join(" "),
1587
+ moreInformationInMarkdown: [
1588
+ `**Agent**: ${info.agentDisplayName} (${data.agentId.toString()})`,
1589
+ `**Identity**: \`${data.posture.resourceIdentifier}\``,
1590
+ `**Agent version**: ${data.agentVersion || "unknown"}`,
1591
+ `**Version**: ${data.posture.toolVersion || "not detected"}`,
1592
+ `**Reachable**: ${reachability}`,
1593
+ ].join("\n\n"),
1594
+ });
1595
+ }
1596
+ /*
1597
+ * The first-connection defaults changed a setting after the first
1598
+ * connection (the agent re-registered with write access, or its write
1599
+ * access appeared on a heartbeat). A setting never changes silently.
1600
+ */
1601
+ async writeDefaultsFeedItem(data) {
1602
+ const info = AI_RESOURCE_TYPE_INFO[data.resource.resourceType];
1603
+ const noun = describeResourceInSentence(data.resource.resourceType);
1604
+ const sentences = [];
1605
+ if (data.defaultsApplied.turnedOnInvestigation) {
1606
+ sentences.push(`AI can now use the ${info.agentDisplayName} to investigate this ${noun}.`);
1607
+ }
1608
+ if (data.defaultsApplied.remediationMode) {
1609
+ sentences.push(`The ${info.agentDisplayName} can now make changes ${Service.describeWriteScope(data.posture)}, so fixes are set to "Ask for approval".`);
1610
+ }
1611
+ sentences.push(`Nobody had chosen AI settings for this ${noun} yet; change them on the ${noun}'s AI agent page.`);
1612
+ await Service.getResourceBinding(data.resource.resourceType).writeFeedItem({
1613
+ resourceId: data.resource.id,
1614
+ projectId: data.resource.projectId,
1615
+ displayColor: Blue500,
1616
+ feedInfoInMarkdown: `🤖 ${sentences.join(" ")}`,
1617
+ });
1618
+ }
1619
+ }
1620
+ __decorate([
1621
+ CaptureSpan(),
1622
+ __metadata("design:type", Function),
1623
+ __metadata("design:paramtypes", [Object]),
1624
+ __metadata("design:returntype", Promise)
1625
+ ], Service.prototype, "findAgentForResource", null);
1626
+ __decorate([
1627
+ CaptureSpan(),
1628
+ __metadata("design:type", Function),
1629
+ __metadata("design:paramtypes", [Object]),
1630
+ __metadata("design:returntype", Promise)
1631
+ ], Service.prototype, "findOnlineAgentForResource", null);
1632
+ __decorate([
1633
+ CaptureSpan(),
1634
+ __metadata("design:type", Function),
1635
+ __metadata("design:paramtypes", [Object]),
1636
+ __metadata("design:returntype", Promise)
1637
+ ], Service.prototype, "findAgentsForResources", null);
1638
+ __decorate([
1639
+ CaptureSpan(),
1640
+ __metadata("design:type", Function),
1641
+ __metadata("design:paramtypes", [Object]),
1642
+ __metadata("design:returntype", Promise)
1643
+ ], Service.prototype, "findResource", null);
1644
+ __decorate([
1645
+ CaptureSpan(),
1646
+ __metadata("design:type", Function),
1647
+ __metadata("design:paramtypes", [Object]),
1648
+ __metadata("design:returntype", Promise)
1649
+ ], Service.prototype, "register", null);
1650
+ __decorate([
1651
+ CaptureSpan(),
1652
+ __metadata("design:type", Function),
1653
+ __metadata("design:paramtypes", [Object]),
1654
+ __metadata("design:returntype", Promise)
1655
+ ], Service.prototype, "applyFirstConnectionDefaults", null);
1656
+ __decorate([
1657
+ CaptureSpan(),
1658
+ __metadata("design:type", Function),
1659
+ __metadata("design:paramtypes", [Object]),
1660
+ __metadata("design:returntype", Promise)
1661
+ ], Service.prototype, "authenticate", null);
1662
+ __decorate([
1663
+ CaptureSpan(),
1664
+ __metadata("design:type", Function),
1665
+ __metadata("design:paramtypes", [Object]),
1666
+ __metadata("design:returntype", Promise)
1667
+ ], Service.prototype, "heartbeat", null);
1668
+ __decorate([
1669
+ CaptureSpan(),
1670
+ __metadata("design:type", Function),
1671
+ __metadata("design:paramtypes", [Object]),
1672
+ __metadata("design:returntype", Promise)
1673
+ ], Service.prototype, "markDisconnected", null);
1674
+ __decorate([
1675
+ CaptureSpan(),
1676
+ __metadata("design:type", Function),
1677
+ __metadata("design:paramtypes", [Object]),
1678
+ __metadata("design:returntype", Promise)
1679
+ ], Service.prototype, "resetAgent", null);
1680
+ __decorate([
1681
+ CaptureSpan(),
1682
+ __metadata("design:type", Function),
1683
+ __metadata("design:paramtypes", [Object]),
1684
+ __metadata("design:returntype", Promise)
1685
+ ], Service.prototype, "deleteAgentsForResources", null);
1686
+ export default new Service();
1687
+ //# sourceMappingURL=ResourceAiAgentService.js.map