@oneuptime/common 14.0.9 → 14.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (383) hide show
  1. package/Models/DatabaseModels/AutoRemediationSuggestion.ts +60 -0
  2. package/Models/DatabaseModels/CephCluster.ts +213 -0
  3. package/Models/DatabaseModels/DatabaseServer.ts +213 -0
  4. package/Models/DatabaseModels/DockerHost.ts +213 -0
  5. package/Models/DatabaseModels/DockerSwarmCluster.ts +213 -0
  6. package/Models/DatabaseModels/GlobalConfig.ts +1 -1
  7. package/Models/DatabaseModels/Host.ts +213 -0
  8. package/Models/DatabaseModels/Index.ts +2 -0
  9. package/Models/DatabaseModels/PodmanHost.ts +213 -0
  10. package/Models/DatabaseModels/ProxmoxCluster.ts +213 -0
  11. package/Models/DatabaseModels/ResourceAiAgent.ts +419 -0
  12. package/Models/DatabaseModels/RunnerJob.ts +144 -0
  13. package/Models/DatabaseModels/VMwareVCenter.ts +213 -0
  14. package/Server/API/AutoRemediationAPI.ts +392 -1
  15. package/Server/API/ResourceAiAccessAPI.ts +1669 -0
  16. package/Server/Infrastructure/Postgres/SchemaMigrations/1796300000000-AddResourceAiAgents.ts +423 -0
  17. package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +2 -0
  18. package/Server/Infrastructure/Semaphore.ts +22 -0
  19. package/Server/Middleware/TelemetryIngest.ts +15 -5
  20. package/Server/Services/AnalyticsDatabaseService.ts +45 -1
  21. package/Server/Services/AutoRemediationRuleEngineService.ts +940 -112
  22. package/Server/Services/CephClusterService.ts +109 -1
  23. package/Server/Services/DatabaseServerService.ts +116 -1
  24. package/Server/Services/DockerHostService.ts +109 -1
  25. package/Server/Services/DockerSwarmClusterService.ts +113 -1
  26. package/Server/Services/HostService.ts +126 -4
  27. package/Server/Services/MetricRecordingRuleService.ts +47 -0
  28. package/Server/Services/PodmanHostService.ts +109 -1
  29. package/Server/Services/ProxmoxClusterService.ts +110 -1
  30. package/Server/Services/ResourceAiAccessService.ts +1439 -0
  31. package/Server/Services/ResourceAiAgentJobService.ts +202 -0
  32. package/Server/Services/ResourceAiAgentService.ts +2432 -0
  33. package/Server/Services/RunnerJobService.ts +611 -4
  34. package/Server/Services/TelemetryUsageBillingService.ts +28 -0
  35. package/Server/Services/TraceRecordingRuleService.ts +33 -0
  36. package/Server/Services/VMwareVCenterService.ts +110 -1
  37. package/Server/Utils/AI/Remediation/RemediationCommandTools.ts +1434 -32
  38. package/Server/Utils/AI/Remediation/RemediationExecutionRunner.ts +935 -21
  39. package/Server/Utils/AI/Remediation/RemediationPlanRunner.ts +25 -1
  40. package/Server/Utils/AI/ResourceAccess/InfrastructureInvestigationToolkit.ts +577 -0
  41. package/Server/Utils/AI/ResourceAccess/ResourceAccessContext.ts +271 -0
  42. package/Server/Utils/AI/ResourceAccess/ResourceAccessToolNames.ts +45 -0
  43. package/Server/Utils/AI/ResourceAccess/ResourceAiAccessSettings.ts +964 -0
  44. package/Server/Utils/AI/ResourceAccess/ResourceAiDeleteCleanup.ts +333 -0
  45. package/Server/Utils/AI/ResourceAccess/ResourceCommandJobRunner.ts +873 -0
  46. package/Server/Utils/AI/SRE/AIInvestigationEngine.ts +72 -2
  47. package/Server/Utils/AI/SRE/AlertInvestigationRunner.ts +72 -5
  48. package/Server/Utils/AI/SRE/IncidentInvestigationRunner.ts +72 -5
  49. package/Server/Utils/AutoRemediation/CommandPlanExecutor.ts +396 -13
  50. package/Server/Utils/AutoRemediation/RemediationVerifier.ts +35 -2
  51. package/Server/Utils/Database/ProjectScopedReferenceValidator.ts +9 -1
  52. package/Server/Utils/SessionReplay/SessionReplayBudgetMetrics.ts +920 -0
  53. package/Server/Utils/SessionReplay/SessionReplayUsage.ts +84 -6
  54. package/Server/Utils/Workspace/MicrosoftTeams/Actions/Alert.ts +35 -15
  55. package/Server/Utils/Workspace/MicrosoftTeams/Actions/AlertEpisode.ts +33 -15
  56. package/Server/Utils/Workspace/MicrosoftTeams/Actions/Auth.ts +21 -1
  57. package/Server/Utils/Workspace/MicrosoftTeams/Actions/Incident.ts +298 -224
  58. package/Server/Utils/Workspace/MicrosoftTeams/Actions/IncidentEpisode.ts +35 -15
  59. package/Server/Utils/Workspace/MicrosoftTeams/Actions/ScheduledMaintenance.ts +389 -175
  60. package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.ts +366 -143
  61. package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsActivityDeduplicator.ts +163 -0
  62. package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsCardChoices.ts +396 -0
  63. package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsCreateCommands.ts +418 -0
  64. package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsMessageSize.ts +152 -0
  65. package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsReplies.ts +251 -0
  66. package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsTimezone.ts +214 -0
  67. package/Tests/App/Dashboard/ClusterAccessNotice.test.tsx +93 -0
  68. package/Tests/App/Dashboard/DatabaseDocumentationMarkdown.test.ts +18 -6
  69. package/Tests/App/Dashboard/InvestigationInfrastructureTools.test.tsx +506 -0
  70. package/Tests/App/Dashboard/RemediationSuggestionCardDescription.test.tsx +209 -0
  71. package/Tests/App/Dashboard/RemediationSuggestionCardResource.test.tsx +317 -0
  72. package/Tests/App/Dashboard/ResourceAiAccessSettingsUtil.test.ts +921 -0
  73. package/Tests/App/Dashboard/ResourceAiAgentInstall.test.ts +860 -0
  74. package/Tests/App/Dashboard/ResourceAiAgentPage.test.tsx +1721 -0
  75. package/Tests/App/Dashboard/ResourceAiAgentStatus.test.ts +1002 -0
  76. package/Tests/App/Dashboard/ResourceAiInsightsPage.test.tsx +931 -0
  77. package/Tests/App/Dashboard/ResourceAiNavigation.test.tsx +575 -0
  78. package/Tests/App/Dashboard/RunbookStepTypeMaps.test.ts +38 -7
  79. package/Tests/Models/DatabaseModels/DatabaseServerModels.test.ts +33 -1
  80. package/Tests/Models/DatabaseModels/ResourceAiAccessColumns.test.ts +738 -0
  81. package/Tests/Models/DatabaseModels/ResourceAiAgentModel.test.ts +842 -0
  82. package/Tests/Server/API/AutoRemediationApproveResourceRound.test.ts +835 -0
  83. package/Tests/Server/API/ResourceAiAccessAPI.test.ts +2730 -0
  84. package/Tests/Server/Infrastructure/Postgres/AddDatabaseServerTablesMigration.test.ts +60 -0
  85. package/Tests/Server/Infrastructure/Postgres/AddResourceAiAgentsMigration.test.ts +659 -0
  86. package/Tests/Server/Infrastructure/SemaphoreMutex.test.ts +31 -0
  87. package/Tests/Server/Middleware/TelemetryIngestBrowserKey.test.ts +63 -5
  88. package/Tests/Server/Middleware/TelemetryIngestKubernetesAgentRunnerPinnedKey.test.ts +103 -5
  89. package/Tests/Server/Middleware/TelemetryIngestKubernetesAgentRunnerRateLimit.test.ts +19 -1
  90. package/Tests/Server/Services/AutoRemediationResourceRuleEngine.test.ts +1279 -0
  91. package/Tests/Server/Services/DatabaseServerService.test.ts +55 -0
  92. package/Tests/Server/Services/GroupTelemetryUsageExcludeNames.test.ts +299 -0
  93. package/Tests/Server/Services/HostServiceFindOrCreateMemo.test.ts +44 -0
  94. package/Tests/Server/Services/MonitorProbeServiceIntervalScheduling.test.ts +45 -6
  95. package/Tests/Server/Services/RecordingRuleReservedMetricName.test.ts +171 -0
  96. package/Tests/Server/Services/ResourceAiAccessChangeAuthorization.test.ts +256 -0
  97. package/Tests/Server/Services/ResourceAiAccessService.test.ts +1373 -0
  98. package/Tests/Server/Services/ResourceAiAgentJobService.test.ts +375 -0
  99. package/Tests/Server/Services/ResourceAiAgentServiceHelpers.test.ts +1114 -0
  100. package/Tests/Server/Services/ResourceAiAgentServiceLifecycle.test.ts +1050 -0
  101. package/Tests/Server/Services/ResourceAiAgentServiceRegister.test.ts +2251 -0
  102. package/Tests/Server/Services/ResourceAiSettingsCreate.test.ts +373 -0
  103. package/Tests/Server/Services/ResourceAiSettingsPermission.test.ts +1042 -0
  104. package/Tests/Server/Services/ResourceServiceDeleteCleansUpAi.test.ts +319 -0
  105. package/Tests/Server/Services/RunnerJobEnqueueKubectl.test.ts +105 -0
  106. package/Tests/Server/Services/RunnerJobEnqueueResourceCommand.test.ts +986 -0
  107. package/Tests/Server/Services/RunnerJobResourceCommandLane.test.ts +211 -0
  108. package/Tests/Server/Services/RunnerJobResourceCommandTimeoutAndRedaction.test.ts +352 -0
  109. package/Tests/Server/Services/TelemetryUsageBillingSloExclusion.test.ts +218 -0
  110. package/Tests/Server/TestingUtils/Services/FakeRunnerJobCount.ts +145 -0
  111. package/Tests/Server/Utils/AI/InvestigationInfrastructureAccessWiring.test.ts +453 -0
  112. package/Tests/Server/Utils/AI/InvestigationInfrastructureReport.test.ts +721 -0
  113. package/Tests/Server/Utils/AI/RemediationCommandTools.test.ts +94 -1
  114. package/Tests/Server/Utils/AI/RemediationCommandToolsResource.test.ts +1530 -0
  115. package/Tests/Server/Utils/AI/RemediationExecutionRunnerResourceMode.test.ts +1249 -0
  116. package/Tests/Server/Utils/AI/RemediationPlanRunner.test.ts +117 -0
  117. package/Tests/Server/Utils/AI/RemediationResourceCopyParity.test.ts +463 -0
  118. package/Tests/Server/Utils/AI/ResourceAccess/InfrastructureInvestigationToolkit.test.ts +722 -0
  119. package/Tests/Server/Utils/AI/ResourceAccess/ResourceAccessContext.test.ts +266 -0
  120. package/Tests/Server/Utils/AI/ResourceAccess/ResourceAiAccessSettings.test.ts +1220 -0
  121. package/Tests/Server/Utils/AI/ResourceAccess/ResourceAiDeleteCleanup.test.ts +569 -0
  122. package/Tests/Server/Utils/AI/ResourceAccess/ResourceCommandJobRunner.test.ts +830 -0
  123. package/Tests/Server/Utils/AutoRemediation/CommandPlanExecutorResource.test.ts +717 -0
  124. package/Tests/Server/Utils/AutoRemediation/RemediationVerifierResourceFollowUp.test.ts +338 -0
  125. package/Tests/Server/Utils/Monitor/Criteria/SessionReplayBudgetTemplateCriteria.test.ts +422 -0
  126. package/Tests/Server/Utils/SessionReplay/SessionReplayBudgetMetrics.test.ts +1647 -0
  127. package/Tests/Server/Utils/SessionReplay/SessionReplayUsage.test.ts +143 -1
  128. package/Tests/Server/Utils/Telemetry/TelemetryIngestionKeyGuard.test.ts +33 -3
  129. package/Tests/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsAccountNotLinked.test.ts +1093 -0
  130. package/Tests/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsActivityDeduplicator.test.ts +1049 -0
  131. package/Tests/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsCardChoices.test.ts +1676 -0
  132. package/Tests/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsCreateCards.test.ts +2884 -0
  133. package/Tests/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsCreateCommands.test.ts +2490 -0
  134. package/Tests/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsCreateSubmit.test.ts +2293 -0
  135. package/Tests/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsCreateSubmitServerTimezone.test.ts +386 -0
  136. package/Tests/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsMessageSize.test.ts +1477 -0
  137. package/Tests/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsReplies.test.ts +1967 -0
  138. package/Tests/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsStripHtmlTags.test.ts +92 -0
  139. package/Tests/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsSubmittedFormRemoval.test.ts +1819 -0
  140. package/Tests/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsTimezone.test.ts +1033 -0
  141. package/Tests/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsTimezoneServerZone.test.ts +610 -0
  142. package/Tests/Server/Utils/Workspace/MicrosoftTeamsBotMessageHandling.test.ts +2610 -0
  143. package/Tests/Server/Utils/Workspace/MicrosoftTeamsCreateCommandsEndToEnd.test.ts +4672 -0
  144. package/Tests/Server/Utils/Workspace/WorkspaceCreateProjectReferences.test.ts +190 -65
  145. package/Tests/Types/AutoRemediation/AiRemediationCommandPlan.test.ts +10 -4
  146. package/Tests/Types/AutoRemediation/AiRemediationCommandPlanResourceCommand.test.ts +305 -0
  147. package/Tests/Types/Monitor/Recommendation/MonitorRecommendationCatalog.test.ts +277 -13
  148. package/Tests/Types/Monitor/Recommendation/MonitorRecommendationUtil.test.ts +113 -0
  149. package/Tests/Types/Monitor/RumAlertTemplates.test.ts +773 -2
  150. package/Tests/Types/ResourceAiAgent/AiResourceType.test.ts +419 -0
  151. package/Tests/Types/ResourceAiAgent/ResourceAiAccess.test.ts +517 -0
  152. package/Tests/Types/Runbook/RunbookStepType.test.ts +147 -8
  153. package/Tests/UI/Rum/RecordingHealthDashboard.test.tsx +769 -1
  154. package/Tests/Utils/AiRemediation/Resource/CephCommandPolicy.test.ts +1653 -0
  155. package/Tests/Utils/AiRemediation/Resource/CephOutputRedaction.test.ts +204 -0
  156. package/Tests/Utils/AiRemediation/Resource/DatabaseCommandPolicy.test.ts +1077 -0
  157. package/Tests/Utils/AiRemediation/Resource/DatabaseDiagnosticCatalog.test.ts +558 -0
  158. package/Tests/Utils/AiRemediation/Resource/DatabaseQueryRedactor.test.ts +834 -0
  159. package/Tests/Utils/AiRemediation/Resource/DockerCliGrammar.test.ts +747 -0
  160. package/Tests/Utils/AiRemediation/Resource/DockerEngineCommandPolicy.test.ts +1259 -0
  161. package/Tests/Utils/AiRemediation/Resource/DockerOutputRedaction.test.ts +386 -0
  162. package/Tests/Utils/AiRemediation/Resource/DockerSwarmCommandPolicy.test.ts +782 -0
  163. package/Tests/Utils/AiRemediation/Resource/GovcCommandPolicy.test.ts +2259 -0
  164. package/Tests/Utils/AiRemediation/Resource/HostCommandPolicy.test.ts +2019 -0
  165. package/Tests/Utils/AiRemediation/Resource/ProxmoxCommandPolicy.test.ts +2497 -0
  166. package/Tests/Utils/AiRemediation/Resource/ResourceCommandPolicy.test.ts +1305 -0
  167. package/Tests/Utils/AiRemediation/Resource/ResourceCommandPolicyCore.test.ts +585 -0
  168. package/Tests/Utils/AiRemediation/Resource/ResourceOutputRedactor.test.ts +334 -0
  169. package/Tests/Utils/AiRemediation/Resource/ResourceOutputRedactorCopyParity.test.ts +98 -0
  170. package/Tests/Utils/AiRemediation/Resource/ResourcePolicyImportClosure.test.ts +391 -0
  171. package/Tests/Utils/AiRemediation/ResourceAiAgentPolicyCopyParity.test.ts +497 -0
  172. package/Tests/Utils/SessionReplay/SessionReplayBudgetMetricType.test.ts +383 -0
  173. package/Types/AI/ResourceAiAccessApi.ts +140 -0
  174. package/Types/AI/ResourceAiAccessPermissions.ts +126 -0
  175. package/Types/AutoRemediation/AiRemediationCommandPlan.ts +183 -2
  176. package/Types/Monitor/Recommendation/MonitorRecommendationCatalog.ts +55 -22
  177. package/Types/Monitor/Recommendation/MonitorRecommendationTypes.ts +35 -3
  178. package/Types/Monitor/RumAlertTemplates.ts +351 -4
  179. package/Types/ResourceAiAgent/AiResourceType.ts +310 -0
  180. package/Types/ResourceAiAgent/ResourceAiAccess.ts +574 -0
  181. package/Types/Rum/SessionReplayBudgetMetricType.ts +47 -0
  182. package/Types/Runbook/RunbookStepType.ts +29 -0
  183. package/Types/Telemetry/TelemetryIngestSurface.ts +14 -2
  184. package/Utils/AI/InvestigationReport.ts +121 -15
  185. package/Utils/AiRemediation/Resource/CephCommandPolicy.ts +1936 -0
  186. package/Utils/AiRemediation/Resource/DatabaseCommandPolicy.ts +166 -0
  187. package/Utils/AiRemediation/Resource/DatabaseDiagnosticCatalog.ts +1532 -0
  188. package/Utils/AiRemediation/Resource/DatabaseQueryRedactor.ts +1394 -0
  189. package/Utils/AiRemediation/Resource/DockerCliGrammar.ts +1839 -0
  190. package/Utils/AiRemediation/Resource/DockerEngineCommandPolicy.ts +490 -0
  191. package/Utils/AiRemediation/Resource/DockerSwarmCommandPolicy.ts +687 -0
  192. package/Utils/AiRemediation/Resource/GovcCommandPolicy.ts +2096 -0
  193. package/Utils/AiRemediation/Resource/HostCommandPolicy.ts +2982 -0
  194. package/Utils/AiRemediation/Resource/ProxmoxCommandPolicy.ts +1679 -0
  195. package/Utils/AiRemediation/Resource/ResourceCommandPolicy.ts +851 -0
  196. package/Utils/AiRemediation/Resource/ResourceCommandPolicyCore.ts +593 -0
  197. package/Utils/AiRemediation/Resource/ResourceOutputRedactor.ts +2812 -0
  198. package/Utils/SessionReplay/SessionReplayBudgetMetricType.ts +184 -0
  199. package/build/dist/Models/DatabaseModels/AutoRemediationSuggestion.js +62 -0
  200. package/build/dist/Models/DatabaseModels/AutoRemediationSuggestion.js.map +1 -1
  201. package/build/dist/Models/DatabaseModels/CephCluster.js +219 -0
  202. package/build/dist/Models/DatabaseModels/CephCluster.js.map +1 -1
  203. package/build/dist/Models/DatabaseModels/DatabaseServer.js +219 -0
  204. package/build/dist/Models/DatabaseModels/DatabaseServer.js.map +1 -1
  205. package/build/dist/Models/DatabaseModels/DockerHost.js +219 -0
  206. package/build/dist/Models/DatabaseModels/DockerHost.js.map +1 -1
  207. package/build/dist/Models/DatabaseModels/DockerSwarmCluster.js +219 -0
  208. package/build/dist/Models/DatabaseModels/DockerSwarmCluster.js.map +1 -1
  209. package/build/dist/Models/DatabaseModels/GlobalConfig.js +1 -1
  210. package/build/dist/Models/DatabaseModels/GlobalConfig.js.map +1 -1
  211. package/build/dist/Models/DatabaseModels/Host.js +219 -0
  212. package/build/dist/Models/DatabaseModels/Host.js.map +1 -1
  213. package/build/dist/Models/DatabaseModels/Index.js +2 -0
  214. package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
  215. package/build/dist/Models/DatabaseModels/PodmanHost.js +219 -0
  216. package/build/dist/Models/DatabaseModels/PodmanHost.js.map +1 -1
  217. package/build/dist/Models/DatabaseModels/ProxmoxCluster.js +219 -0
  218. package/build/dist/Models/DatabaseModels/ProxmoxCluster.js.map +1 -1
  219. package/build/dist/Models/DatabaseModels/ResourceAiAgent.js +439 -0
  220. package/build/dist/Models/DatabaseModels/ResourceAiAgent.js.map +1 -0
  221. package/build/dist/Models/DatabaseModels/RunnerJob.js +145 -0
  222. package/build/dist/Models/DatabaseModels/RunnerJob.js.map +1 -1
  223. package/build/dist/Models/DatabaseModels/VMwareVCenter.js +219 -0
  224. package/build/dist/Models/DatabaseModels/VMwareVCenter.js.map +1 -1
  225. package/build/dist/Server/API/AutoRemediationAPI.js +231 -1
  226. package/build/dist/Server/API/AutoRemediationAPI.js.map +1 -1
  227. package/build/dist/Server/API/ResourceAiAccessAPI.js +1119 -0
  228. package/build/dist/Server/API/ResourceAiAccessAPI.js.map +1 -0
  229. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1796300000000-AddResourceAiAgents.js +168 -0
  230. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1796300000000-AddResourceAiAgents.js.map +1 -0
  231. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +2 -0
  232. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
  233. package/build/dist/Server/Infrastructure/Semaphore.js +6 -0
  234. package/build/dist/Server/Infrastructure/Semaphore.js.map +1 -1
  235. package/build/dist/Server/Middleware/TelemetryIngest.js +12 -5
  236. package/build/dist/Server/Middleware/TelemetryIngest.js.map +1 -1
  237. package/build/dist/Server/Services/AnalyticsDatabaseService.js +26 -1
  238. package/build/dist/Server/Services/AnalyticsDatabaseService.js.map +1 -1
  239. package/build/dist/Server/Services/AutoRemediationRuleEngineService.js +601 -3
  240. package/build/dist/Server/Services/AutoRemediationRuleEngineService.js.map +1 -1
  241. package/build/dist/Server/Services/CephClusterService.js +104 -0
  242. package/build/dist/Server/Services/CephClusterService.js.map +1 -1
  243. package/build/dist/Server/Services/DatabaseServerService.js +99 -0
  244. package/build/dist/Server/Services/DatabaseServerService.js.map +1 -1
  245. package/build/dist/Server/Services/DockerHostService.js +104 -0
  246. package/build/dist/Server/Services/DockerHostService.js.map +1 -1
  247. package/build/dist/Server/Services/DockerSwarmClusterService.js +104 -0
  248. package/build/dist/Server/Services/DockerSwarmClusterService.js.map +1 -1
  249. package/build/dist/Server/Services/HostService.js +114 -2
  250. package/build/dist/Server/Services/HostService.js.map +1 -1
  251. package/build/dist/Server/Services/MetricRecordingRuleService.js +46 -0
  252. package/build/dist/Server/Services/MetricRecordingRuleService.js.map +1 -1
  253. package/build/dist/Server/Services/PodmanHostService.js +104 -0
  254. package/build/dist/Server/Services/PodmanHostService.js.map +1 -1
  255. package/build/dist/Server/Services/ProxmoxClusterService.js +104 -0
  256. package/build/dist/Server/Services/ProxmoxClusterService.js.map +1 -1
  257. package/build/dist/Server/Services/ResourceAiAccessService.js +1028 -0
  258. package/build/dist/Server/Services/ResourceAiAccessService.js.map +1 -0
  259. package/build/dist/Server/Services/ResourceAiAgentJobService.js +173 -0
  260. package/build/dist/Server/Services/ResourceAiAgentJobService.js.map +1 -0
  261. package/build/dist/Server/Services/ResourceAiAgentService.js +1687 -0
  262. package/build/dist/Server/Services/ResourceAiAgentService.js.map +1 -0
  263. package/build/dist/Server/Services/RunnerJobService.js +344 -5
  264. package/build/dist/Server/Services/RunnerJobService.js.map +1 -1
  265. package/build/dist/Server/Services/TelemetryUsageBillingService.js +26 -0
  266. package/build/dist/Server/Services/TelemetryUsageBillingService.js.map +1 -1
  267. package/build/dist/Server/Services/TraceRecordingRuleService.js +37 -0
  268. package/build/dist/Server/Services/TraceRecordingRuleService.js.map +1 -1
  269. package/build/dist/Server/Services/VMwareVCenterService.js +104 -0
  270. package/build/dist/Server/Services/VMwareVCenterService.js.map +1 -1
  271. package/build/dist/Server/Utils/AI/Remediation/RemediationCommandTools.js +1029 -30
  272. package/build/dist/Server/Utils/AI/Remediation/RemediationCommandTools.js.map +1 -1
  273. package/build/dist/Server/Utils/AI/Remediation/RemediationExecutionRunner.js +633 -28
  274. package/build/dist/Server/Utils/AI/Remediation/RemediationExecutionRunner.js.map +1 -1
  275. package/build/dist/Server/Utils/AI/Remediation/RemediationPlanRunner.js +21 -1
  276. package/build/dist/Server/Utils/AI/Remediation/RemediationPlanRunner.js.map +1 -1
  277. package/build/dist/Server/Utils/AI/ResourceAccess/InfrastructureInvestigationToolkit.js +330 -0
  278. package/build/dist/Server/Utils/AI/ResourceAccess/InfrastructureInvestigationToolkit.js.map +1 -0
  279. package/build/dist/Server/Utils/AI/ResourceAccess/ResourceAccessContext.js +160 -0
  280. package/build/dist/Server/Utils/AI/ResourceAccess/ResourceAccessContext.js.map +1 -0
  281. package/build/dist/Server/Utils/AI/ResourceAccess/ResourceAccessToolNames.js +33 -0
  282. package/build/dist/Server/Utils/AI/ResourceAccess/ResourceAccessToolNames.js.map +1 -0
  283. package/build/dist/Server/Utils/AI/ResourceAccess/ResourceAiAccessSettings.js +640 -0
  284. package/build/dist/Server/Utils/AI/ResourceAccess/ResourceAiAccessSettings.js.map +1 -0
  285. package/build/dist/Server/Utils/AI/ResourceAccess/ResourceAiDeleteCleanup.js +226 -0
  286. package/build/dist/Server/Utils/AI/ResourceAccess/ResourceAiDeleteCleanup.js.map +1 -0
  287. package/build/dist/Server/Utils/AI/ResourceAccess/ResourceCommandJobRunner.js +600 -0
  288. package/build/dist/Server/Utils/AI/ResourceAccess/ResourceCommandJobRunner.js.map +1 -0
  289. package/build/dist/Server/Utils/AI/SRE/AIInvestigationEngine.js +50 -4
  290. package/build/dist/Server/Utils/AI/SRE/AIInvestigationEngine.js.map +1 -1
  291. package/build/dist/Server/Utils/AI/SRE/AlertInvestigationRunner.js +55 -4
  292. package/build/dist/Server/Utils/AI/SRE/AlertInvestigationRunner.js.map +1 -1
  293. package/build/dist/Server/Utils/AI/SRE/IncidentInvestigationRunner.js +55 -4
  294. package/build/dist/Server/Utils/AI/SRE/IncidentInvestigationRunner.js.map +1 -1
  295. package/build/dist/Server/Utils/AutoRemediation/CommandPlanExecutor.js +290 -13
  296. package/build/dist/Server/Utils/AutoRemediation/CommandPlanExecutor.js.map +1 -1
  297. package/build/dist/Server/Utils/AutoRemediation/RemediationVerifier.js +29 -1
  298. package/build/dist/Server/Utils/AutoRemediation/RemediationVerifier.js.map +1 -1
  299. package/build/dist/Server/Utils/Database/ProjectScopedReferenceValidator.js +9 -1
  300. package/build/dist/Server/Utils/Database/ProjectScopedReferenceValidator.js.map +1 -1
  301. package/build/dist/Server/Utils/SessionReplay/SessionReplayBudgetMetrics.js +627 -0
  302. package/build/dist/Server/Utils/SessionReplay/SessionReplayBudgetMetrics.js.map +1 -0
  303. package/build/dist/Server/Utils/SessionReplay/SessionReplayUsage.js +60 -5
  304. package/build/dist/Server/Utils/SessionReplay/SessionReplayUsage.js.map +1 -1
  305. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Alert.js +19 -15
  306. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Alert.js.map +1 -1
  307. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/AlertEpisode.js +19 -15
  308. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/AlertEpisode.js.map +1 -1
  309. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Auth.js +17 -1
  310. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Auth.js.map +1 -1
  311. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Incident.js +183 -209
  312. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Incident.js.map +1 -1
  313. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/IncidentEpisode.js +19 -15
  314. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/IncidentEpisode.js.map +1 -1
  315. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/ScheduledMaintenance.js +233 -167
  316. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/ScheduledMaintenance.js.map +1 -1
  317. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js +263 -110
  318. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js.map +1 -1
  319. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsActivityDeduplicator.js +129 -0
  320. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsActivityDeduplicator.js.map +1 -0
  321. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsCardChoices.js +266 -0
  322. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsCardChoices.js.map +1 -0
  323. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsCreateCommands.js +258 -0
  324. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsCreateCommands.js.map +1 -0
  325. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsMessageSize.js +104 -0
  326. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsMessageSize.js.map +1 -0
  327. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsReplies.js +183 -0
  328. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsReplies.js.map +1 -0
  329. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsTimezone.js +123 -0
  330. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsTimezone.js.map +1 -0
  331. package/build/dist/Types/AI/ResourceAiAccessApi.js +30 -0
  332. package/build/dist/Types/AI/ResourceAiAccessApi.js.map +1 -0
  333. package/build/dist/Types/AI/ResourceAiAccessPermissions.js +98 -0
  334. package/build/dist/Types/AI/ResourceAiAccessPermissions.js.map +1 -0
  335. package/build/dist/Types/AutoRemediation/AiRemediationCommandPlan.js +116 -29
  336. package/build/dist/Types/AutoRemediation/AiRemediationCommandPlan.js.map +1 -1
  337. package/build/dist/Types/Monitor/Recommendation/MonitorRecommendationCatalog.js +47 -21
  338. package/build/dist/Types/Monitor/Recommendation/MonitorRecommendationCatalog.js.map +1 -1
  339. package/build/dist/Types/Monitor/Recommendation/MonitorRecommendationTypes.js +5 -0
  340. package/build/dist/Types/Monitor/Recommendation/MonitorRecommendationTypes.js.map +1 -1
  341. package/build/dist/Types/Monitor/RumAlertTemplates.js +199 -3
  342. package/build/dist/Types/Monitor/RumAlertTemplates.js.map +1 -1
  343. package/build/dist/Types/ResourceAiAgent/AiResourceType.js +242 -0
  344. package/build/dist/Types/ResourceAiAgent/AiResourceType.js.map +1 -0
  345. package/build/dist/Types/ResourceAiAgent/ResourceAiAccess.js +275 -0
  346. package/build/dist/Types/ResourceAiAgent/ResourceAiAccess.js.map +1 -0
  347. package/build/dist/Types/Rum/SessionReplayBudgetMetricType.js +45 -0
  348. package/build/dist/Types/Rum/SessionReplayBudgetMetricType.js.map +1 -0
  349. package/build/dist/Types/Runbook/RunbookStepType.js +27 -0
  350. package/build/dist/Types/Runbook/RunbookStepType.js.map +1 -1
  351. package/build/dist/Types/Telemetry/TelemetryIngestSurface.js +13 -2
  352. package/build/dist/Types/Telemetry/TelemetryIngestSurface.js.map +1 -1
  353. package/build/dist/Utils/AI/InvestigationReport.js +71 -11
  354. package/build/dist/Utils/AI/InvestigationReport.js.map +1 -1
  355. package/build/dist/Utils/AiRemediation/Resource/CephCommandPolicy.js +1462 -0
  356. package/build/dist/Utils/AiRemediation/Resource/CephCommandPolicy.js.map +1 -0
  357. package/build/dist/Utils/AiRemediation/Resource/DatabaseCommandPolicy.js +122 -0
  358. package/build/dist/Utils/AiRemediation/Resource/DatabaseCommandPolicy.js.map +1 -0
  359. package/build/dist/Utils/AiRemediation/Resource/DatabaseDiagnosticCatalog.js +1139 -0
  360. package/build/dist/Utils/AiRemediation/Resource/DatabaseDiagnosticCatalog.js.map +1 -0
  361. package/build/dist/Utils/AiRemediation/Resource/DatabaseQueryRedactor.js +1060 -0
  362. package/build/dist/Utils/AiRemediation/Resource/DatabaseQueryRedactor.js.map +1 -0
  363. package/build/dist/Utils/AiRemediation/Resource/DockerCliGrammar.js +1301 -0
  364. package/build/dist/Utils/AiRemediation/Resource/DockerCliGrammar.js.map +1 -0
  365. package/build/dist/Utils/AiRemediation/Resource/DockerEngineCommandPolicy.js +370 -0
  366. package/build/dist/Utils/AiRemediation/Resource/DockerEngineCommandPolicy.js.map +1 -0
  367. package/build/dist/Utils/AiRemediation/Resource/DockerSwarmCommandPolicy.js +498 -0
  368. package/build/dist/Utils/AiRemediation/Resource/DockerSwarmCommandPolicy.js.map +1 -0
  369. package/build/dist/Utils/AiRemediation/Resource/GovcCommandPolicy.js +1565 -0
  370. package/build/dist/Utils/AiRemediation/Resource/GovcCommandPolicy.js.map +1 -0
  371. package/build/dist/Utils/AiRemediation/Resource/HostCommandPolicy.js +2206 -0
  372. package/build/dist/Utils/AiRemediation/Resource/HostCommandPolicy.js.map +1 -0
  373. package/build/dist/Utils/AiRemediation/Resource/ProxmoxCommandPolicy.js +1129 -0
  374. package/build/dist/Utils/AiRemediation/Resource/ProxmoxCommandPolicy.js.map +1 -0
  375. package/build/dist/Utils/AiRemediation/Resource/ResourceCommandPolicy.js +565 -0
  376. package/build/dist/Utils/AiRemediation/Resource/ResourceCommandPolicy.js.map +1 -0
  377. package/build/dist/Utils/AiRemediation/Resource/ResourceCommandPolicyCore.js +408 -0
  378. package/build/dist/Utils/AiRemediation/Resource/ResourceCommandPolicyCore.js.map +1 -0
  379. package/build/dist/Utils/AiRemediation/Resource/ResourceOutputRedactor.js +1910 -0
  380. package/build/dist/Utils/AiRemediation/Resource/ResourceOutputRedactor.js.map +1 -0
  381. package/build/dist/Utils/SessionReplay/SessionReplayBudgetMetricType.js +160 -0
  382. package/build/dist/Utils/SessionReplay/SessionReplayBudgetMetricType.js.map +1 -0
  383. package/package.json +1 -1
@@ -35,7 +35,7 @@ import { truncateToLength } from "../../Database/TruncateColumnValue";
35
35
  import { CloudAdapter, ConfigurationBotFrameworkAuthentication, TeamsActivityHandler, TeamsInfo, MessageFactory, } from "botbuilder";
36
36
  import MicrosoftTeamsServiceUrl from "./MicrosoftTeamsServiceUrl";
37
37
  // Teams action handlers and types
38
- import MicrosoftTeamsAuthAction from "./Actions/Auth";
38
+ import MicrosoftTeamsAuthAction, { MicrosoftTeamsAccountNotLinkedException, } from "./Actions/Auth";
39
39
  import MicrosoftTeamsIncidentActions from "./Actions/Incident";
40
40
  import MicrosoftTeamsAlertActions from "./Actions/Alert";
41
41
  import MicrosoftTeamsAlertEpisodeActions from "./Actions/AlertEpisode";
@@ -43,6 +43,10 @@ import MicrosoftTeamsIncidentEpisodeActions from "./Actions/IncidentEpisode";
43
43
  import MicrosoftTeamsMonitorActions from "./Actions/Monitor";
44
44
  import MicrosoftTeamsScheduledMaintenanceActions from "./Actions/ScheduledMaintenance";
45
45
  import MicrosoftTeamsOnCallDutyActions from "./Actions/OnCallDutyPolicy";
46
+ import MicrosoftTeamsActivityDeduplicator from "./MicrosoftTeamsActivityDeduplicator";
47
+ import MicrosoftTeamsCreateCommands from "./MicrosoftTeamsCreateCommands";
48
+ import MicrosoftTeamsMessageSize from "./MicrosoftTeamsMessageSize";
49
+ import MicrosoftTeamsReplies from "./MicrosoftTeamsReplies";
46
50
  import WorkspaceActionAuthorization from "../WorkspaceActionAuthorization";
47
51
  import NotAuthorizedException from "../../../../Types/Exception/NotAuthorizedException";
48
52
  import AIService, { AI_DISABLED_MESSAGE } from "../../../Services/AIService";
@@ -123,6 +127,11 @@ const MICROSOFT_TEAMS_ROSTER_ERROR_FRAGMENTS = [
123
127
  ];
124
128
  // Maximum number of pages to fetch when paginating teams
125
129
  const MICROSOFT_TEAMS_MAX_PAGES = 500;
130
+ // Bot commands that open a form; text after them becomes the form's title.
131
+ const CREATE_INCIDENT_COMMAND = "create incident";
132
+ const CREATE_MAINTENANCE_COMMAND = "create maintenance";
133
+ // How many affected monitors a "show ..." reply names for one item.
134
+ const MICROSOFT_TEAMS_MAX_AFFECTED_MONITOR_NAMES = 10;
126
135
  /*
127
136
  * Hosts that may receive a Teams incoming webhook. Legacy Connector webhooks
128
137
  * use Office domains. Teams Workflows use regional logic.azure.com hosts, and
@@ -1965,7 +1974,7 @@ class MicrosoftTeamsUtil extends WorkspaceBase {
1965
1974
  }
1966
1975
  // Bot Framework specific methods
1967
1976
  static async handleBotMessageActivity(data) {
1968
- var _a, _b, _c, _d;
1977
+ var _a, _b, _c, _d, _e;
1969
1978
  // Handle direct messages to bot or @mentions via Bot Framework
1970
1979
  const messageText = data.activity["text"] || "";
1971
1980
  const possibleActionValue = data.activity["value"] || {};
@@ -2024,18 +2033,8 @@ class MicrosoftTeamsUtil extends WorkspaceBase {
2024
2033
  onlyIfMissingOrStale: true,
2025
2034
  });
2026
2035
  }
2027
- // If this is actually an Adaptive Card submit wrapped as a message, route to invoke handler
2028
- if (possibleActionValue["action"] ||
2029
- ((_b = possibleActionValue["data"]) === null || _b === void 0 ? void 0 : _b["action"])) {
2030
- logger.debug("Message activity contains action payload; routing to invoke handler");
2031
- await this.handleBotInvokeActivity({
2032
- activity: data.activity,
2033
- turnContext: data.turnContext,
2034
- });
2035
- return;
2036
- }
2037
2036
  // Check if the bot was mentioned
2038
- const recipientId = (_c = data.activity["recipient"]) === null || _c === void 0 ? void 0 : _c["id"];
2037
+ const recipientId = (_b = data.activity["recipient"]) === null || _b === void 0 ? void 0 : _b["id"];
2039
2038
  const conversationType = conversation["conversationType"] || "";
2040
2039
  const isDirectMessage = conversationType === "personal";
2041
2040
  const isMentioned = entities.some((entity) => {
@@ -2043,29 +2042,34 @@ class MicrosoftTeamsUtil extends WorkspaceBase {
2043
2042
  return (entity["type"] === "mention" &&
2044
2043
  ((_a = entity["mentioned"]) === null || _a === void 0 ? void 0 : _a["id"]) === recipientId);
2045
2044
  });
2046
- // Only respond if it's a direct message or the bot was mentioned
2047
- if (!isDirectMessage && !isMentioned) {
2045
+ // An Adaptive Card submit arrives as a message whose value names the action.
2046
+ const isCardSubmit = Boolean(possibleActionValue["action"] ||
2047
+ ((_c = possibleActionValue["data"]) === null || _c === void 0 ? void 0 : _c["action"]));
2048
+ // Only respond to card submits, direct messages and @mentions.
2049
+ if (!isCardSubmit && !isDirectMessage && !isMentioned) {
2048
2050
  logger.debug("Bot not mentioned in channel message, ignoring");
2049
2051
  return;
2050
2052
  }
2051
- // Extract tenant ID to get project ID
2052
- const tenantId = (_d = channelData["tenant"]) === null || _d === void 0 ? void 0 : _d["id"];
2053
- if (!tenantId) {
2054
- logger.error("Tenant ID not found in channelData");
2055
- await data.turnContext.sendActivity("Sorry, I couldn't identify your organization. Please try again later.");
2053
+ /*
2054
+ * Teams delivers an activity again when the first delivery was slow or
2055
+ * failed. Handling it twice sends every reply twice and creates a
2056
+ * submitted incident twice, so only the first delivery is handled.
2057
+ */
2058
+ if (!(await MicrosoftTeamsActivityDeduplicator.claim(data.activity))) {
2059
+ logger.debug("Microsoft Teams delivered this activity before; ignoring the repeat", {
2060
+ activityId: data.activity["id"] || "",
2061
+ });
2056
2062
  return;
2057
2063
  }
2058
- // Get project auth by tenant ID
2059
- const tenantResolution = await this.resolveProjectByTenantId({
2060
- tenantId: tenantId,
2061
- });
2062
- if (!tenantResolution.projectAuth ||
2063
- !tenantResolution.projectAuth.projectId) {
2064
- await data.turnContext.sendActivity(this.getTenantResolutionFailureMessage(tenantResolution));
2064
+ // If this is actually an Adaptive Card submit wrapped as a message, route to invoke handler
2065
+ if (isCardSubmit) {
2066
+ logger.debug("Message activity contains action payload; routing to invoke handler");
2067
+ await this.handleBotInvokeActivity({
2068
+ activity: data.activity,
2069
+ turnContext: data.turnContext,
2070
+ });
2065
2071
  return;
2066
2072
  }
2067
- const projectId = tenantResolution.projectAuth.projectId;
2068
- logger.debug(`Found project ID: ${projectId.toString()} for tenant ID: ${tenantId}`);
2069
2073
  // Clean the message text by removing bot mentions
2070
2074
  const cleanText = messageText
2071
2075
  .replace(/<at[^>]*>.*?<\/at>/g, "")
@@ -2079,62 +2083,98 @@ class MicrosoftTeamsUtil extends WorkspaceBase {
2079
2083
  const originalQuestionText = messageText
2080
2084
  .replace(/<at[^>]*>.*?<\/at>/g, "")
2081
2085
  .trim();
2086
+ const isCreateIncidentCommand = cleanText === CREATE_INCIDENT_COMMAND ||
2087
+ cleanText.startsWith(CREATE_INCIDENT_COMMAND + " ");
2088
+ const isCreateMaintenanceCommand = cleanText === CREATE_MAINTENANCE_COMMAND ||
2089
+ cleanText.startsWith(CREATE_MAINTENANCE_COMMAND + " ");
2090
+ /*
2091
+ * Explicit commands are matched precisely so that natural-language
2092
+ * questions (which may incidentally contain words like "help" or
2093
+ * "alerts") fall through to the AI assistant instead of a canned command.
2094
+ */
2095
+ const isHelpCommand = cleanText === "help" || cleanText === "" || cleanText === "?";
2096
+ const isShowActiveIncidentsCommand = cleanText === "show active incidents" || cleanText === "active incidents";
2097
+ const isShowScheduledMaintenanceCommand = cleanText === "show scheduled maintenance" ||
2098
+ cleanText === "scheduled maintenance";
2099
+ const isShowOngoingMaintenanceCommand = cleanText === "show ongoing maintenance" ||
2100
+ cleanText === "ongoing maintenance";
2101
+ const isShowActiveAlertsCommand = cleanText === "show active alerts" || cleanText === "active alerts";
2102
+ /*
2103
+ * "ask <question>" is an explicit prefix that always routes to the AI
2104
+ * assistant. When present, strip the prefix and use the remainder as the
2105
+ * question.
2106
+ */
2107
+ const isAskCommand = cleanText === "ask" || cleanText.startsWith("ask ");
2108
+ /*
2109
+ * The command, named for log lines that must not quote the message: a
2110
+ * free-form question can carry things that do not belong in a log.
2111
+ */
2112
+ const commandName = (_d = [
2113
+ { matches: isHelpCommand, name: "help" },
2114
+ { matches: isCreateIncidentCommand, name: CREATE_INCIDENT_COMMAND },
2115
+ { matches: isCreateMaintenanceCommand, name: CREATE_MAINTENANCE_COMMAND },
2116
+ { matches: isShowActiveIncidentsCommand, name: "show active incidents" },
2117
+ {
2118
+ matches: isShowScheduledMaintenanceCommand,
2119
+ name: "show scheduled maintenance",
2120
+ },
2121
+ {
2122
+ matches: isShowOngoingMaintenanceCommand,
2123
+ name: "show ongoing maintenance",
2124
+ },
2125
+ { matches: isShowActiveAlertsCommand, name: "show active alerts" },
2126
+ { matches: isAskCommand, name: "ask" },
2127
+ ].find((command) => {
2128
+ return command.matches;
2129
+ })) === null || _d === void 0 ? void 0 : _d.name;
2130
+ let projectId = undefined;
2082
2131
  let responseText = "";
2083
2132
  try {
2084
- const isCreateIncidentCommand = cleanText === "create incident" ||
2085
- cleanText.startsWith("create incident ");
2086
- const isCreateMaintenanceCommand = cleanText === "create maintenance" ||
2087
- cleanText.startsWith("create maintenance ");
2088
- /*
2089
- * Explicit commands are matched precisely so that natural-language
2090
- * questions (which may incidentally contain words like "help" or
2091
- * "alerts") fall through to the AI assistant instead of a canned command.
2092
- */
2093
- const isHelpCommand = cleanText === "help" || cleanText === "" || cleanText === "?";
2094
- const isShowActiveIncidentsCommand = cleanText === "show active incidents" ||
2095
- cleanText === "active incidents";
2096
- const isShowScheduledMaintenanceCommand = cleanText === "show scheduled maintenance" ||
2097
- cleanText === "scheduled maintenance";
2098
- const isShowOngoingMaintenanceCommand = cleanText === "show ongoing maintenance" ||
2099
- cleanText === "ongoing maintenance";
2100
- const isShowActiveAlertsCommand = cleanText === "show active alerts" || cleanText === "active alerts";
2101
- /*
2102
- * "ask <question>" is an explicit prefix that always routes to the AI
2103
- * assistant. When present, strip the prefix and use the remainder as the
2104
- * question.
2105
- */
2106
- const isAskCommand = cleanText === "ask" || cleanText.startsWith("ask ");
2133
+ // Extract tenant ID to get project ID
2134
+ const tenantId = (_e = channelData["tenant"]) === null || _e === void 0 ? void 0 : _e["id"];
2135
+ if (!tenantId) {
2136
+ logger.error("Tenant ID not found in channelData");
2137
+ await data.turnContext.sendActivity("Sorry, I couldn't identify your organization. Please try again later.");
2138
+ return;
2139
+ }
2140
+ // Get project auth by tenant ID
2141
+ const tenantResolution = await this.resolveProjectByTenantId({
2142
+ tenantId: tenantId,
2143
+ });
2144
+ if (!tenantResolution.projectAuth ||
2145
+ !tenantResolution.projectAuth.projectId) {
2146
+ await data.turnContext.sendActivity(this.getTenantResolutionFailureMessage(tenantResolution));
2147
+ return;
2148
+ }
2149
+ projectId = tenantResolution.projectAuth.projectId;
2150
+ logger.debug(`Found project ID: ${projectId.toString()} for tenant ID: ${tenantId}`);
2107
2151
  if (isHelpCommand) {
2108
2152
  responseText = this.getHelpMessage();
2109
2153
  }
2110
2154
  else if (isCreateIncidentCommand) {
2111
- // Handle create incident command (legacy slash command supported)
2155
+ // "create incident <title>" opens the form with the title filled in.
2112
2156
  logger.debug("Processing create incident command");
2113
- const card = await MicrosoftTeamsIncidentActions.buildNewIncidentCard(projectId);
2114
- await data.turnContext.sendActivity({
2115
- attachments: [
2116
- {
2117
- contentType: "application/vnd.microsoft.card.adaptive",
2118
- content: card,
2119
- },
2120
- ],
2157
+ await MicrosoftTeamsCreateCommands.handleCreateIncidentCommand({
2158
+ turnContext: data.turnContext,
2159
+ activity: data.activity,
2160
+ projectId: projectId,
2161
+ initialTitle: originalQuestionText
2162
+ .substring(CREATE_INCIDENT_COMMAND.length)
2163
+ .trim(),
2121
2164
  });
2122
- logger.debug("New incident card sent successfully");
2123
2165
  return;
2124
2166
  }
2125
2167
  else if (isCreateMaintenanceCommand) {
2126
- // Handle create maintenance command (legacy slash command supported)
2168
+ // "create maintenance <title>" opens the form with the title filled in.
2127
2169
  logger.debug("Processing create maintenance command");
2128
- const card = await MicrosoftTeamsScheduledMaintenanceActions.buildNewScheduledMaintenanceCard(projectId);
2129
- await data.turnContext.sendActivity({
2130
- attachments: [
2131
- {
2132
- contentType: "application/vnd.microsoft.card.adaptive",
2133
- content: card,
2134
- },
2135
- ],
2170
+ await MicrosoftTeamsCreateCommands.handleCreateScheduledMaintenanceCommand({
2171
+ turnContext: data.turnContext,
2172
+ activity: data.activity,
2173
+ projectId: projectId,
2174
+ initialTitle: originalQuestionText
2175
+ .substring(CREATE_MAINTENANCE_COMMAND.length)
2176
+ .trim(),
2136
2177
  });
2137
- logger.debug("New scheduled maintenance card sent successfully");
2138
2178
  return;
2139
2179
  }
2140
2180
  else if (isShowActiveIncidentsCommand) {
@@ -2172,18 +2212,71 @@ class MicrosoftTeamsUtil extends WorkspaceBase {
2172
2212
  });
2173
2213
  return;
2174
2214
  }
2175
- // Send response directly using TurnContext - this is the recommended Bot Framework pattern
2176
- await data.turnContext.sendActivity(responseText);
2215
+ /*
2216
+ * Send response directly using TurnContext - this is the recommended Bot
2217
+ * Framework pattern. Lists grow with the project, so the text is kept
2218
+ * within what Teams accepts.
2219
+ */
2220
+ await data.turnContext.sendActivity(MicrosoftTeamsMessageSize.fitTextToBudget({ text: responseText }));
2177
2221
  logger.debug("Bot message sent successfully using TurnContext", {
2178
2222
  projectId: projectId.toString(),
2179
2223
  });
2180
2224
  }
2181
2225
  catch (error) {
2182
- logger.error("Error sending bot message via TurnContext: " + error, {
2183
- projectId: projectId.toString(),
2226
+ /*
2227
+ * One reply, and no rethrow. This used to reply and then rethrow: the
2228
+ * adapter answered Teams with HTTP 500, Teams delivered the message
2229
+ * again, and every failure showed up twice (issue #4111).
2230
+ */
2231
+ /*
2232
+ * The command is named, not quoted: a free-form question can carry
2233
+ * things that do not belong in an error log. The text is in the debug
2234
+ * log above.
2235
+ */
2236
+ MicrosoftTeamsReplies.logFailure(`Microsoft Teams message ${data.activity["id"] || ""} (${commandName
2237
+ ? `"${commandName}"`
2238
+ : `a ${cleanText.length}-character question`}) failed`, error, {
2239
+ projectId: projectId === null || projectId === void 0 ? void 0 : projectId.toString(),
2240
+ });
2241
+ await MicrosoftTeamsReplies.sendBestEffort(data.turnContext, this.getUnexpectedErrorMessage(data.activity));
2242
+ }
2243
+ }
2244
+ /*
2245
+ * The reply to a message whose handling failed in a way nobody planned for.
2246
+ * It names the activity id, which the server log line carries too, so an
2247
+ * administrator can find what went wrong.
2248
+ */
2249
+ static getUnexpectedErrorMessage(activity) {
2250
+ const reference = activity["id"] || "";
2251
+ return `Sorry, something went wrong in OneUptime while handling that message. Please try again in a minute.${reference
2252
+ ? ` If it keeps happening, ask your OneUptime administrator to look for reference ${reference} in the server logs.`
2253
+ : ""}`;
2254
+ }
2255
+ /*
2256
+ * The last line of defence for an inbound activity whose handler threw.
2257
+ *
2258
+ * The error is logged and the turn ends normally, so CloudAdapter answers
2259
+ * Teams with 200. Letting the error through made CloudAdapter answer HTTP
2260
+ * 500, Teams delivered the activity again, and every reply the turn had
2261
+ * posted appeared twice (issue #4111). A message that got no reply yet gets
2262
+ * one; an invoke gets the response it needs, or CloudAdapter answers 501.
2263
+ *
2264
+ * This is deliberately not adapter.onTurnError: the same adapter sends
2265
+ * proactive notifications, and their callers need their errors thrown.
2266
+ */
2267
+ static async recoverFromFailedTurn(data) {
2268
+ const { turnContext, error } = data;
2269
+ const activity = turnContext.activity || {};
2270
+ MicrosoftTeamsReplies.logFailure(`Microsoft Teams ${activity.type || "unknown"} activity ${activity.id || ""} failed`, error);
2271
+ if (activity.type === "message" && !turnContext.responded) {
2272
+ await MicrosoftTeamsReplies.sendBestEffort(turnContext, this.getUnexpectedErrorMessage(activity));
2273
+ return;
2274
+ }
2275
+ if (activity.type === "invoke") {
2276
+ await MicrosoftTeamsReplies.sendBestEffort(turnContext, {
2277
+ type: "invokeResponse",
2278
+ value: { status: 200 },
2184
2279
  });
2185
- await data.turnContext.sendActivity("Sorry, I encountered an error processing your request. Please try again later.");
2186
- throw error;
2187
2280
  }
2188
2281
  }
2189
2282
  /*
@@ -2192,13 +2285,31 @@ class MicrosoftTeamsUtil extends WorkspaceBase {
2192
2285
  * channel/chat message bodies are typically HTML (body.contentType "html").
2193
2286
  */
2194
2287
  static toPlainTextFromTeamsMessageBody(rawContent) {
2195
- return rawContent
2196
- .replace(/<at[^>]*>.*?<\/at>/g, "")
2197
- .replace(/<[^>]*>/g, "")
2288
+ return this.stripHtmlTags(rawContent.replace(/<at[^>]*>.*?<\/at>/g, ""))
2198
2289
  .replace(/&nbsp;/g, " ")
2199
2290
  .replace(/\s+/g, " ")
2200
2291
  .trim();
2201
2292
  }
2293
+ /*
2294
+ * Plain text out of a Teams message body, which Graph and the Bot Framework
2295
+ * hand over as HTML. Removing complete tags is not enough on its own: an
2296
+ * unclosed one ("<script" with no ">" after it) matches no tag pattern, so
2297
+ * once no tag is left, any "<" still standing goes too, and the text holds
2298
+ * no markup at all. The tag pass repeats until nothing changes - the shape
2299
+ * code scanning recognises as complete, where a single pass is reported as
2300
+ * incomplete multi-character sanitization. Teams sends a literal "<" in a
2301
+ * message as "&lt;", which is left encoded: decoding it here would hand
2302
+ * back what this removed.
2303
+ */
2304
+ static stripHtmlTags(html) {
2305
+ let text = html;
2306
+ let previous;
2307
+ do {
2308
+ previous = text;
2309
+ text = text.replace(/<[^>]*>/g, "");
2310
+ } while (text !== previous);
2311
+ return text.replace(/</g, "");
2312
+ }
2202
2313
  /*
2203
2314
  * AI Ops: gather the prior turns of the current Teams conversation/thread and
2204
2315
  * map them to the assistant's history shape ({ role, content }, oldest-first,
@@ -2382,12 +2493,18 @@ class MicrosoftTeamsUtil extends WorkspaceBase {
2382
2493
  });
2383
2494
  }
2384
2495
  catch (error) {
2496
+ // A failed lookup is not a missing account; the caller answers it.
2497
+ if (!(error instanceof MicrosoftTeamsAccountNotLinkedException)) {
2498
+ throw error;
2499
+ }
2385
2500
  logger.debug("No OneUptime user linked to Teams user; prompting to connect account", {
2386
2501
  projectId: projectId.toString(),
2387
2502
  workspaceUserId: teamsUserId,
2388
2503
  });
2389
- logger.debug(error);
2390
- await turnContext.sendActivity("I couldn't find your OneUptime account. Please connect your Microsoft Teams account in OneUptime User Settings before asking me questions.");
2504
+ await turnContext.sendActivity(await MicrosoftTeamsReplies.getAccountNotLinkedMessage({
2505
+ projectId: projectId,
2506
+ purpose: "ask OneUptime questions from Microsoft Teams",
2507
+ }));
2391
2508
  return;
2392
2509
  }
2393
2510
  // The user's real permission props - the assistant's tools run under these.
@@ -2488,6 +2605,25 @@ class MicrosoftTeamsUtil extends WorkspaceBase {
2488
2605
  await turnContext.sendActivity("Sorry, I ran into a problem answering that question. Please try again later.");
2489
2606
  }
2490
2607
  }
2608
+ /*
2609
+ * The monitors an incident or maintenance event affects, as one line: the
2610
+ * first few names, then how many more. An event can cover hundreds of
2611
+ * monitors, and listing them all made the reply too large for Teams.
2612
+ */
2613
+ static formatAffectedMonitorNames(monitors) {
2614
+ const names = monitors
2615
+ .map((monitor) => {
2616
+ return monitor.name || "";
2617
+ })
2618
+ .filter((name) => {
2619
+ return Boolean(name);
2620
+ });
2621
+ const shownNames = names.slice(0, MICROSOFT_TEAMS_MAX_AFFECTED_MONITOR_NAMES);
2622
+ const notShownCount = names.length - shownNames.length;
2623
+ return notShownCount > 0
2624
+ ? `${shownNames.join(", ")} and ${notShownCount} more`
2625
+ : shownNames.join(", ");
2626
+ }
2491
2627
  // Helper methods for bot commands
2492
2628
  static getHelpMessage() {
2493
2629
  return `Hello! I'm the OneUptime bot. I can help you with the following commands:
@@ -2495,8 +2631,8 @@ class MicrosoftTeamsUtil extends WorkspaceBase {
2495
2631
  **Available Commands:**
2496
2632
  - **help** - Show this help message
2497
2633
  - **ask <question>** - Ask OneUptime AI about your logs, traces, metrics, incidents and monitors
2498
- - **create incident** - Create a new incident
2499
- - **create maintenance** - Create a new scheduled maintenance event
2634
+ - **create incident [title]** - Create a new incident
2635
+ - **create maintenance [title]** - Create a new scheduled maintenance event
2500
2636
  - **show active incidents** - Display all currently active incidents
2501
2637
  - **show scheduled maintenance** - Show upcoming scheduled maintenance events
2502
2638
  - **show ongoing maintenance** - Display currently ongoing maintenance events
@@ -2580,11 +2716,7 @@ If you need to report an incident or check historical incidents, please visit th
2580
2716
  • **Declared:** ${declaredAtText}
2581
2717
  `;
2582
2718
  if (incident.monitors && incident.monitors.length > 0) {
2583
- message += `• **Affected Services:** ${incident.monitors
2584
- .map((m) => {
2585
- return m.name;
2586
- })
2587
- .join(", ")}\n`;
2719
+ message += `• **Affected Services:** ${this.formatAffectedMonitorNames(incident.monitors)}\n`;
2588
2720
  }
2589
2721
  if (incident.description) {
2590
2722
  const desc = incident.description.replace(/\s+/g, " ");
@@ -2668,11 +2800,7 @@ Check back later for upcoming maintenance windows.`;
2668
2800
  • **Ends:** ${endTime}
2669
2801
  `;
2670
2802
  if (event.monitors && event.monitors.length > 0) {
2671
- message += `• **Affected Services:** ${event.monitors
2672
- .map((m) => {
2673
- return m.name;
2674
- })
2675
- .join(", ")}\n`;
2803
+ message += `• **Affected Services:** ${this.formatAffectedMonitorNames(event.monitors)}\n`;
2676
2804
  }
2677
2805
  if (event.description) {
2678
2806
  const desc = event.description.replace(/\s+/g, " ");
@@ -2755,11 +2883,7 @@ All systems are currently operating normally.`;
2755
2883
  • **Expected End:** ${endTime}
2756
2884
  `;
2757
2885
  if (event.monitors && event.monitors.length > 0) {
2758
- message += `• **Affected Services:** ${event.monitors
2759
- .map((m) => {
2760
- return m.name;
2761
- })
2762
- .join(", ")}\n`;
2886
+ message += `• **Affected Services:** ${this.formatAffectedMonitorNames(event.monitors)}\n`;
2763
2887
  }
2764
2888
  if (event.description) {
2765
2889
  const desc = event.description.replace(/\s+/g, " ");
@@ -2871,6 +2995,7 @@ All monitoring checks are passing normally.`;
2871
2995
  const { actionType, actionValue } = this.extractActionFromValue(value);
2872
2996
  logger.debug(`Bot invoke activity - Action type: ${actionType}`);
2873
2997
  logger.debug(`Bot invoke value: ${JSON.stringify(value)}`);
2998
+ let projectId = undefined;
2874
2999
  try {
2875
3000
  // Resolve project and user context from activity
2876
3001
  const channelData = data.activity["channelData"] || {};
@@ -2888,7 +3013,7 @@ All monitoring checks are passing normally.`;
2888
3013
  await data.turnContext.sendActivity(this.getTenantResolutionFailureMessage(tenantResolution));
2889
3014
  return;
2890
3015
  }
2891
- const projectId = tenantResolution.projectAuth.projectId;
3016
+ projectId = tenantResolution.projectAuth.projectId;
2892
3017
  const fromObj = (data.activity["from"] ||
2893
3018
  {});
2894
3019
  const teamsUserId = fromObj["aadObjectId"] || undefined;
@@ -3001,19 +3126,39 @@ All monitoring checks are passing normally.`;
3001
3126
  }
3002
3127
  }
3003
3128
  catch (error) {
3129
+ /*
3130
+ * Every reply below is sent best-effort: a reply that fails here must
3131
+ * not escape, or the adapter answers Teams with HTTP 500 and Teams
3132
+ * delivers the action again (issue #4111).
3133
+ */
3134
+ // The account is not connected: say where to connect it.
3135
+ if (error instanceof MicrosoftTeamsAccountNotLinkedException &&
3136
+ projectId) {
3137
+ logger.debug("Bot invoke activity from a Teams user with no linked account", {
3138
+ actionType: actionType,
3139
+ });
3140
+ await MicrosoftTeamsReplies.sendBestEffort(data.turnContext, await MicrosoftTeamsReplies.getAccountNotLinkedMessage({
3141
+ projectId: projectId,
3142
+ purpose: "use OneUptime actions in Microsoft Teams",
3143
+ }));
3144
+ return;
3145
+ }
3004
3146
  // Tell the user why they were refused; the message is written for them.
3005
3147
  if (error instanceof NotAuthorizedException) {
3006
3148
  logger.debug("Bot invoke activity refused: " + error.message, {
3007
3149
  actionType: actionType,
3008
3150
  });
3009
- await data.turnContext.sendActivity(error.message);
3151
+ await MicrosoftTeamsReplies.sendBestEffort(data.turnContext, error.message);
3010
3152
  return;
3011
3153
  }
3012
- logger.error("Error handling bot invoke activity:", {
3154
+ MicrosoftTeamsReplies.logFailure("Error handling bot invoke activity", error, {
3013
3155
  actionType: actionType,
3156
+ projectId: projectId === null || projectId === void 0 ? void 0 : projectId.toString(),
3014
3157
  });
3015
- logger.error(error);
3016
- await data.turnContext.sendActivity("Sorry, that action failed. Please try again later.");
3158
+ const reason = MicrosoftTeamsReplies.getUserFacingErrorMessage(error);
3159
+ await MicrosoftTeamsReplies.sendBestEffort(data.turnContext, reason
3160
+ ? `Sorry, that action failed: ${reason}`
3161
+ : "Sorry, that action failed. Please try again later.");
3017
3162
  }
3018
3163
  }
3019
3164
  static async handleConversationUpdateActivity(data) {
@@ -4308,8 +4453,17 @@ All monitoring checks are passing normally.`;
4308
4453
  from: (_a = context.activity.from) === null || _a === void 0 ? void 0 : _a.name,
4309
4454
  conversationId: (_b = context.activity.conversation) === null || _b === void 0 ? void 0 : _b.id,
4310
4455
  }));
4311
- // Run the activity through our activity handler
4312
- await activityHandler.run(context);
4456
+ try {
4457
+ // Run the activity through our activity handler
4458
+ await activityHandler.run(context);
4459
+ }
4460
+ catch (error) {
4461
+ // Never answer Teams with a 500; see recoverFromFailedTurn.
4462
+ await MicrosoftTeamsUtil.recoverFromFailedTurn({
4463
+ turnContext: context,
4464
+ error: error,
4465
+ });
4466
+ }
4313
4467
  });
4314
4468
  logger.debug("Bot Framework activity processed successfully");
4315
4469
  }
@@ -4709,9 +4863,8 @@ All monitoring checks are passing normally.`;
4709
4863
  }
4710
4864
  const body = msg["body"];
4711
4865
  let text = (body === null || body === void 0 ? void 0 : body["content"]) || "";
4712
- // Remove HTML tags if present (Teams uses HTML)
4713
- text = text.replace(/<[^>]*>/g, "");
4714
- text = text.trim();
4866
+ // Teams message bodies are HTML.
4867
+ text = this.stripHtmlTags(text).trim();
4715
4868
  // Skip empty messages
4716
4869
  if (!text) {
4717
4870
  continue;