@oneuptime/common 9.2.26 → 9.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (278) hide show
  1. package/Models/DatabaseModels/AIAgent.ts +589 -0
  2. package/Models/DatabaseModels/AIAgentOwnerTeam.ts +434 -0
  3. package/Models/DatabaseModels/AIAgentOwnerUser.ts +433 -0
  4. package/Models/DatabaseModels/AIAgentTask.ts +549 -0
  5. package/Models/DatabaseModels/AIAgentTaskLog.ts +417 -0
  6. package/Models/DatabaseModels/AIAgentTaskPullRequest.ts +731 -0
  7. package/Models/DatabaseModels/AIAgentTaskTelemetryException.ts +388 -0
  8. package/Models/DatabaseModels/Index.ts +15 -0
  9. package/Models/DatabaseModels/Monitor.ts +33 -0
  10. package/Models/DatabaseModels/Project.ts +25 -0
  11. package/Models/DatabaseModels/TelemetryException.ts +1 -1
  12. package/Server/API/AIAgentAPI.ts +200 -0
  13. package/Server/API/AIAgentDataAPI.ts +692 -0
  14. package/Server/API/AIAgentTaskAPI.ts +286 -0
  15. package/Server/API/AIAgentTaskLogAPI.ts +165 -0
  16. package/Server/API/AIAgentTaskPullRequestAPI.ts +14 -0
  17. package/Server/API/GitHubAPI.ts +25 -7
  18. package/Server/API/TelemetryExceptionAPI.ts +169 -0
  19. package/Server/EnvironmentConfig.ts +3 -0
  20. package/Server/Infrastructure/Postgres/SchemaMigrations/1766590916627-MigrationName.ts +195 -0
  21. package/Server/Infrastructure/Postgres/SchemaMigrations/1766600860972-MigrationName.ts +31 -0
  22. package/Server/Infrastructure/Postgres/SchemaMigrations/1766606720183-MigrationName.ts +17 -0
  23. package/Server/Infrastructure/Postgres/SchemaMigrations/1766688107858-MigrationName.ts +63 -0
  24. package/Server/Infrastructure/Postgres/SchemaMigrations/1766754182870-MigrationName.ts +75 -0
  25. package/Server/Infrastructure/Postgres/SchemaMigrations/1766774689743-MigrationName.ts +157 -0
  26. package/Server/Infrastructure/Postgres/SchemaMigrations/1766777986427-MigrationName.ts +33 -0
  27. package/Server/Infrastructure/Postgres/SchemaMigrations/1766918848434-AddAIAgentIsDefault.ts +27 -0
  28. package/Server/Infrastructure/Postgres/SchemaMigrations/1766923324521-MigrationName.ts +37 -0
  29. package/Server/Infrastructure/Postgres/SchemaMigrations/1766958924188-AddGitHubAppInstallationIdToProject.ts +31 -0
  30. package/Server/Infrastructure/Postgres/SchemaMigrations/1767009661768-MigrationName.ts +35 -0
  31. package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +22 -0
  32. package/Server/Services/AIAgentOwnerTeamService.ts +10 -0
  33. package/Server/Services/AIAgentOwnerUserService.ts +10 -0
  34. package/Server/Services/AIAgentService.ts +564 -0
  35. package/Server/Services/AIAgentTaskLogService.ts +10 -0
  36. package/Server/Services/AIAgentTaskPullRequestService.ts +10 -0
  37. package/Server/Services/AIAgentTaskService.ts +178 -0
  38. package/Server/Services/AIAgentTaskTelemetryExceptionService.ts +39 -0
  39. package/Server/Services/Index.ts +10 -0
  40. package/Server/Services/TelemetryExceptionService.ts +162 -0
  41. package/Server/Types/Workflow/Components/Index.ts +2 -0
  42. package/Server/Types/Workflow/Components/Telegram/SendMessageToChat.ts +146 -0
  43. package/Server/Utils/Monitor/MonitorResource.ts +228 -0
  44. package/Server/Utils/PushNotificationUtil.ts +29 -0
  45. package/Server/Utils/WhatsAppTemplateUtil.ts +6 -0
  46. package/Tests/UI/Components/Badge.test.tsx +5 -5
  47. package/Tests/UI/Components/Card.test.tsx +4 -8
  48. package/Tests/UI/Components/HiddenText.test.tsx +2 -5
  49. package/Tests/UI/Components/SideMenuItem.test.tsx +4 -2
  50. package/Types/AI/AIAgentTaskMetadata.ts +25 -0
  51. package/Types/AI/AIAgentTaskStatus.ts +65 -0
  52. package/Types/AI/AIAgentTaskType.ts +40 -0
  53. package/Types/Email/EmailTemplateType.ts +2 -0
  54. package/Types/Monitor/MonitorEvaluationSummary.ts +2 -1
  55. package/Types/NotificationSetting/NotificationSettingEventType.ts +4 -0
  56. package/Types/Permission.ts +176 -0
  57. package/Types/WhatsApp/WhatsAppTemplates.ts +9 -0
  58. package/Types/Workflow/ComponentID.ts +1 -0
  59. package/Types/Workflow/Components/Telegram.ts +76 -0
  60. package/Types/Workflow/Components.ts +7 -0
  61. package/UI/Components/AIAgent/AIAgent.tsx +69 -0
  62. package/UI/Components/Badge/Badge.tsx +9 -5
  63. package/UI/Components/Banner/Banner.tsx +1 -1
  64. package/UI/Components/Card/Card.tsx +14 -12
  65. package/UI/Components/CodeBlock/CodeBlock.tsx +47 -4
  66. package/UI/Components/Detail/Detail.tsx +239 -49
  67. package/UI/Components/Detail/FieldLabel.tsx +35 -11
  68. package/UI/Components/Detail/PlaceholderText.tsx +18 -1
  69. package/UI/Components/Footer/Footer.tsx +9 -7
  70. package/UI/Components/Header/Header.tsx +4 -3
  71. package/UI/Components/Header/HeaderIconDropdownButton.tsx +13 -11
  72. package/UI/Components/Header/IconDropdown/IconDropdownItem.tsx +3 -3
  73. package/UI/Components/Header/IconDropdown/IconDropdownMenu.tsx +1 -1
  74. package/UI/Components/Header/ProjectPicker/CreateNewProjectButton.tsx +4 -4
  75. package/UI/Components/Header/ProjectPicker/ProjectPicker.tsx +6 -6
  76. package/UI/Components/Header/ProjectPicker/ProjectPickerFilterBox.tsx +3 -3
  77. package/UI/Components/Header/ProjectPicker/ProjectPickerMenu.tsx +1 -1
  78. package/UI/Components/Header/ProjectPicker/ProjectPickerMenuItem.tsx +4 -4
  79. package/UI/Components/HeaderAlert/HeaderAlert.tsx +32 -32
  80. package/UI/Components/HeaderAlert/HeaderAlertGroup.tsx +1 -7
  81. package/UI/Components/HiddenText/HiddenText.tsx +98 -27
  82. package/UI/Components/Icon/Icon.tsx +12 -9
  83. package/UI/Components/InfoCard/InfoCard.tsx +7 -3
  84. package/UI/Components/ModelTable/BaseModelTable.tsx +1 -1
  85. package/UI/Components/ObjectID/ObjectIDView.tsx +73 -0
  86. package/UI/Components/Page/Page.tsx +3 -5
  87. package/UI/Components/SideMenu/SideMenu.tsx +175 -40
  88. package/UI/Components/SideMenu/SideMenuDivider.tsx +17 -0
  89. package/UI/Components/SideMenu/SideMenuItem.tsx +111 -158
  90. package/UI/Components/SideMenu/SideMenuSection.tsx +53 -3
  91. package/UI/Components/Table/Table.tsx +1 -1
  92. package/UI/Components/Types/FieldType.ts +2 -0
  93. package/UI/Config.ts +5 -0
  94. package/build/dist/Models/DatabaseModels/AIAgent.js +614 -0
  95. package/build/dist/Models/DatabaseModels/AIAgent.js.map +1 -0
  96. package/build/dist/Models/DatabaseModels/AIAgentOwnerTeam.js +452 -0
  97. package/build/dist/Models/DatabaseModels/AIAgentOwnerTeam.js.map +1 -0
  98. package/build/dist/Models/DatabaseModels/AIAgentOwnerUser.js +451 -0
  99. package/build/dist/Models/DatabaseModels/AIAgentOwnerUser.js.map +1 -0
  100. package/build/dist/Models/DatabaseModels/AIAgentTask.js +580 -0
  101. package/build/dist/Models/DatabaseModels/AIAgentTask.js.map +1 -0
  102. package/build/dist/Models/DatabaseModels/AIAgentTaskLog.js +438 -0
  103. package/build/dist/Models/DatabaseModels/AIAgentTaskLog.js.map +1 -0
  104. package/build/dist/Models/DatabaseModels/AIAgentTaskPullRequest.js +771 -0
  105. package/build/dist/Models/DatabaseModels/AIAgentTaskPullRequest.js.map +1 -0
  106. package/build/dist/Models/DatabaseModels/AIAgentTaskTelemetryException.js +404 -0
  107. package/build/dist/Models/DatabaseModels/AIAgentTaskTelemetryException.js.map +1 -0
  108. package/build/dist/Models/DatabaseModels/Index.js +14 -0
  109. package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
  110. package/build/dist/Models/DatabaseModels/Monitor.js +34 -0
  111. package/build/dist/Models/DatabaseModels/Monitor.js.map +1 -1
  112. package/build/dist/Models/DatabaseModels/Project.js +26 -0
  113. package/build/dist/Models/DatabaseModels/Project.js.map +1 -1
  114. package/build/dist/Models/DatabaseModels/TelemetryException.js +1 -1
  115. package/build/dist/Models/DatabaseModels/TelemetryException.js.map +1 -1
  116. package/build/dist/Server/API/AIAgentAPI.js +141 -0
  117. package/build/dist/Server/API/AIAgentAPI.js.map +1 -0
  118. package/build/dist/Server/API/AIAgentDataAPI.js +415 -0
  119. package/build/dist/Server/API/AIAgentDataAPI.js.map +1 -0
  120. package/build/dist/Server/API/AIAgentTaskAPI.js +199 -0
  121. package/build/dist/Server/API/AIAgentTaskAPI.js.map +1 -0
  122. package/build/dist/Server/API/AIAgentTaskLogAPI.js +106 -0
  123. package/build/dist/Server/API/AIAgentTaskLogAPI.js.map +1 -0
  124. package/build/dist/Server/API/AIAgentTaskPullRequestAPI.js +9 -0
  125. package/build/dist/Server/API/AIAgentTaskPullRequestAPI.js.map +1 -0
  126. package/build/dist/Server/API/GitHubAPI.js +23 -8
  127. package/build/dist/Server/API/GitHubAPI.js.map +1 -1
  128. package/build/dist/Server/API/TelemetryExceptionAPI.js +120 -0
  129. package/build/dist/Server/API/TelemetryExceptionAPI.js.map +1 -0
  130. package/build/dist/Server/EnvironmentConfig.js +2 -0
  131. package/build/dist/Server/EnvironmentConfig.js.map +1 -1
  132. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1766590916627-MigrationName.js +74 -0
  133. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1766590916627-MigrationName.js.map +1 -0
  134. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1766600860972-MigrationName.js +18 -0
  135. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1766600860972-MigrationName.js.map +1 -0
  136. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1766606720183-MigrationName.js +12 -0
  137. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1766606720183-MigrationName.js.map +1 -0
  138. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1766688107858-MigrationName.js +28 -0
  139. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1766688107858-MigrationName.js.map +1 -0
  140. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1766754182870-MigrationName.js +32 -0
  141. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1766754182870-MigrationName.js.map +1 -0
  142. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1766774689743-MigrationName.js +60 -0
  143. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1766774689743-MigrationName.js.map +1 -0
  144. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1766777986427-MigrationName.js +18 -0
  145. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1766777986427-MigrationName.js.map +1 -0
  146. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1766918848434-AddAIAgentIsDefault.js +16 -0
  147. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1766918848434-AddAIAgentIsDefault.js.map +1 -0
  148. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1766923324521-MigrationName.js +20 -0
  149. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1766923324521-MigrationName.js.map +1 -0
  150. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1766958924188-AddGitHubAppInstallationIdToProject.js +16 -0
  151. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1766958924188-AddGitHubAppInstallationIdToProject.js.map +1 -0
  152. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1767009661768-MigrationName.js +18 -0
  153. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1767009661768-MigrationName.js.map +1 -0
  154. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +22 -0
  155. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
  156. package/build/dist/Server/Services/AIAgentOwnerTeamService.js +9 -0
  157. package/build/dist/Server/Services/AIAgentOwnerTeamService.js.map +1 -0
  158. package/build/dist/Server/Services/AIAgentOwnerUserService.js +9 -0
  159. package/build/dist/Server/Services/AIAgentOwnerUserService.js.map +1 -0
  160. package/build/dist/Server/Services/AIAgentService.js +471 -0
  161. package/build/dist/Server/Services/AIAgentService.js.map +1 -0
  162. package/build/dist/Server/Services/AIAgentTaskLogService.js +9 -0
  163. package/build/dist/Server/Services/AIAgentTaskLogService.js.map +1 -0
  164. package/build/dist/Server/Services/AIAgentTaskPullRequestService.js +9 -0
  165. package/build/dist/Server/Services/AIAgentTaskPullRequestService.js.map +1 -0
  166. package/build/dist/Server/Services/AIAgentTaskService.js +158 -0
  167. package/build/dist/Server/Services/AIAgentTaskService.js.map +1 -0
  168. package/build/dist/Server/Services/AIAgentTaskTelemetryExceptionService.js +36 -0
  169. package/build/dist/Server/Services/AIAgentTaskTelemetryExceptionService.js.map +1 -0
  170. package/build/dist/Server/Services/Index.js +10 -0
  171. package/build/dist/Server/Services/Index.js.map +1 -1
  172. package/build/dist/Server/Services/TelemetryExceptionService.js +137 -0
  173. package/build/dist/Server/Services/TelemetryExceptionService.js.map +1 -1
  174. package/build/dist/Server/Types/Workflow/Components/Index.js +2 -0
  175. package/build/dist/Server/Types/Workflow/Components/Index.js.map +1 -1
  176. package/build/dist/Server/Types/Workflow/Components/Telegram/SendMessageToChat.js +119 -0
  177. package/build/dist/Server/Types/Workflow/Components/Telegram/SendMessageToChat.js.map +1 -0
  178. package/build/dist/Server/Utils/Monitor/MonitorResource.js +168 -0
  179. package/build/dist/Server/Utils/Monitor/MonitorResource.js.map +1 -1
  180. package/build/dist/Server/Utils/PushNotificationUtil.js +21 -0
  181. package/build/dist/Server/Utils/PushNotificationUtil.js.map +1 -1
  182. package/build/dist/Server/Utils/WhatsAppTemplateUtil.js +4 -0
  183. package/build/dist/Server/Utils/WhatsAppTemplateUtil.js.map +1 -1
  184. package/build/dist/Tests/UI/Components/Badge.test.js +5 -5
  185. package/build/dist/Tests/UI/Components/Badge.test.js.map +1 -1
  186. package/build/dist/Tests/UI/Components/Card.test.js +4 -8
  187. package/build/dist/Tests/UI/Components/Card.test.js.map +1 -1
  188. package/build/dist/Tests/UI/Components/HiddenText.test.js +2 -3
  189. package/build/dist/Tests/UI/Components/HiddenText.test.js.map +1 -1
  190. package/build/dist/Tests/UI/Components/SideMenuItem.test.js +3 -2
  191. package/build/dist/Tests/UI/Components/SideMenuItem.test.js.map +1 -1
  192. package/build/dist/Types/AI/AIAgentTaskMetadata.js +6 -0
  193. package/build/dist/Types/AI/AIAgentTaskMetadata.js.map +1 -0
  194. package/build/dist/Types/AI/AIAgentTaskStatus.js +51 -0
  195. package/build/dist/Types/AI/AIAgentTaskStatus.js.map +1 -0
  196. package/build/dist/Types/AI/AIAgentTaskType.js +29 -0
  197. package/build/dist/Types/AI/AIAgentTaskType.js.map +1 -0
  198. package/build/dist/Types/Email/EmailTemplateType.js +2 -0
  199. package/build/dist/Types/Email/EmailTemplateType.js.map +1 -1
  200. package/build/dist/Types/NotificationSetting/NotificationSettingEventType.js +3 -0
  201. package/build/dist/Types/NotificationSetting/NotificationSettingEventType.js.map +1 -1
  202. package/build/dist/Types/Permission.js +160 -0
  203. package/build/dist/Types/Permission.js.map +1 -1
  204. package/build/dist/Types/WhatsApp/WhatsAppTemplates.js +6 -0
  205. package/build/dist/Types/WhatsApp/WhatsAppTemplates.js.map +1 -1
  206. package/build/dist/Types/Workflow/ComponentID.js +1 -0
  207. package/build/dist/Types/Workflow/ComponentID.js.map +1 -1
  208. package/build/dist/Types/Workflow/Components/Telegram.js +69 -0
  209. package/build/dist/Types/Workflow/Components/Telegram.js.map +1 -0
  210. package/build/dist/Types/Workflow/Components.js +7 -0
  211. package/build/dist/Types/Workflow/Components.js.map +1 -1
  212. package/build/dist/UI/Components/AIAgent/AIAgent.js +32 -0
  213. package/build/dist/UI/Components/AIAgent/AIAgent.js.map +1 -0
  214. package/build/dist/UI/Components/Badge/Badge.js +9 -5
  215. package/build/dist/UI/Components/Badge/Badge.js.map +1 -1
  216. package/build/dist/UI/Components/Banner/Banner.js +1 -1
  217. package/build/dist/UI/Components/Banner/Banner.js.map +1 -1
  218. package/build/dist/UI/Components/Card/Card.js +12 -12
  219. package/build/dist/UI/Components/Card/Card.js.map +1 -1
  220. package/build/dist/UI/Components/CodeBlock/CodeBlock.js +22 -2
  221. package/build/dist/UI/Components/CodeBlock/CodeBlock.js.map +1 -1
  222. package/build/dist/UI/Components/Detail/Detail.js +117 -37
  223. package/build/dist/UI/Components/Detail/Detail.js.map +1 -1
  224. package/build/dist/UI/Components/Detail/FieldLabel.js +12 -7
  225. package/build/dist/UI/Components/Detail/FieldLabel.js.map +1 -1
  226. package/build/dist/UI/Components/Detail/PlaceholderText.js +4 -1
  227. package/build/dist/UI/Components/Detail/PlaceholderText.js.map +1 -1
  228. package/build/dist/UI/Components/Footer/Footer.js +6 -6
  229. package/build/dist/UI/Components/Footer/Footer.js.map +1 -1
  230. package/build/dist/UI/Components/Header/Header.js +4 -3
  231. package/build/dist/UI/Components/Header/Header.js.map +1 -1
  232. package/build/dist/UI/Components/Header/HeaderIconDropdownButton.js +7 -7
  233. package/build/dist/UI/Components/Header/HeaderIconDropdownButton.js.map +1 -1
  234. package/build/dist/UI/Components/Header/IconDropdown/IconDropdownItem.js +3 -3
  235. package/build/dist/UI/Components/Header/IconDropdown/IconDropdownItem.js.map +1 -1
  236. package/build/dist/UI/Components/Header/IconDropdown/IconDropdownMenu.js +1 -1
  237. package/build/dist/UI/Components/Header/IconDropdown/IconDropdownMenu.js.map +1 -1
  238. package/build/dist/UI/Components/Header/ProjectPicker/CreateNewProjectButton.js +4 -4
  239. package/build/dist/UI/Components/Header/ProjectPicker/CreateNewProjectButton.js.map +1 -1
  240. package/build/dist/UI/Components/Header/ProjectPicker/ProjectPicker.js +6 -6
  241. package/build/dist/UI/Components/Header/ProjectPicker/ProjectPicker.js.map +1 -1
  242. package/build/dist/UI/Components/Header/ProjectPicker/ProjectPickerFilterBox.js +2 -2
  243. package/build/dist/UI/Components/Header/ProjectPicker/ProjectPickerFilterBox.js.map +1 -1
  244. package/build/dist/UI/Components/Header/ProjectPicker/ProjectPickerMenu.js +1 -1
  245. package/build/dist/UI/Components/Header/ProjectPicker/ProjectPickerMenu.js.map +1 -1
  246. package/build/dist/UI/Components/Header/ProjectPicker/ProjectPickerMenuItem.js +4 -4
  247. package/build/dist/UI/Components/Header/ProjectPicker/ProjectPickerMenuItem.js.map +1 -1
  248. package/build/dist/UI/Components/HeaderAlert/HeaderAlert.js +31 -29
  249. package/build/dist/UI/Components/HeaderAlert/HeaderAlert.js.map +1 -1
  250. package/build/dist/UI/Components/HeaderAlert/HeaderAlertGroup.js +1 -3
  251. package/build/dist/UI/Components/HeaderAlert/HeaderAlertGroup.js.map +1 -1
  252. package/build/dist/UI/Components/HiddenText/HiddenText.js +33 -14
  253. package/build/dist/UI/Components/HiddenText/HiddenText.js.map +1 -1
  254. package/build/dist/UI/Components/Icon/Icon.js +3 -4
  255. package/build/dist/UI/Components/Icon/Icon.js.map +1 -1
  256. package/build/dist/UI/Components/InfoCard/InfoCard.js +3 -3
  257. package/build/dist/UI/Components/InfoCard/InfoCard.js.map +1 -1
  258. package/build/dist/UI/Components/ModelTable/BaseModelTable.js +1 -1
  259. package/build/dist/UI/Components/ModelTable/BaseModelTable.js.map +1 -1
  260. package/build/dist/UI/Components/ObjectID/ObjectIDView.js +30 -0
  261. package/build/dist/UI/Components/ObjectID/ObjectIDView.js.map +1 -0
  262. package/build/dist/UI/Components/Page/Page.js +3 -3
  263. package/build/dist/UI/Components/Page/Page.js.map +1 -1
  264. package/build/dist/UI/Components/SideMenu/SideMenu.js +82 -17
  265. package/build/dist/UI/Components/SideMenu/SideMenu.js.map +1 -1
  266. package/build/dist/UI/Components/SideMenu/SideMenuDivider.js +7 -0
  267. package/build/dist/UI/Components/SideMenu/SideMenuDivider.js.map +1 -0
  268. package/build/dist/UI/Components/SideMenu/SideMenuItem.js +68 -97
  269. package/build/dist/UI/Components/SideMenu/SideMenuItem.js.map +1 -1
  270. package/build/dist/UI/Components/SideMenu/SideMenuSection.js +18 -3
  271. package/build/dist/UI/Components/SideMenu/SideMenuSection.js.map +1 -1
  272. package/build/dist/UI/Components/Table/Table.js +1 -1
  273. package/build/dist/UI/Components/Table/Table.js.map +1 -1
  274. package/build/dist/UI/Components/Types/FieldType.js +2 -0
  275. package/build/dist/UI/Components/Types/FieldType.js.map +1 -1
  276. package/build/dist/UI/Config.js +2 -0
  277. package/build/dist/UI/Config.js.map +1 -1
  278. package/package.json +1 -1
@@ -0,0 +1,178 @@
1
+ import DatabaseService from "./DatabaseService";
2
+ import Model from "../../Models/DatabaseModels/AIAgentTask";
3
+ import AIAgent from "../../Models/DatabaseModels/AIAgent";
4
+ import CreateBy from "../Types/Database/CreateBy";
5
+ import { OnCreate } from "../Types/Database/Hooks";
6
+ import BadDataException from "../../Types/Exception/BadDataException";
7
+ import AIAgentService from "./AIAgentService";
8
+ import CaptureSpan from "../Utils/Telemetry/CaptureSpan";
9
+ import ObjectID from "../../Types/ObjectID";
10
+ import Semaphore, { SemaphoreMutex } from "../Infrastructure/Semaphore";
11
+ import SortOrder from "../../Types/BaseDatabase/SortOrder";
12
+ import logger from "../Utils/Logger";
13
+ import OneUptimeDate from "../../Types/Date";
14
+
15
+ export class Service extends DatabaseService<Model> {
16
+ public constructor() {
17
+ super(Model);
18
+ }
19
+
20
+ @CaptureSpan()
21
+ protected override async onBeforeCreate(
22
+ createBy: CreateBy<Model>,
23
+ ): Promise<OnCreate<Model>> {
24
+ // If no aiAgentId is provided, assign one automatically
25
+ if (!createBy.data.aiAgentId) {
26
+ createBy.data.aiAgentId = await this.getDefaultAgentId(createBy);
27
+ } else {
28
+ // Validate the provided aiAgentId
29
+ await this.validateAgentBelongsToProject(createBy);
30
+ }
31
+
32
+ // Generate task number
33
+ if (!createBy.data.projectId) {
34
+ throw new BadDataException(
35
+ "Project ID is required to create an AI Agent Task",
36
+ );
37
+ }
38
+
39
+ const projectId: ObjectID = createBy.data.projectId;
40
+
41
+ let mutex: SemaphoreMutex | null = null;
42
+
43
+ try {
44
+ mutex = await Semaphore.lock({
45
+ key: projectId.toString(),
46
+ namespace: "AIAgentTaskService.task-create",
47
+ lockTimeout: 15000,
48
+ acquireTimeout: 20000,
49
+ });
50
+
51
+ logger.debug(
52
+ "Mutex acquired - AIAgentTaskService.task-create " +
53
+ projectId.toString() +
54
+ " at " +
55
+ OneUptimeDate.getCurrentDateAsFormattedString(),
56
+ );
57
+ } catch (err) {
58
+ logger.debug(
59
+ "Mutex acquire failed - AIAgentTaskService.task-create " +
60
+ projectId.toString() +
61
+ " at " +
62
+ OneUptimeDate.getCurrentDateAsFormattedString(),
63
+ );
64
+ logger.error(err);
65
+ }
66
+
67
+ try {
68
+ const taskNumberForThisTask: number =
69
+ (await this.getExistingTaskNumberForProject({
70
+ projectId: projectId,
71
+ })) + 1;
72
+
73
+ createBy.data.taskNumber = taskNumberForThisTask;
74
+ } finally {
75
+ if (mutex) {
76
+ await Semaphore.release(mutex);
77
+ }
78
+ }
79
+
80
+ return { createBy, carryForward: null };
81
+ }
82
+
83
+ @CaptureSpan()
84
+ public async getExistingTaskNumberForProject(data: {
85
+ projectId: ObjectID;
86
+ }): Promise<number> {
87
+ // get last task number.
88
+ const lastTask: Model | null = await this.findOneBy({
89
+ query: {
90
+ projectId: data.projectId,
91
+ },
92
+ select: {
93
+ taskNumber: true,
94
+ },
95
+ sort: {
96
+ createdAt: SortOrder.Descending,
97
+ },
98
+ props: {
99
+ isRoot: true,
100
+ },
101
+ });
102
+
103
+ if (!lastTask) {
104
+ return 0;
105
+ }
106
+
107
+ return lastTask.taskNumber ? Number(lastTask.taskNumber) : 0;
108
+ }
109
+
110
+ @CaptureSpan()
111
+ private async getDefaultAgentId(
112
+ createBy: CreateBy<Model>,
113
+ ): Promise<ObjectID> {
114
+ if (!createBy.data.projectId) {
115
+ throw new BadDataException(
116
+ "Project ID is required to assign an AI Agent",
117
+ );
118
+ }
119
+
120
+ // Try to get the default agent for the project (or global fallback)
121
+ const agent: AIAgent | null = await AIAgentService.getAIAgentForProject(
122
+ createBy.data.projectId,
123
+ );
124
+
125
+ if (!agent || !agent.id) {
126
+ throw new BadDataException(
127
+ "No AI Agent available. Please configure an AI Agent for this project or ensure a global AI Agent is available.",
128
+ );
129
+ }
130
+
131
+ return agent.id!;
132
+ }
133
+
134
+ @CaptureSpan()
135
+ private async validateAgentBelongsToProject(
136
+ createBy: CreateBy<Model>,
137
+ ): Promise<void> {
138
+ if (!createBy.data.aiAgentId || !createBy.data.projectId) {
139
+ return;
140
+ }
141
+
142
+ const agent: AIAgent | null = await AIAgentService.findOneById({
143
+ id: createBy.data.aiAgentId,
144
+ select: {
145
+ _id: true,
146
+ projectId: true,
147
+ isGlobalAIAgent: true,
148
+ },
149
+ props: {
150
+ isRoot: true,
151
+ },
152
+ });
153
+
154
+ if (!agent) {
155
+ throw new BadDataException("AI Agent not found");
156
+ }
157
+
158
+ // Allow if it's a global agent
159
+ if (agent.isGlobalAIAgent) {
160
+ return;
161
+ }
162
+
163
+ // Allow if the agent belongs to the same project
164
+ if (
165
+ agent.projectId &&
166
+ agent.projectId.toString() === createBy.data.projectId.toString()
167
+ ) {
168
+ return;
169
+ }
170
+
171
+ // Reject if the agent belongs to a different project
172
+ throw new BadDataException(
173
+ "The specified AI Agent does not belong to this project. Please use an AI Agent from your project or a global AI Agent.",
174
+ );
175
+ }
176
+ }
177
+
178
+ export default new Service();
@@ -0,0 +1,39 @@
1
+ import DatabaseService from "./DatabaseService";
2
+ import Model from "../../Models/DatabaseModels/AIAgentTaskTelemetryException";
3
+ import ObjectID from "../../Types/ObjectID";
4
+ import DatabaseCommonInteractionProps from "../../Types/BaseDatabase/DatabaseCommonInteractionProps";
5
+ import CaptureSpan from "../Utils/Telemetry/CaptureSpan";
6
+
7
+ export interface LinkTaskToTelemetryExceptionParams {
8
+ projectId: ObjectID;
9
+ aiAgentTaskId: ObjectID;
10
+ telemetryExceptionId: ObjectID;
11
+ props: DatabaseCommonInteractionProps;
12
+ }
13
+
14
+ export class Service extends DatabaseService<Model> {
15
+ public constructor() {
16
+ super(Model);
17
+ }
18
+
19
+ @CaptureSpan()
20
+ public async linkTaskToTelemetryException(
21
+ params: LinkTaskToTelemetryExceptionParams,
22
+ ): Promise<Model> {
23
+ const { projectId, aiAgentTaskId, telemetryExceptionId, props } = params;
24
+
25
+ const taskExceptionLink: Model = new Model();
26
+ taskExceptionLink.projectId = projectId;
27
+ taskExceptionLink.aiAgentTaskId = aiAgentTaskId;
28
+ taskExceptionLink.telemetryExceptionId = telemetryExceptionId;
29
+
30
+ return await this.create({
31
+ data: taskExceptionLink,
32
+ props: {
33
+ ...props,
34
+ },
35
+ });
36
+ }
37
+ }
38
+
39
+ export default new Service();
@@ -64,6 +64,11 @@ import OnCallDutyPolicyScheduleService from "./OnCallDutyPolicyScheduleService";
64
64
  // On-Call Duty
65
65
  import OnCallDutyPolicyService from "./OnCallDutyPolicyService";
66
66
  import ProbeService from "./ProbeService";
67
+ import AIAgentService from "./AIAgentService";
68
+ import AIAgentOwnerUserService from "./AIAgentOwnerUserService";
69
+ import AIAgentOwnerTeamService from "./AIAgentOwnerTeamService";
70
+ import AIAgentTaskLogService from "./AIAgentTaskLogService";
71
+ import AIAgentTaskPullRequestService from "./AIAgentTaskPullRequestService";
67
72
  import ProjectCallSMSConfigService from "./ProjectCallSMSConfigService";
68
73
  import ProjectService from "./ProjectService";
69
74
  // Project SMTP Config.
@@ -241,6 +246,11 @@ const services: Array<BaseService> = [
241
246
  ProjectService,
242
247
  ProjectSmtpConfigService,
243
248
  ProbeService,
249
+ AIAgentService,
250
+ AIAgentOwnerUserService,
251
+ AIAgentOwnerTeamService,
252
+ AIAgentTaskLogService,
253
+ AIAgentTaskPullRequestService,
244
254
  ProjectSsoService,
245
255
 
246
256
  ScheduledMaintenanceCustomFieldService,
@@ -1,10 +1,172 @@
1
1
  import DatabaseService from "./DatabaseService";
2
2
  import Model from "../../Models/DatabaseModels/TelemetryException";
3
+ import AIAgentTask from "../../Models/DatabaseModels/AIAgentTask";
4
+ import AIAgentTaskTelemetryException from "../../Models/DatabaseModels/AIAgentTaskTelemetryException";
5
+ import ObjectID from "../../Types/ObjectID";
6
+ import BadDataException from "../../Types/Exception/BadDataException";
7
+ import AIAgentTaskType from "../../Types/AI/AIAgentTaskType";
8
+ import AIAgentTaskStatus from "../../Types/AI/AIAgentTaskStatus";
9
+ import { FixExceptionTaskMetadata } from "../../Types/AI/AIAgentTaskMetadata";
10
+ import DatabaseCommonInteractionProps from "../../Types/BaseDatabase/DatabaseCommonInteractionProps";
11
+ import AIAgentTaskService from "./AIAgentTaskService";
12
+ import AIAgentTaskTelemetryExceptionService from "./AIAgentTaskTelemetryExceptionService";
13
+ import QueryHelper from "../Types/Database/QueryHelper";
14
+ import CaptureSpan from "../Utils/Telemetry/CaptureSpan";
15
+
16
+ export interface CreateAIAgentTaskForExceptionParams {
17
+ telemetryExceptionId: ObjectID;
18
+ props: DatabaseCommonInteractionProps;
19
+ }
3
20
 
4
21
  export class Service extends DatabaseService<Model> {
5
22
  public constructor() {
6
23
  super(Model);
7
24
  }
25
+
26
+ @CaptureSpan()
27
+ public async createAIAgentTaskForException(
28
+ params: CreateAIAgentTaskForExceptionParams,
29
+ ): Promise<AIAgentTask> {
30
+ const { telemetryExceptionId, props } = params;
31
+
32
+ // Get the telemetry exception
33
+ const telemetryException: Model | null = await this.findOneById({
34
+ id: telemetryExceptionId,
35
+ select: {
36
+ _id: true,
37
+ projectId: true,
38
+ message: true,
39
+ stackTrace: true,
40
+ telemetryServiceId: true,
41
+ exceptionType: true,
42
+ },
43
+ props,
44
+ });
45
+
46
+ if (!telemetryException || !telemetryException.projectId) {
47
+ throw new BadDataException("Telemetry Exception not found");
48
+ }
49
+
50
+ // Check if an active AI agent task already exists for this exception
51
+ await this.validateNoActiveTaskExists(telemetryExceptionId);
52
+
53
+ // Create the AI Agent Task
54
+ const createdTask: AIAgentTask = await this.createFixExceptionTask({
55
+ telemetryException,
56
+ telemetryExceptionId,
57
+ props,
58
+ });
59
+
60
+ // Link the task to the telemetry exception
61
+ await AIAgentTaskTelemetryExceptionService.linkTaskToTelemetryException({
62
+ projectId: telemetryException.projectId,
63
+ aiAgentTaskId: createdTask.id!,
64
+ telemetryExceptionId,
65
+ props,
66
+ });
67
+
68
+ return createdTask;
69
+ }
70
+
71
+ @CaptureSpan()
72
+ private async validateNoActiveTaskExists(
73
+ telemetryExceptionId: ObjectID,
74
+ ): Promise<void> {
75
+ const existingTaskLink: AIAgentTaskTelemetryException | null =
76
+ await AIAgentTaskTelemetryExceptionService.findOneBy({
77
+ query: {
78
+ telemetryExceptionId: telemetryExceptionId,
79
+ aiAgentTask: {
80
+ status: QueryHelper.notIn([
81
+ AIAgentTaskStatus.Completed,
82
+ AIAgentTaskStatus.Error,
83
+ ]),
84
+ },
85
+ },
86
+ select: {
87
+ _id: true,
88
+ aiAgentTaskId: true,
89
+ },
90
+ props: {
91
+ isRoot: true,
92
+ },
93
+ });
94
+
95
+ if (existingTaskLink) {
96
+ throw new BadDataException(
97
+ "An AI agent task is already in progress for this exception. Please wait for it to complete before creating a new one.",
98
+ );
99
+ }
100
+ }
101
+
102
+ @CaptureSpan()
103
+ private async createFixExceptionTask(params: {
104
+ telemetryException: Model;
105
+ telemetryExceptionId: ObjectID;
106
+ props: DatabaseCommonInteractionProps;
107
+ }): Promise<AIAgentTask> {
108
+ const { telemetryException, telemetryExceptionId, props } = params;
109
+
110
+ const aiAgentTask: AIAgentTask = new AIAgentTask();
111
+ aiAgentTask.projectId = telemetryException.projectId!;
112
+ aiAgentTask.taskType = AIAgentTaskType.FixException;
113
+ aiAgentTask.status = AIAgentTaskStatus.Scheduled;
114
+
115
+ // Set name and description based on exception details
116
+ const exceptionType: string =
117
+ telemetryException.exceptionType || "Exception";
118
+ const exceptionMessage: string =
119
+ telemetryException.message || "No message available";
120
+
121
+ aiAgentTask.name = `Fix ${exceptionType}: ${exceptionMessage}`;
122
+ aiAgentTask.description = `AI Agent task to fix the exception: ${exceptionMessage}`;
123
+
124
+ // Build metadata
125
+ aiAgentTask.metadata = this.buildFixExceptionMetadata({
126
+ telemetryException,
127
+ telemetryExceptionId,
128
+ });
129
+
130
+ const createdTask: AIAgentTask = await AIAgentTaskService.create({
131
+ data: aiAgentTask,
132
+ props: {
133
+ ...props,
134
+ },
135
+ });
136
+
137
+ if (!createdTask.id) {
138
+ throw new BadDataException("Failed to create AI Agent Task");
139
+ }
140
+
141
+ return createdTask;
142
+ }
143
+
144
+ private buildFixExceptionMetadata(params: {
145
+ telemetryException: Model;
146
+ telemetryExceptionId: ObjectID;
147
+ }): FixExceptionTaskMetadata {
148
+ const { telemetryException, telemetryExceptionId } = params;
149
+
150
+ const metadata: FixExceptionTaskMetadata = {
151
+ taskType: AIAgentTaskType.FixException,
152
+ exceptionId: telemetryExceptionId.toString(),
153
+ };
154
+
155
+ if (telemetryException.stackTrace) {
156
+ metadata.stackTrace = telemetryException.stackTrace;
157
+ }
158
+
159
+ if (telemetryException.message) {
160
+ metadata.errorMessage = telemetryException.message;
161
+ }
162
+
163
+ if (telemetryException.telemetryServiceId) {
164
+ metadata.telemetryServiceId =
165
+ telemetryException.telemetryServiceId.toString();
166
+ }
167
+
168
+ return metadata;
169
+ }
8
170
  }
9
171
 
10
172
  export default new Service();
@@ -28,6 +28,7 @@ import ManualTrigger from "./Manual";
28
28
  import MicrosoftTeamsSendMessageToChannel from "./MicrosoftTeams/SendMessageToChannel";
29
29
  import Schedule from "./Schedule";
30
30
  import SlackSendMessageToChannel from "./Slack/SendMessageToChannel";
31
+ import TelegramSendMessageToChat from "./Telegram/SendMessageToChat";
31
32
  import WebhookTrigger from "./Webhook";
32
33
  import BaseModel from "../../../../Models/DatabaseModels/DatabaseBaseModel/DatabaseBaseModel";
33
34
  import Dictionary from "../../../../Types/Dictionary";
@@ -41,6 +42,7 @@ const Components: Dictionary<ComponentCode> = {
41
42
  [ComponentID.DiscordSendMessageToChannel]: new DiscordSendMessageToChannel(),
42
43
  [ComponentID.MicrosoftTeamsSendMessageToChannel]:
43
44
  new MicrosoftTeamsSendMessageToChannel(),
45
+ [ComponentID.TelegramSendMessageToChat]: new TelegramSendMessageToChat(),
44
46
  [ComponentID.Log]: new Log(),
45
47
  [ComponentID.Schedule]: new Schedule(),
46
48
  [ComponentID.JavaScriptCode]: new JavaScriptCode(),
@@ -0,0 +1,146 @@
1
+ import ComponentCode, { RunOptions, RunReturnType } from "../../ComponentCode";
2
+ import HTTPErrorResponse from "../../../../../Types/API/HTTPErrorResponse";
3
+ import HTTPResponse from "../../../../../Types/API/HTTPResponse";
4
+ import URL from "../../../../../Types/API/URL";
5
+ import APIException from "../../../../../Types/Exception/ApiException";
6
+ import BadDataException from "../../../../../Types/Exception/BadDataException";
7
+ import { JSONObject } from "../../../../../Types/JSON";
8
+ import ComponentMetadata, {
9
+ Port,
10
+ } from "../../../../../Types/Workflow/Component";
11
+ import ComponentID from "../../../../../Types/Workflow/ComponentID";
12
+ import TelegramComponents from "../../../../../Types/Workflow/Components/Telegram";
13
+ import API from "../../../../../Utils/API";
14
+ import CaptureSpan from "../../../../Utils/Telemetry/CaptureSpan";
15
+
16
+ export default class SendMessageToChat extends ComponentCode {
17
+ public constructor() {
18
+ super();
19
+
20
+ const Component: ComponentMetadata | undefined = TelegramComponents.find(
21
+ (i: ComponentMetadata) => {
22
+ return i.id === ComponentID.TelegramSendMessageToChat;
23
+ },
24
+ );
25
+
26
+ if (!Component) {
27
+ throw new BadDataException("Component not found.");
28
+ }
29
+
30
+ this.setMetadata(Component);
31
+ }
32
+
33
+ @CaptureSpan()
34
+ public override async run(
35
+ args: JSONObject,
36
+ options: RunOptions,
37
+ ): Promise<RunReturnType> {
38
+ const successPort: Port | undefined = this.getMetadata().outPorts.find(
39
+ (p: Port) => {
40
+ return p.id === "success";
41
+ },
42
+ );
43
+
44
+ if (!successPort) {
45
+ throw options.onError(new BadDataException("Success port not found"));
46
+ }
47
+
48
+ const errorPort: Port | undefined = this.getMetadata().outPorts.find(
49
+ (p: Port) => {
50
+ return p.id === "error";
51
+ },
52
+ );
53
+
54
+ if (!errorPort) {
55
+ throw options.onError(new BadDataException("Error port not found"));
56
+ }
57
+
58
+ if (!args["bot-token"]) {
59
+ throw options.onError(
60
+ new BadDataException("Telegram Bot Token not found"),
61
+ );
62
+ }
63
+
64
+ if (!args["chat-id"]) {
65
+ throw options.onError(new BadDataException("Telegram Chat ID not found"));
66
+ }
67
+
68
+ if (!args["text"]) {
69
+ throw options.onError(new BadDataException("Telegram message not found"));
70
+ }
71
+
72
+ const botToken: string = args["bot-token"]?.toString() as string;
73
+ const chatId: string = args["chat-id"]?.toString() as string;
74
+ const text: string = args["text"]?.toString() as string;
75
+
76
+ const telegramApiUrl: URL = URL.fromString(
77
+ `https://api.telegram.org/bot${botToken}/sendMessage`,
78
+ );
79
+
80
+ let apiResult: HTTPResponse<JSONObject> | HTTPErrorResponse | null = null;
81
+
82
+ try {
83
+ // https://core.telegram.org/bots/api#sendmessage
84
+ apiResult = await API.post({
85
+ url: telegramApiUrl,
86
+ data: {
87
+ chat_id: chatId,
88
+ text: text,
89
+ },
90
+ });
91
+
92
+ const helpMessage: string =
93
+ " Note: For usernames, the user must have started a conversation with the bot first. For groups/channels, the bot must be added as a member or admin.";
94
+
95
+ if (apiResult instanceof HTTPErrorResponse) {
96
+ // Telegram returns errors in 'description' field
97
+ const telegramError: string =
98
+ (apiResult.data?.["description"] as string) ||
99
+ apiResult.message ||
100
+ "Server Error.";
101
+ return Promise.resolve({
102
+ returnValues: {
103
+ error: telegramError + helpMessage,
104
+ },
105
+ executePort: errorPort,
106
+ });
107
+ }
108
+
109
+ // Check if Telegram returned ok: false (some errors return 200 OK)
110
+ if (apiResult.data && apiResult.data["ok"] === false) {
111
+ const telegramError: string =
112
+ (apiResult.data["description"] as string) || "Telegram API Error.";
113
+ return Promise.resolve({
114
+ returnValues: {
115
+ error: telegramError + helpMessage,
116
+ },
117
+ executePort: errorPort,
118
+ });
119
+ }
120
+
121
+ return Promise.resolve({
122
+ returnValues: {},
123
+ executePort: successPort,
124
+ });
125
+ } catch (err) {
126
+ const helpMessage: string =
127
+ " Note: For usernames, the user must have started a conversation with the bot first. For groups/channels, the bot must be added as a member or admin.";
128
+
129
+ if (err instanceof HTTPErrorResponse) {
130
+ // Telegram returns errors in 'description' field
131
+ const telegramError: string =
132
+ (err.data?.["description"] as string) ||
133
+ err.message ||
134
+ "Server Error.";
135
+ return Promise.resolve({
136
+ returnValues: {
137
+ error: telegramError + helpMessage,
138
+ },
139
+ executePort: errorPort,
140
+ });
141
+ }
142
+
143
+ throw options.onError(new APIException("Something wrong happened."));
144
+ }
145
+ }
146
+ }