@oneuptime/common 9.2.27 → 9.3.1

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 (263) 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/Utils/Monitor/MonitorResource.ts +228 -0
  42. package/Server/Utils/PushNotificationUtil.ts +29 -0
  43. package/Server/Utils/WhatsAppTemplateUtil.ts +6 -0
  44. package/Tests/UI/Components/Badge.test.tsx +5 -5
  45. package/Tests/UI/Components/Card.test.tsx +4 -8
  46. package/Tests/UI/Components/HiddenText.test.tsx +2 -5
  47. package/Tests/UI/Components/SideMenuItem.test.tsx +4 -2
  48. package/Types/AI/AIAgentTaskMetadata.ts +25 -0
  49. package/Types/AI/AIAgentTaskStatus.ts +65 -0
  50. package/Types/AI/AIAgentTaskType.ts +40 -0
  51. package/Types/Email/EmailTemplateType.ts +2 -0
  52. package/Types/Monitor/MonitorEvaluationSummary.ts +2 -1
  53. package/Types/NotificationSetting/NotificationSettingEventType.ts +4 -0
  54. package/Types/Permission.ts +176 -0
  55. package/Types/WhatsApp/WhatsAppTemplates.ts +9 -0
  56. package/UI/Components/AIAgent/AIAgent.tsx +69 -0
  57. package/UI/Components/Badge/Badge.tsx +9 -5
  58. package/UI/Components/Banner/Banner.tsx +1 -1
  59. package/UI/Components/Card/Card.tsx +14 -12
  60. package/UI/Components/CodeBlock/CodeBlock.tsx +47 -4
  61. package/UI/Components/Detail/Detail.tsx +239 -49
  62. package/UI/Components/Detail/FieldLabel.tsx +35 -11
  63. package/UI/Components/Detail/PlaceholderText.tsx +18 -1
  64. package/UI/Components/Footer/Footer.tsx +9 -7
  65. package/UI/Components/Header/Header.tsx +4 -3
  66. package/UI/Components/Header/HeaderIconDropdownButton.tsx +13 -11
  67. package/UI/Components/Header/IconDropdown/IconDropdownItem.tsx +3 -3
  68. package/UI/Components/Header/IconDropdown/IconDropdownMenu.tsx +1 -1
  69. package/UI/Components/Header/ProjectPicker/CreateNewProjectButton.tsx +4 -4
  70. package/UI/Components/Header/ProjectPicker/ProjectPicker.tsx +6 -6
  71. package/UI/Components/Header/ProjectPicker/ProjectPickerFilterBox.tsx +3 -3
  72. package/UI/Components/Header/ProjectPicker/ProjectPickerMenu.tsx +1 -1
  73. package/UI/Components/Header/ProjectPicker/ProjectPickerMenuItem.tsx +4 -4
  74. package/UI/Components/HeaderAlert/HeaderAlert.tsx +32 -32
  75. package/UI/Components/HeaderAlert/HeaderAlertGroup.tsx +1 -7
  76. package/UI/Components/HiddenText/HiddenText.tsx +98 -27
  77. package/UI/Components/Icon/Icon.tsx +12 -9
  78. package/UI/Components/InfoCard/InfoCard.tsx +7 -3
  79. package/UI/Components/ModelTable/BaseModelTable.tsx +1 -1
  80. package/UI/Components/ObjectID/ObjectIDView.tsx +73 -0
  81. package/UI/Components/Page/Page.tsx +3 -5
  82. package/UI/Components/SideMenu/SideMenu.tsx +175 -40
  83. package/UI/Components/SideMenu/SideMenuDivider.tsx +17 -0
  84. package/UI/Components/SideMenu/SideMenuItem.tsx +111 -158
  85. package/UI/Components/SideMenu/SideMenuSection.tsx +53 -3
  86. package/UI/Components/Table/Table.tsx +1 -1
  87. package/UI/Components/Types/FieldType.ts +2 -0
  88. package/UI/Config.ts +5 -0
  89. package/build/dist/Models/DatabaseModels/AIAgent.js +614 -0
  90. package/build/dist/Models/DatabaseModels/AIAgent.js.map +1 -0
  91. package/build/dist/Models/DatabaseModels/AIAgentOwnerTeam.js +452 -0
  92. package/build/dist/Models/DatabaseModels/AIAgentOwnerTeam.js.map +1 -0
  93. package/build/dist/Models/DatabaseModels/AIAgentOwnerUser.js +451 -0
  94. package/build/dist/Models/DatabaseModels/AIAgentOwnerUser.js.map +1 -0
  95. package/build/dist/Models/DatabaseModels/AIAgentTask.js +580 -0
  96. package/build/dist/Models/DatabaseModels/AIAgentTask.js.map +1 -0
  97. package/build/dist/Models/DatabaseModels/AIAgentTaskLog.js +438 -0
  98. package/build/dist/Models/DatabaseModels/AIAgentTaskLog.js.map +1 -0
  99. package/build/dist/Models/DatabaseModels/AIAgentTaskPullRequest.js +771 -0
  100. package/build/dist/Models/DatabaseModels/AIAgentTaskPullRequest.js.map +1 -0
  101. package/build/dist/Models/DatabaseModels/AIAgentTaskTelemetryException.js +404 -0
  102. package/build/dist/Models/DatabaseModels/AIAgentTaskTelemetryException.js.map +1 -0
  103. package/build/dist/Models/DatabaseModels/Index.js +14 -0
  104. package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
  105. package/build/dist/Models/DatabaseModels/Monitor.js +34 -0
  106. package/build/dist/Models/DatabaseModels/Monitor.js.map +1 -1
  107. package/build/dist/Models/DatabaseModels/Project.js +26 -0
  108. package/build/dist/Models/DatabaseModels/Project.js.map +1 -1
  109. package/build/dist/Models/DatabaseModels/TelemetryException.js +1 -1
  110. package/build/dist/Models/DatabaseModels/TelemetryException.js.map +1 -1
  111. package/build/dist/Server/API/AIAgentAPI.js +141 -0
  112. package/build/dist/Server/API/AIAgentAPI.js.map +1 -0
  113. package/build/dist/Server/API/AIAgentDataAPI.js +415 -0
  114. package/build/dist/Server/API/AIAgentDataAPI.js.map +1 -0
  115. package/build/dist/Server/API/AIAgentTaskAPI.js +199 -0
  116. package/build/dist/Server/API/AIAgentTaskAPI.js.map +1 -0
  117. package/build/dist/Server/API/AIAgentTaskLogAPI.js +106 -0
  118. package/build/dist/Server/API/AIAgentTaskLogAPI.js.map +1 -0
  119. package/build/dist/Server/API/AIAgentTaskPullRequestAPI.js +9 -0
  120. package/build/dist/Server/API/AIAgentTaskPullRequestAPI.js.map +1 -0
  121. package/build/dist/Server/API/GitHubAPI.js +23 -8
  122. package/build/dist/Server/API/GitHubAPI.js.map +1 -1
  123. package/build/dist/Server/API/TelemetryExceptionAPI.js +120 -0
  124. package/build/dist/Server/API/TelemetryExceptionAPI.js.map +1 -0
  125. package/build/dist/Server/EnvironmentConfig.js +2 -0
  126. package/build/dist/Server/EnvironmentConfig.js.map +1 -1
  127. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1766590916627-MigrationName.js +74 -0
  128. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1766590916627-MigrationName.js.map +1 -0
  129. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1766600860972-MigrationName.js +18 -0
  130. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1766600860972-MigrationName.js.map +1 -0
  131. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1766606720183-MigrationName.js +12 -0
  132. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1766606720183-MigrationName.js.map +1 -0
  133. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1766688107858-MigrationName.js +28 -0
  134. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1766688107858-MigrationName.js.map +1 -0
  135. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1766754182870-MigrationName.js +32 -0
  136. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1766754182870-MigrationName.js.map +1 -0
  137. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1766774689743-MigrationName.js +60 -0
  138. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1766774689743-MigrationName.js.map +1 -0
  139. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1766777986427-MigrationName.js +18 -0
  140. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1766777986427-MigrationName.js.map +1 -0
  141. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1766918848434-AddAIAgentIsDefault.js +16 -0
  142. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1766918848434-AddAIAgentIsDefault.js.map +1 -0
  143. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1766923324521-MigrationName.js +20 -0
  144. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1766923324521-MigrationName.js.map +1 -0
  145. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1766958924188-AddGitHubAppInstallationIdToProject.js +16 -0
  146. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1766958924188-AddGitHubAppInstallationIdToProject.js.map +1 -0
  147. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1767009661768-MigrationName.js +18 -0
  148. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1767009661768-MigrationName.js.map +1 -0
  149. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +22 -0
  150. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
  151. package/build/dist/Server/Services/AIAgentOwnerTeamService.js +9 -0
  152. package/build/dist/Server/Services/AIAgentOwnerTeamService.js.map +1 -0
  153. package/build/dist/Server/Services/AIAgentOwnerUserService.js +9 -0
  154. package/build/dist/Server/Services/AIAgentOwnerUserService.js.map +1 -0
  155. package/build/dist/Server/Services/AIAgentService.js +471 -0
  156. package/build/dist/Server/Services/AIAgentService.js.map +1 -0
  157. package/build/dist/Server/Services/AIAgentTaskLogService.js +9 -0
  158. package/build/dist/Server/Services/AIAgentTaskLogService.js.map +1 -0
  159. package/build/dist/Server/Services/AIAgentTaskPullRequestService.js +9 -0
  160. package/build/dist/Server/Services/AIAgentTaskPullRequestService.js.map +1 -0
  161. package/build/dist/Server/Services/AIAgentTaskService.js +158 -0
  162. package/build/dist/Server/Services/AIAgentTaskService.js.map +1 -0
  163. package/build/dist/Server/Services/AIAgentTaskTelemetryExceptionService.js +36 -0
  164. package/build/dist/Server/Services/AIAgentTaskTelemetryExceptionService.js.map +1 -0
  165. package/build/dist/Server/Services/Index.js +10 -0
  166. package/build/dist/Server/Services/Index.js.map +1 -1
  167. package/build/dist/Server/Services/TelemetryExceptionService.js +137 -0
  168. package/build/dist/Server/Services/TelemetryExceptionService.js.map +1 -1
  169. package/build/dist/Server/Utils/Monitor/MonitorResource.js +168 -0
  170. package/build/dist/Server/Utils/Monitor/MonitorResource.js.map +1 -1
  171. package/build/dist/Server/Utils/PushNotificationUtil.js +21 -0
  172. package/build/dist/Server/Utils/PushNotificationUtil.js.map +1 -1
  173. package/build/dist/Server/Utils/WhatsAppTemplateUtil.js +4 -0
  174. package/build/dist/Server/Utils/WhatsAppTemplateUtil.js.map +1 -1
  175. package/build/dist/Tests/UI/Components/Badge.test.js +5 -5
  176. package/build/dist/Tests/UI/Components/Badge.test.js.map +1 -1
  177. package/build/dist/Tests/UI/Components/Card.test.js +4 -8
  178. package/build/dist/Tests/UI/Components/Card.test.js.map +1 -1
  179. package/build/dist/Tests/UI/Components/HiddenText.test.js +2 -3
  180. package/build/dist/Tests/UI/Components/HiddenText.test.js.map +1 -1
  181. package/build/dist/Tests/UI/Components/SideMenuItem.test.js +3 -2
  182. package/build/dist/Tests/UI/Components/SideMenuItem.test.js.map +1 -1
  183. package/build/dist/Types/AI/AIAgentTaskMetadata.js +6 -0
  184. package/build/dist/Types/AI/AIAgentTaskMetadata.js.map +1 -0
  185. package/build/dist/Types/AI/AIAgentTaskStatus.js +51 -0
  186. package/build/dist/Types/AI/AIAgentTaskStatus.js.map +1 -0
  187. package/build/dist/Types/AI/AIAgentTaskType.js +29 -0
  188. package/build/dist/Types/AI/AIAgentTaskType.js.map +1 -0
  189. package/build/dist/Types/Email/EmailTemplateType.js +2 -0
  190. package/build/dist/Types/Email/EmailTemplateType.js.map +1 -1
  191. package/build/dist/Types/NotificationSetting/NotificationSettingEventType.js +3 -0
  192. package/build/dist/Types/NotificationSetting/NotificationSettingEventType.js.map +1 -1
  193. package/build/dist/Types/Permission.js +160 -0
  194. package/build/dist/Types/Permission.js.map +1 -1
  195. package/build/dist/Types/WhatsApp/WhatsAppTemplates.js +6 -0
  196. package/build/dist/Types/WhatsApp/WhatsAppTemplates.js.map +1 -1
  197. package/build/dist/UI/Components/AIAgent/AIAgent.js +32 -0
  198. package/build/dist/UI/Components/AIAgent/AIAgent.js.map +1 -0
  199. package/build/dist/UI/Components/Badge/Badge.js +9 -5
  200. package/build/dist/UI/Components/Badge/Badge.js.map +1 -1
  201. package/build/dist/UI/Components/Banner/Banner.js +1 -1
  202. package/build/dist/UI/Components/Banner/Banner.js.map +1 -1
  203. package/build/dist/UI/Components/Card/Card.js +12 -12
  204. package/build/dist/UI/Components/Card/Card.js.map +1 -1
  205. package/build/dist/UI/Components/CodeBlock/CodeBlock.js +22 -2
  206. package/build/dist/UI/Components/CodeBlock/CodeBlock.js.map +1 -1
  207. package/build/dist/UI/Components/Detail/Detail.js +117 -37
  208. package/build/dist/UI/Components/Detail/Detail.js.map +1 -1
  209. package/build/dist/UI/Components/Detail/FieldLabel.js +12 -7
  210. package/build/dist/UI/Components/Detail/FieldLabel.js.map +1 -1
  211. package/build/dist/UI/Components/Detail/PlaceholderText.js +4 -1
  212. package/build/dist/UI/Components/Detail/PlaceholderText.js.map +1 -1
  213. package/build/dist/UI/Components/Footer/Footer.js +6 -6
  214. package/build/dist/UI/Components/Footer/Footer.js.map +1 -1
  215. package/build/dist/UI/Components/Header/Header.js +4 -3
  216. package/build/dist/UI/Components/Header/Header.js.map +1 -1
  217. package/build/dist/UI/Components/Header/HeaderIconDropdownButton.js +7 -7
  218. package/build/dist/UI/Components/Header/HeaderIconDropdownButton.js.map +1 -1
  219. package/build/dist/UI/Components/Header/IconDropdown/IconDropdownItem.js +3 -3
  220. package/build/dist/UI/Components/Header/IconDropdown/IconDropdownItem.js.map +1 -1
  221. package/build/dist/UI/Components/Header/IconDropdown/IconDropdownMenu.js +1 -1
  222. package/build/dist/UI/Components/Header/IconDropdown/IconDropdownMenu.js.map +1 -1
  223. package/build/dist/UI/Components/Header/ProjectPicker/CreateNewProjectButton.js +4 -4
  224. package/build/dist/UI/Components/Header/ProjectPicker/CreateNewProjectButton.js.map +1 -1
  225. package/build/dist/UI/Components/Header/ProjectPicker/ProjectPicker.js +6 -6
  226. package/build/dist/UI/Components/Header/ProjectPicker/ProjectPicker.js.map +1 -1
  227. package/build/dist/UI/Components/Header/ProjectPicker/ProjectPickerFilterBox.js +2 -2
  228. package/build/dist/UI/Components/Header/ProjectPicker/ProjectPickerFilterBox.js.map +1 -1
  229. package/build/dist/UI/Components/Header/ProjectPicker/ProjectPickerMenu.js +1 -1
  230. package/build/dist/UI/Components/Header/ProjectPicker/ProjectPickerMenu.js.map +1 -1
  231. package/build/dist/UI/Components/Header/ProjectPicker/ProjectPickerMenuItem.js +4 -4
  232. package/build/dist/UI/Components/Header/ProjectPicker/ProjectPickerMenuItem.js.map +1 -1
  233. package/build/dist/UI/Components/HeaderAlert/HeaderAlert.js +31 -29
  234. package/build/dist/UI/Components/HeaderAlert/HeaderAlert.js.map +1 -1
  235. package/build/dist/UI/Components/HeaderAlert/HeaderAlertGroup.js +1 -3
  236. package/build/dist/UI/Components/HeaderAlert/HeaderAlertGroup.js.map +1 -1
  237. package/build/dist/UI/Components/HiddenText/HiddenText.js +33 -14
  238. package/build/dist/UI/Components/HiddenText/HiddenText.js.map +1 -1
  239. package/build/dist/UI/Components/Icon/Icon.js +3 -4
  240. package/build/dist/UI/Components/Icon/Icon.js.map +1 -1
  241. package/build/dist/UI/Components/InfoCard/InfoCard.js +3 -3
  242. package/build/dist/UI/Components/InfoCard/InfoCard.js.map +1 -1
  243. package/build/dist/UI/Components/ModelTable/BaseModelTable.js +1 -1
  244. package/build/dist/UI/Components/ModelTable/BaseModelTable.js.map +1 -1
  245. package/build/dist/UI/Components/ObjectID/ObjectIDView.js +30 -0
  246. package/build/dist/UI/Components/ObjectID/ObjectIDView.js.map +1 -0
  247. package/build/dist/UI/Components/Page/Page.js +3 -3
  248. package/build/dist/UI/Components/Page/Page.js.map +1 -1
  249. package/build/dist/UI/Components/SideMenu/SideMenu.js +82 -17
  250. package/build/dist/UI/Components/SideMenu/SideMenu.js.map +1 -1
  251. package/build/dist/UI/Components/SideMenu/SideMenuDivider.js +7 -0
  252. package/build/dist/UI/Components/SideMenu/SideMenuDivider.js.map +1 -0
  253. package/build/dist/UI/Components/SideMenu/SideMenuItem.js +68 -97
  254. package/build/dist/UI/Components/SideMenu/SideMenuItem.js.map +1 -1
  255. package/build/dist/UI/Components/SideMenu/SideMenuSection.js +18 -3
  256. package/build/dist/UI/Components/SideMenu/SideMenuSection.js.map +1 -1
  257. package/build/dist/UI/Components/Table/Table.js +1 -1
  258. package/build/dist/UI/Components/Table/Table.js.map +1 -1
  259. package/build/dist/UI/Components/Types/FieldType.js +2 -0
  260. package/build/dist/UI/Components/Types/FieldType.js.map +1 -1
  261. package/build/dist/UI/Config.js +2 -0
  262. package/build/dist/UI/Config.js.map +1 -1
  263. package/package.json +1 -1
@@ -0,0 +1,286 @@
1
+ import AIAgentService from "../Services/AIAgentService";
2
+ import AIAgentTaskService, {
3
+ Service as AIAgentTaskServiceType,
4
+ } from "../Services/AIAgentTaskService";
5
+ import {
6
+ ExpressRequest,
7
+ ExpressResponse,
8
+ NextFunction,
9
+ } from "../Utils/Express";
10
+ import Response from "../Utils/Response";
11
+ import BaseAPI from "./BaseAPI";
12
+ import AIAgentTask from "../../Models/DatabaseModels/AIAgentTask";
13
+ import AIAgent from "../../Models/DatabaseModels/AIAgent";
14
+ import BadDataException from "../../Types/Exception/BadDataException";
15
+ import { JSONObject } from "../../Types/JSON";
16
+ import ObjectID from "../../Types/ObjectID";
17
+ import OneUptimeDate from "../../Types/Date";
18
+ import AIAgentTaskStatus from "../../Types/AI/AIAgentTaskStatus";
19
+ import SortOrder from "../../Types/BaseDatabase/SortOrder";
20
+ import PositiveNumber from "../../Types/PositiveNumber";
21
+
22
+ export default class AIAgentTaskAPI extends BaseAPI<
23
+ AIAgentTask,
24
+ AIAgentTaskServiceType
25
+ > {
26
+ public constructor() {
27
+ super(AIAgentTask, AIAgentTaskService);
28
+
29
+ /*
30
+ * Get the next pending (scheduled) task for processing
31
+ * Validates aiAgentId and aiAgentKey before returning task
32
+ */
33
+ this.router.post(
34
+ `${new this.entityType().getCrudApiPath()?.toString()}/get-pending-task`,
35
+ async (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => {
36
+ try {
37
+ const data: JSONObject = req.body;
38
+
39
+ /* Validate AI Agent credentials */
40
+ const aiAgent: AIAgent | null = await this.validateAIAgent(data);
41
+
42
+ if (!aiAgent) {
43
+ return Response.sendErrorResponse(
44
+ req,
45
+ res,
46
+ new BadDataException("Invalid AI Agent ID or AI Agent Key"),
47
+ );
48
+ }
49
+
50
+ /* Fetch one scheduled task, sorted by createdAt (oldest first) */
51
+ const task: AIAgentTask | null = await AIAgentTaskService.findOneBy({
52
+ query: {
53
+ status: AIAgentTaskStatus.Scheduled,
54
+ },
55
+ sort: {
56
+ createdAt: SortOrder.Ascending,
57
+ },
58
+ select: {
59
+ _id: true,
60
+ projectId: true,
61
+ taskType: true,
62
+ metadata: true,
63
+ createdAt: true,
64
+ },
65
+ props: {
66
+ isRoot: true,
67
+ },
68
+ });
69
+
70
+ if (!task) {
71
+ return Response.sendJsonObjectResponse(req, res, {
72
+ task: null,
73
+ message: "No pending tasks available",
74
+ });
75
+ }
76
+
77
+ return Response.sendJsonObjectResponse(req, res, {
78
+ task: {
79
+ _id: task._id?.toString(),
80
+ projectId: task.projectId?.toString(),
81
+ taskType: task.taskType,
82
+ metadata: task.metadata as JSONObject | undefined,
83
+ createdAt: task.createdAt,
84
+ },
85
+ message: "Task fetched successfully",
86
+ });
87
+ } catch (err) {
88
+ next(err);
89
+ }
90
+ },
91
+ );
92
+
93
+ /*
94
+ * Get the count of pending (scheduled) tasks for KEDA autoscaling
95
+ * Validates aiAgentId and aiAgentKey before returning count
96
+ */
97
+ this.router.post(
98
+ `${new this.entityType().getCrudApiPath()?.toString()}/get-pending-task-count`,
99
+ async (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => {
100
+ try {
101
+ const data: JSONObject = req.body;
102
+
103
+ /* Validate AI Agent credentials */
104
+ const aiAgent: AIAgent | null = await this.validateAIAgent(data);
105
+
106
+ if (!aiAgent) {
107
+ return Response.sendErrorResponse(
108
+ req,
109
+ res,
110
+ new BadDataException("Invalid AI Agent ID or AI Agent Key"),
111
+ );
112
+ }
113
+
114
+ /* Count scheduled tasks */
115
+ const count: PositiveNumber = await AIAgentTaskService.countBy({
116
+ query: {
117
+ status: AIAgentTaskStatus.Scheduled,
118
+ },
119
+ props: {
120
+ isRoot: true,
121
+ },
122
+ });
123
+
124
+ return Response.sendJsonObjectResponse(req, res, {
125
+ count: count,
126
+ message: "Pending task count fetched successfully",
127
+ });
128
+ } catch (err) {
129
+ next(err);
130
+ }
131
+ },
132
+ );
133
+
134
+ /*
135
+ * Update task status (InProgress, Completed, Error)
136
+ * Validates aiAgentId and aiAgentKey before updating
137
+ */
138
+ this.router.post(
139
+ `${new this.entityType().getCrudApiPath()?.toString()}/update-task-status`,
140
+ async (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => {
141
+ try {
142
+ const data: JSONObject = req.body;
143
+
144
+ /* Validate AI Agent credentials */
145
+ const aiAgent: AIAgent | null = await this.validateAIAgent(data);
146
+
147
+ if (!aiAgent) {
148
+ return Response.sendErrorResponse(
149
+ req,
150
+ res,
151
+ new BadDataException("Invalid AI Agent ID or AI Agent Key"),
152
+ );
153
+ }
154
+
155
+ /* Validate required fields */
156
+ if (!data["taskId"]) {
157
+ return Response.sendErrorResponse(
158
+ req,
159
+ res,
160
+ new BadDataException("taskId is required"),
161
+ );
162
+ }
163
+
164
+ if (!data["status"]) {
165
+ return Response.sendErrorResponse(
166
+ req,
167
+ res,
168
+ new BadDataException("status is required"),
169
+ );
170
+ }
171
+
172
+ const taskId: ObjectID = new ObjectID(data["taskId"] as string);
173
+ const status: AIAgentTaskStatus = data["status"] as AIAgentTaskStatus;
174
+ const statusMessage: string | undefined = data["statusMessage"] as
175
+ | string
176
+ | undefined;
177
+
178
+ /* Validate status value */
179
+ const validStatuses: Array<AIAgentTaskStatus> = [
180
+ AIAgentTaskStatus.InProgress,
181
+ AIAgentTaskStatus.Completed,
182
+ AIAgentTaskStatus.Error,
183
+ ];
184
+
185
+ if (!validStatuses.includes(status)) {
186
+ return Response.sendErrorResponse(
187
+ req,
188
+ res,
189
+ new BadDataException(
190
+ `Invalid status. Must be one of: ${validStatuses.join(", ")}`,
191
+ ),
192
+ );
193
+ }
194
+
195
+ /* Check if task exists */
196
+ const existingTask: AIAgentTask | null =
197
+ await AIAgentTaskService.findOneById({
198
+ id: taskId,
199
+ select: {
200
+ _id: true,
201
+ status: true,
202
+ },
203
+ props: {
204
+ isRoot: true,
205
+ },
206
+ });
207
+
208
+ if (!existingTask) {
209
+ return Response.sendErrorResponse(
210
+ req,
211
+ res,
212
+ new BadDataException("Task not found"),
213
+ );
214
+ }
215
+
216
+ /* Update the task based on status */
217
+ if (status === AIAgentTaskStatus.InProgress) {
218
+ await AIAgentTaskService.updateOneById({
219
+ id: taskId,
220
+ data: {
221
+ status: status,
222
+ ...(aiAgent.id && { aiAgentId: aiAgent.id }),
223
+ startedAt: OneUptimeDate.getCurrentDate(),
224
+ ...(statusMessage && { statusMessage: statusMessage }),
225
+ },
226
+ props: {
227
+ isRoot: true,
228
+ },
229
+ });
230
+ } else if (
231
+ status === AIAgentTaskStatus.Completed ||
232
+ status === AIAgentTaskStatus.Error
233
+ ) {
234
+ await AIAgentTaskService.updateOneById({
235
+ id: taskId,
236
+ data: {
237
+ status: status,
238
+ completedAt: OneUptimeDate.getCurrentDate(),
239
+ ...(statusMessage && { statusMessage: statusMessage }),
240
+ },
241
+ props: {
242
+ isRoot: true,
243
+ },
244
+ });
245
+ }
246
+
247
+ return Response.sendJsonObjectResponse(req, res, {
248
+ taskId: taskId.toString(),
249
+ status: status,
250
+ message: "Task status updated successfully",
251
+ });
252
+ } catch (err) {
253
+ next(err);
254
+ }
255
+ },
256
+ );
257
+ }
258
+
259
+ /*
260
+ * Validate AI Agent credentials from request body
261
+ * Returns AIAgent if valid, null otherwise
262
+ */
263
+ private async validateAIAgent(data: JSONObject): Promise<AIAgent | null> {
264
+ if (!data["aiAgentId"] || !data["aiAgentKey"]) {
265
+ return null;
266
+ }
267
+
268
+ const aiAgentId: ObjectID = new ObjectID(data["aiAgentId"] as string);
269
+ const aiAgentKey: string = data["aiAgentKey"] as string;
270
+
271
+ const aiAgent: AIAgent | null = await AIAgentService.findOneBy({
272
+ query: {
273
+ _id: aiAgentId.toString(),
274
+ key: aiAgentKey,
275
+ },
276
+ select: {
277
+ _id: true,
278
+ },
279
+ props: {
280
+ isRoot: true,
281
+ },
282
+ });
283
+
284
+ return aiAgent;
285
+ }
286
+ }
@@ -0,0 +1,165 @@
1
+ import AIAgentTaskLogService, {
2
+ Service as AIAgentTaskLogServiceType,
3
+ } from "../Services/AIAgentTaskLogService";
4
+ import AIAgentService from "../Services/AIAgentService";
5
+ import AIAgentTaskService from "../Services/AIAgentTaskService";
6
+ import {
7
+ ExpressRequest,
8
+ ExpressResponse,
9
+ NextFunction,
10
+ } from "../Utils/Express";
11
+ import Response from "../Utils/Response";
12
+ import BaseAPI from "./BaseAPI";
13
+ import AIAgentTaskLog from "../../Models/DatabaseModels/AIAgentTaskLog";
14
+ import AIAgent from "../../Models/DatabaseModels/AIAgent";
15
+ import AIAgentTask from "../../Models/DatabaseModels/AIAgentTask";
16
+ import BadDataException from "../../Types/Exception/BadDataException";
17
+ import { JSONObject } from "../../Types/JSON";
18
+ import ObjectID from "../../Types/ObjectID";
19
+ import LogSeverity from "../../Types/Log/LogSeverity";
20
+
21
+ export default class AIAgentTaskLogAPI extends BaseAPI<
22
+ AIAgentTaskLog,
23
+ AIAgentTaskLogServiceType
24
+ > {
25
+ public constructor() {
26
+ super(AIAgentTaskLog, AIAgentTaskLogService);
27
+
28
+ /*
29
+ * Create a log entry for an AI Agent task
30
+ * Validates aiAgentId and aiAgentKey before creating log
31
+ */
32
+ this.router.post(
33
+ `${new this.entityType().getCrudApiPath()?.toString()}/create-log`,
34
+ async (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => {
35
+ try {
36
+ const data: JSONObject = req.body;
37
+
38
+ /* Validate AI Agent credentials */
39
+ const aiAgent: AIAgent | null = await this.validateAIAgent(data);
40
+
41
+ if (!aiAgent) {
42
+ return Response.sendErrorResponse(
43
+ req,
44
+ res,
45
+ new BadDataException("Invalid AI Agent ID or AI Agent Key"),
46
+ );
47
+ }
48
+
49
+ /* Validate required fields */
50
+ if (!data["taskId"]) {
51
+ return Response.sendErrorResponse(
52
+ req,
53
+ res,
54
+ new BadDataException("taskId is required"),
55
+ );
56
+ }
57
+
58
+ if (!data["severity"]) {
59
+ return Response.sendErrorResponse(
60
+ req,
61
+ res,
62
+ new BadDataException("severity is required"),
63
+ );
64
+ }
65
+
66
+ if (!data["message"]) {
67
+ return Response.sendErrorResponse(
68
+ req,
69
+ res,
70
+ new BadDataException("message is required"),
71
+ );
72
+ }
73
+
74
+ const taskId: ObjectID = new ObjectID(data["taskId"] as string);
75
+ const severity: LogSeverity = data["severity"] as LogSeverity;
76
+ const message: string = data["message"] as string;
77
+
78
+ /* Validate severity value */
79
+ const validSeverities: Array<LogSeverity> =
80
+ Object.values(LogSeverity);
81
+ if (!validSeverities.includes(severity)) {
82
+ return Response.sendErrorResponse(
83
+ req,
84
+ res,
85
+ new BadDataException(
86
+ `Invalid severity. Must be one of: ${validSeverities.join(", ")}`,
87
+ ),
88
+ );
89
+ }
90
+
91
+ /* Check if task exists and get project ID */
92
+ const existingTask: AIAgentTask | null =
93
+ await AIAgentTaskService.findOneById({
94
+ id: taskId,
95
+ select: {
96
+ _id: true,
97
+ projectId: true,
98
+ },
99
+ props: {
100
+ isRoot: true,
101
+ },
102
+ });
103
+
104
+ if (!existingTask) {
105
+ return Response.sendErrorResponse(
106
+ req,
107
+ res,
108
+ new BadDataException("Task not found"),
109
+ );
110
+ }
111
+
112
+ /* Create the log entry */
113
+ const logEntry: AIAgentTaskLog = new AIAgentTaskLog();
114
+ logEntry.projectId = existingTask.projectId!;
115
+ logEntry.aiAgentTaskId = taskId;
116
+ logEntry.aiAgentId = aiAgent.id!;
117
+ logEntry.severity = severity;
118
+ logEntry.message = message;
119
+
120
+ await AIAgentTaskLogService.create({
121
+ data: logEntry,
122
+ props: {
123
+ isRoot: true,
124
+ },
125
+ });
126
+
127
+ return Response.sendJsonObjectResponse(req, res, {
128
+ taskId: taskId.toString(),
129
+ message: "Log entry created successfully",
130
+ });
131
+ } catch (err) {
132
+ next(err);
133
+ }
134
+ },
135
+ );
136
+ }
137
+
138
+ /*
139
+ * Validate AI Agent credentials from request body
140
+ * Returns AIAgent if valid, null otherwise
141
+ */
142
+ private async validateAIAgent(data: JSONObject): Promise<AIAgent | null> {
143
+ if (!data["aiAgentId"] || !data["aiAgentKey"]) {
144
+ return null;
145
+ }
146
+
147
+ const aiAgentId: ObjectID = new ObjectID(data["aiAgentId"] as string);
148
+ const aiAgentKey: string = data["aiAgentKey"] as string;
149
+
150
+ const aiAgent: AIAgent | null = await AIAgentService.findOneBy({
151
+ query: {
152
+ _id: aiAgentId.toString(),
153
+ key: aiAgentKey,
154
+ },
155
+ select: {
156
+ _id: true,
157
+ },
158
+ props: {
159
+ isRoot: true,
160
+ },
161
+ });
162
+
163
+ return aiAgent;
164
+ }
165
+ }
@@ -0,0 +1,14 @@
1
+ import AIAgentTaskPullRequestService, {
2
+ Service as AIAgentTaskPullRequestServiceType,
3
+ } from "../Services/AIAgentTaskPullRequestService";
4
+ import BaseAPI from "./BaseAPI";
5
+ import AIAgentTaskPullRequest from "../../Models/DatabaseModels/AIAgentTaskPullRequest";
6
+
7
+ export default class AIAgentTaskPullRequestAPI extends BaseAPI<
8
+ AIAgentTaskPullRequest,
9
+ AIAgentTaskPullRequestServiceType
10
+ > {
11
+ public constructor() {
12
+ super(AIAgentTaskPullRequest, AIAgentTaskPullRequestService);
13
+ }
14
+ }
@@ -7,12 +7,13 @@ import Response from "../Utils/Response";
7
7
  import BadDataException from "../../Types/Exception/BadDataException";
8
8
  import logger from "../Utils/Logger";
9
9
  import { JSONObject } from "../../Types/JSON";
10
- import { DashboardClientUrl, GitHubAppClientId } from "../EnvironmentConfig";
10
+ import { DashboardClientUrl, GitHubAppName } from "../EnvironmentConfig";
11
11
  import ObjectID from "../../Types/ObjectID";
12
12
  import GitHubUtil, {
13
13
  GitHubRepository,
14
14
  } from "../Utils/CodeRepository/GitHub/GitHub";
15
15
  import CodeRepositoryService from "../Services/CodeRepositoryService";
16
+ import ProjectService from "../Services/ProjectService";
16
17
  import CodeRepository from "../../Models/DatabaseModels/CodeRepository";
17
18
  import CodeRepositoryType from "../../Types/CodeRepository/CodeRepositoryType";
18
19
  import URL from "../../Types/API/URL";
@@ -91,10 +92,21 @@ export default class GitHubAPI {
91
92
  }
92
93
 
93
94
  /*
94
- * Store the installation ID - we'll create repositories when user selects them
95
- * For now, redirect back to dashboard with installation ID
95
+ * Store the installation ID in the project
96
+ * This allows reuse when connecting additional repositories
96
97
  */
97
- const redirectUrl: string = `${DashboardClientUrl.toString()}/dashboard/${projectId}/code-repository?installation_id=${installationId}`;
98
+ await ProjectService.updateOneById({
99
+ id: new ObjectID(projectId),
100
+ data: {
101
+ gitHubAppInstallationId: installationId,
102
+ },
103
+ props: {
104
+ isRoot: true,
105
+ },
106
+ });
107
+
108
+ // Redirect back to dashboard with installation ID
109
+ const redirectUrl: string = `${DashboardClientUrl.toString()}/${projectId}/code-repository?installation_id=${installationId}`;
98
110
 
99
111
  return Response.redirect(req, res, URL.fromString(redirectUrl));
100
112
  } catch (error) {
@@ -116,12 +128,12 @@ export default class GitHubAPI {
116
128
  "/github/auth/install",
117
129
  async (req: ExpressRequest, res: ExpressResponse) => {
118
130
  try {
119
- if (!GitHubAppClientId) {
131
+ if (!GitHubAppName) {
120
132
  return Response.sendErrorResponse(
121
133
  req,
122
134
  res,
123
135
  new BadDataException(
124
- "GitHub App is not configured. Please set GITHUB_APP_CLIENT_ID.",
136
+ "GitHub App is not configured. Please set GITHUB_APP_NAME.",
125
137
  ),
126
138
  );
127
139
  }
@@ -146,7 +158,7 @@ export default class GitHubAPI {
146
158
  JSON.stringify({ projectId, userId }),
147
159
  ).toString("base64");
148
160
 
149
- const installUrl: string = `https://github.com/apps/${GitHubAppClientId}/installations/new?state=${state}`;
161
+ const installUrl: string = `https://github.com/apps/${GitHubAppName}/installations/new?state=${state}`;
150
162
 
151
163
  return Response.redirect(req, res, URL.fromString(installUrl));
152
164
  } catch (error) {
@@ -220,6 +232,8 @@ export default class GitHubAPI {
220
232
  body["defaultBranch"]?.toString();
221
233
  const repositoryUrl: string | undefined =
222
234
  body["repositoryUrl"]?.toString();
235
+ const description: string | undefined =
236
+ body["description"]?.toString();
223
237
 
224
238
  if (!projectId) {
225
239
  return Response.sendErrorResponse(
@@ -267,6 +281,10 @@ export default class GitHubAPI {
267
281
  codeRepository.repositoryUrl = URL.fromString(repositoryUrl);
268
282
  }
269
283
 
284
+ if (description) {
285
+ codeRepository.description = description;
286
+ }
287
+
270
288
  const createdRepository: CodeRepository =
271
289
  await CodeRepositoryService.create({
272
290
  data: codeRepository,