@oneuptime/common 11.3.25 → 11.3.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Models/DatabaseModels/AIConversation.ts +322 -0
- package/Models/DatabaseModels/AIConversationMessage.ts +495 -0
- package/Models/DatabaseModels/AIRun.ts +584 -0
- package/Models/DatabaseModels/AIRunEvent.ts +443 -0
- package/Models/DatabaseModels/IncidentEpisodeRoleMember.ts +1 -1
- package/Models/DatabaseModels/IncidentMember.ts +1 -1
- package/Models/DatabaseModels/IncomingCallPolicy.ts +13 -0
- package/Models/DatabaseModels/Index.ts +11 -0
- package/Models/DatabaseModels/LlmLog.ts +26 -0
- package/Models/DatabaseModels/LlmProvider.ts +2 -2
- package/Models/DatabaseModels/MigrationFailure.ts +170 -0
- package/Models/DatabaseModels/OnCallDutyPolicyExecutionLog.ts +51 -2
- package/Models/DatabaseModels/OnCallDutyPolicySchedule.ts +44 -0
- package/Models/DatabaseModels/OnCallDutyPolicyScheduleLayer.ts +6 -0
- package/Models/DatabaseModels/OnCallDutyPolicyScheduleLayerUser.ts +6 -0
- package/Models/DatabaseModels/OnCallDutyPolicyTimeLog.ts +1 -1
- package/Models/DatabaseModels/OnCallDutyPolicyUserOverride.ts +2 -2
- package/Server/API/AIChatAPI.ts +693 -0
- package/Server/API/AlertAPI.ts +1 -1
- package/Server/API/IncidentAPI.ts +2 -2
- package/Server/API/IncidentEpisodeAPI.ts +1 -1
- package/Server/API/LlmProviderAPI.ts +170 -0
- package/Server/API/MicrosoftTeamsAPI.ts +5 -0
- package/Server/API/ScheduledMaintenanceAPI.ts +1 -1
- package/Server/API/SlackAPI.ts +663 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1783363279075-AddAIChatModels.ts +245 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1783443471795-AddLlmProviderToAIConversation.ts +36 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1783453297388-AddAIChatWriteActionsAndWidgets.ts +46 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1783461767405-MigrationName.ts +119 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1783470000000-AddIncomingCallPolicyRoutingPhoneNumberUnique.ts +25 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1783510935686-FixNotNullForeignKeysOnDelete.ts +81 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1783515836148-MigrationName.ts +25 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1783523076215-AddMigrationFailureTable.ts +35 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +16 -0
- package/Server/Infrastructure/PostgresDatabase.ts +11 -0
- package/Server/Services/AIConversationMessageService.ts +39 -0
- package/Server/Services/AIConversationService.ts +63 -0
- package/Server/Services/AIRunEventService.ts +39 -0
- package/Server/Services/AIRunService.ts +39 -0
- package/Server/Services/AIService.ts +127 -33
- package/Server/Services/AnalyticsDatabaseService.ts +10 -1
- package/Server/Services/DatabaseService.ts +29 -1
- package/Server/Services/IncidentService.ts +1 -1
- package/Server/Services/IncomingCallPolicyEscalationRuleService.ts +75 -2
- package/Server/Services/IncomingCallPolicyService.ts +42 -1
- package/Server/Services/Index.ts +2 -0
- package/Server/Services/LlmProviderService.ts +110 -0
- package/Server/Services/MigrationFailureService.ts +9 -0
- package/Server/Services/MonitorProbeService.ts +33 -7
- package/Server/Services/MonitorService.ts +19 -7
- package/Server/Services/OnCallDutyPolicyEscalationRuleScheduleService.ts +65 -0
- package/Server/Services/OnCallDutyPolicyEscalationRuleService.ts +185 -41
- package/Server/Services/OnCallDutyPolicyEscalationRuleUserService.ts +23 -15
- package/Server/Services/OnCallDutyPolicyExecutionLogService.ts +39 -0
- package/Server/Services/OnCallDutyPolicyScheduleLayerService.ts +148 -0
- package/Server/Services/OnCallDutyPolicyScheduleLayerUserService.ts +11 -2
- package/Server/Services/OnCallDutyPolicyScheduleService.ts +502 -26
- package/Server/Services/OnCallDutyPolicyTimeLogService.ts +49 -7
- package/Server/Services/OnCallDutyPolicyUserOverrideService.ts +218 -4
- package/Server/Services/ProjectCallSMSConfigService.ts +82 -1
- package/Server/Services/ProjectService.ts +24 -0
- package/Server/Services/TeamMemberService.ts +6 -0
- package/Server/Services/UserNotificationRuleService.ts +13 -42
- package/Server/Services/UserOnCallLogService.ts +90 -0
- package/Server/Services/UserOnCallLogTimelineService.ts +43 -1
- package/Server/Types/AnalyticsDatabase/ModelPermission.ts +74 -9
- package/Server/Types/Database/QueryUtil.ts +57 -0
- package/Server/Utils/AI/AIChatPrivacyFilter.ts +28 -0
- package/Server/Utils/AI/AlertAIContextBuilder.ts +6 -1
- package/Server/Utils/AI/Chat/ChatAgentRunner.ts +1066 -0
- package/Server/Utils/AI/Chat/ObservabilityAssistant.ts +239 -0
- package/Server/Utils/AI/Chat/ObservabilityChatPrompt.ts +51 -0
- package/Server/Utils/AI/IncidentAIContextBuilder.ts +18 -3
- package/Server/Utils/AI/IncidentEpisodeAIContextBuilder.ts +6 -1
- package/Server/Utils/AI/ScheduledMaintenanceAIContextBuilder.ts +12 -2
- package/Server/Utils/AI/Toolbox/AlertTools.ts +201 -0
- package/Server/Utils/AI/Toolbox/AlertWriteTools.ts +174 -0
- package/Server/Utils/AI/Toolbox/ContextTools.ts +189 -0
- package/Server/Utils/AI/Toolbox/ExceptionTools.ts +149 -0
- package/Server/Utils/AI/Toolbox/IncidentTools.ts +386 -0
- package/Server/Utils/AI/Toolbox/IncidentWriteTools.ts +350 -0
- package/Server/Utils/AI/Toolbox/Index.ts +231 -0
- package/Server/Utils/AI/Toolbox/LogTools.ts +339 -0
- package/Server/Utils/AI/Toolbox/MetricTools.ts +179 -0
- package/Server/Utils/AI/Toolbox/MonitorTools.ts +193 -0
- package/Server/Utils/AI/Toolbox/RecentChangesTools.ts +208 -0
- package/Server/Utils/AI/Toolbox/Serializer.ts +299 -0
- package/Server/Utils/AI/Toolbox/ToolTypes.ts +249 -0
- package/Server/Utils/AI/Toolbox/TraceTools.ts +402 -0
- package/Server/Utils/AI/Toolbox/WidgetBuilder.ts +189 -0
- package/Server/Utils/Database/MigrationFailureLog.ts +240 -0
- package/Server/Utils/IncomingCallPhoneNumber.ts +41 -0
- package/Server/Utils/LLM/LLMService.ts +605 -96
- package/Server/Utils/Telemetry/IoTSnapshotScan.ts +12 -9
- package/Server/Utils/Telemetry/ProxmoxCephSnapshotScan.ts +12 -9
- package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.ts +512 -19
- package/Server/Utils/Workspace/Slack/Slack.ts +80 -0
- package/Server/Utils/Workspace/Slack/app-manifest.json +16 -1
- package/Tests/Server/Services/AnalyticsDatabaseService.test.ts +0 -8
- package/Tests/Server/Services/OnCallDutyPolicyScheduleLayerUserReorder.test.ts +233 -0
- package/Tests/Server/Services/OnCallDutyPolicyTimeLogServiceScoping.test.ts +242 -0
- package/Tests/Server/Services/OnCallDutyPolicyUserOverrideEdit.test.ts +198 -0
- package/Tests/Server/Services/UserOnCallLogClaimNotificationRule.test.ts +495 -0
- package/Tests/Server/Types/Database/QueryUtil.test.ts +74 -0
- package/Tests/Server/Utils/AI/AIChatModelACL.test.ts +42 -0
- package/Tests/Server/Utils/AI/ChatAgentHelpers.test.ts +89 -0
- package/Tests/Server/Utils/AI/LLMServiceBaseUrl.test.ts +139 -0
- package/Tests/Server/Utils/AI/LLMServiceToolCalling.test.ts +386 -0
- package/Tests/Server/Utils/AI/ToolArgsGetTimeRange.test.ts +62 -0
- package/Tests/Server/Utils/AI/ToolArgsScopeServiceIds.test.ts +79 -0
- package/Tests/Server/Utils/AI/ToolResultSerializer.test.ts +223 -0
- package/Tests/Types/Billing/SubscriptionStatus.test.ts +127 -0
- package/Tests/Types/DateExhaustiveTimezone.test.ts +700 -0
- package/Tests/Types/DateTimezoneWallClock.test.ts +99 -0
- package/Tests/Types/Events/Recurring.test.ts +22 -9
- package/Tests/Types/Metrics/RecordingRuleDefinition.test.ts +213 -0
- package/Tests/Types/OnCallDutyPolicy/LayerUtilAuditFixes.test.ts +291 -0
- package/Tests/Types/OnCallDutyPolicy/LayerUtilAuditFixesRound2.test.ts +398 -0
- package/Tests/Types/OnCallDutyPolicy/LayerUtilDSTWeekendGap.test.ts +114 -0
- package/Tests/Types/OnCallDutyPolicy/LayerUtilDSTWeeklyDayShift.test.ts +76 -0
- package/Tests/Types/OnCallDutyPolicy/LayerUtilDailyMutation.test.ts +128 -0
- package/Tests/Types/OnCallDutyPolicy/LayerUtilDailyProbe.test.ts +203 -0
- package/Tests/Types/OnCallDutyPolicy/LayerUtilDiffFuzz.test.ts +322 -0
- package/Tests/Types/OnCallDutyPolicy/LayerUtilEdgeCases.test.ts +280 -0
- package/Tests/Types/OnCallDutyPolicy/LayerUtilExhaustiveCurrentUser.test.ts +863 -0
- package/Tests/Types/OnCallDutyPolicy/LayerUtilExhaustiveDaily.test.ts +900 -0
- package/Tests/Types/OnCallDutyPolicy/LayerUtilExhaustiveMultiLayer.test.ts +1104 -0
- package/Tests/Types/OnCallDutyPolicy/LayerUtilExhaustiveRotation.test.ts +957 -0
- package/Tests/Types/OnCallDutyPolicy/LayerUtilExhaustiveWeekly.test.ts +1095 -0
- package/Tests/Types/OnCallDutyPolicy/LayerUtilInvariants.test.ts +232 -0
- package/Tests/Types/OnCallDutyPolicy/LayerUtilMergeAudit.test.ts +227 -0
- package/Tests/Types/OnCallDutyPolicy/LayerUtilMonthYearAudit.test.ts +255 -0
- package/Tests/Types/OnCallDutyPolicy/LayerUtilMultiLayerAudit.test.ts +388 -0
- package/Tests/Types/OnCallDutyPolicy/LayerUtilMultiLayerEdge.test.ts +300 -0
- package/Tests/Types/OnCallDutyPolicy/LayerUtilOvernightDSTAudit.test.ts +158 -0
- package/Tests/Types/OnCallDutyPolicy/LayerUtilRestrictedGapFix.test.ts +253 -0
- package/Tests/Types/OnCallDutyPolicy/LayerUtilRestrictedGapRepro.test.ts +157 -0
- package/Tests/Types/OnCallDutyPolicy/LayerUtilRotationFixes.test.ts +414 -0
- package/Tests/Types/OnCallDutyPolicy/LayerUtilTimezone.test.ts +243 -0
- package/Tests/Types/OnCallDutyPolicy/LayerUtilWeekendGapRepro.test.ts +112 -0
- package/Tests/Types/OnCallDutyPolicy/OverrideLensAudit.test.ts +117 -0
- package/Tests/Types/OnCallDutyPolicy/RestrictionTimes.test.ts +8 -6
- package/Tests/Types/OnCallDutyPolicy/RestrictionTimesDefaultDayAudit.test.ts +112 -0
- package/Tests/Types/OnCallDutyPolicy/RestrictionTimesExhaustive.test.ts +821 -0
- package/Tests/Types/OnCallDutyPolicy/RestrictionTimesMutationInvariant.test.ts +886 -0
- package/Tests/Types/OnCallDutyPolicy/UserOverrideUtil.test.ts +255 -0
- package/Tests/Types/OnCallDutyPolicy/UserOverrideUtilExhaustive.test.ts +1126 -0
- package/Types/AI/AIChatMessageRole.ts +6 -0
- package/Types/AI/AIChatMessageStatus.ts +32 -0
- package/Types/AI/AIChatPermissionMode.ts +69 -0
- package/Types/AI/AIChatTypes.ts +231 -0
- package/Types/AI/AIRunEventType.ts +17 -0
- package/Types/AI/AIRunStatus.ts +28 -0
- package/Types/AI/AIRunType.ts +6 -0
- package/Types/Date.ts +200 -15
- package/Types/LLM/LlmType.ts +6 -0
- package/Types/OnCallDutyPolicy/Layer.ts +790 -260
- package/Types/OnCallDutyPolicy/RestrictionTimes.ts +39 -13
- package/Types/OnCallDutyPolicy/UserOverrideUtil.ts +21 -5
- package/UI/Components/Events/RecurringFieldElement.tsx +16 -0
- package/UI/Components/Header/HeaderIconDropdownButton.tsx +22 -12
- package/UI/Components/Markdown.tsx/MarkdownViewer.tsx +35 -3
- package/UI/Components/ModelFormModal/ModelFormModal.tsx +8 -0
- package/UI/Components/Page/Page.tsx +14 -0
- package/UI/Components/RadioButtons/BasicRadioButtons.tsx +1 -1
- package/UI/Utils/LlmTypeDropdownOptions.ts +40 -0
- package/UI/Utils/TestLLMProvider.ts +59 -0
- package/build/dist/Models/DatabaseModels/AIConversation.js +345 -0
- package/build/dist/Models/DatabaseModels/AIConversation.js.map +1 -0
- package/build/dist/Models/DatabaseModels/AIConversationMessage.js +521 -0
- package/build/dist/Models/DatabaseModels/AIConversationMessage.js.map +1 -0
- package/build/dist/Models/DatabaseModels/AIRun.js +619 -0
- package/build/dist/Models/DatabaseModels/AIRun.js.map +1 -0
- package/build/dist/Models/DatabaseModels/AIRunEvent.js +469 -0
- package/build/dist/Models/DatabaseModels/AIRunEvent.js.map +1 -0
- package/build/dist/Models/DatabaseModels/IncidentEpisodeRoleMember.js +1 -1
- package/build/dist/Models/DatabaseModels/IncidentEpisodeRoleMember.js.map +1 -1
- package/build/dist/Models/DatabaseModels/IncidentMember.js +1 -1
- package/build/dist/Models/DatabaseModels/IncidentMember.js.map +1 -1
- package/build/dist/Models/DatabaseModels/IncomingCallPolicy.js +10 -0
- package/build/dist/Models/DatabaseModels/IncomingCallPolicy.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Index.js +10 -0
- package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
- package/build/dist/Models/DatabaseModels/LlmLog.js +28 -0
- package/build/dist/Models/DatabaseModels/LlmLog.js.map +1 -1
- package/build/dist/Models/DatabaseModels/LlmProvider.js +2 -2
- package/build/dist/Models/DatabaseModels/LlmProvider.js.map +1 -1
- package/build/dist/Models/DatabaseModels/MigrationFailure.js +196 -0
- package/build/dist/Models/DatabaseModels/MigrationFailure.js.map +1 -0
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyExecutionLog.js +52 -2
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyExecutionLog.js.map +1 -1
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicySchedule.js +45 -0
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicySchedule.js.map +1 -1
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyScheduleLayer.js +6 -0
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyScheduleLayer.js.map +1 -1
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyScheduleLayerUser.js +6 -0
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyScheduleLayerUser.js.map +1 -1
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyTimeLog.js +1 -1
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyTimeLog.js.map +1 -1
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyUserOverride.js +2 -2
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyUserOverride.js.map +1 -1
- package/build/dist/Server/API/AIChatAPI.js +498 -0
- package/build/dist/Server/API/AIChatAPI.js.map +1 -0
- package/build/dist/Server/API/AlertAPI.js +1 -1
- package/build/dist/Server/API/IncidentAPI.js +2 -2
- package/build/dist/Server/API/IncidentEpisodeAPI.js +1 -1
- package/build/dist/Server/API/LlmProviderAPI.js +108 -1
- package/build/dist/Server/API/LlmProviderAPI.js.map +1 -1
- package/build/dist/Server/API/MicrosoftTeamsAPI.js +4 -0
- package/build/dist/Server/API/MicrosoftTeamsAPI.js.map +1 -1
- package/build/dist/Server/API/ScheduledMaintenanceAPI.js +1 -1
- package/build/dist/Server/API/SlackAPI.js +442 -0
- package/build/dist/Server/API/SlackAPI.js.map +1 -1
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783363279075-AddAIChatModels.js +96 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783363279075-AddAIChatModels.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783443471795-AddLlmProviderToAIConversation.js +25 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783443471795-AddLlmProviderToAIConversation.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783453297388-AddAIChatWriteActionsAndWidgets.js +31 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783453297388-AddAIChatWriteActionsAndWidgets.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783461767405-MigrationName.js +46 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783461767405-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783470000000-AddIncomingCallPolicyRoutingPhoneNumberUnique.js +18 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783470000000-AddIncomingCallPolicyRoutingPhoneNumberUnique.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783510935686-FixNotNullForeignKeysOnDelete.js +38 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783510935686-FixNotNullForeignKeysOnDelete.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783515836148-MigrationName.js +16 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783515836148-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783523076215-AddMigrationFailureTable.js +18 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783523076215-AddMigrationFailureTable.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +16 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
- package/build/dist/Server/Infrastructure/PostgresDatabase.js +9 -0
- package/build/dist/Server/Infrastructure/PostgresDatabase.js.map +1 -1
- package/build/dist/Server/Services/AIConversationMessageService.js +34 -0
- package/build/dist/Server/Services/AIConversationMessageService.js.map +1 -0
- package/build/dist/Server/Services/AIConversationService.js +42 -0
- package/build/dist/Server/Services/AIConversationService.js.map +1 -0
- package/build/dist/Server/Services/AIRunEventService.js +34 -0
- package/build/dist/Server/Services/AIRunEventService.js.map +1 -0
- package/build/dist/Server/Services/AIRunService.js +34 -0
- package/build/dist/Server/Services/AIRunService.js.map +1 -0
- package/build/dist/Server/Services/AIService.js +84 -25
- package/build/dist/Server/Services/AIService.js.map +1 -1
- package/build/dist/Server/Services/AnalyticsDatabaseService.js +10 -1
- package/build/dist/Server/Services/AnalyticsDatabaseService.js.map +1 -1
- package/build/dist/Server/Services/DatabaseService.js +20 -1
- package/build/dist/Server/Services/DatabaseService.js.map +1 -1
- package/build/dist/Server/Services/IncidentService.js +1 -1
- package/build/dist/Server/Services/IncomingCallPolicyEscalationRuleService.js +55 -2
- package/build/dist/Server/Services/IncomingCallPolicyEscalationRuleService.js.map +1 -1
- package/build/dist/Server/Services/IncomingCallPolicyService.js +40 -0
- package/build/dist/Server/Services/IncomingCallPolicyService.js.map +1 -1
- package/build/dist/Server/Services/Index.js +2 -0
- package/build/dist/Server/Services/Index.js.map +1 -1
- package/build/dist/Server/Services/LlmProviderService.js +108 -0
- package/build/dist/Server/Services/LlmProviderService.js.map +1 -1
- package/build/dist/Server/Services/MigrationFailureService.js +9 -0
- package/build/dist/Server/Services/MigrationFailureService.js.map +1 -0
- package/build/dist/Server/Services/MonitorProbeService.js +33 -7
- package/build/dist/Server/Services/MonitorProbeService.js.map +1 -1
- package/build/dist/Server/Services/MonitorService.js +12 -5
- package/build/dist/Server/Services/MonitorService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleScheduleService.js +81 -22
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleScheduleService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleService.js +134 -31
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleUserService.js +21 -13
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleUserService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyExecutionLogService.js +36 -0
- package/build/dist/Server/Services/OnCallDutyPolicyExecutionLogService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyScheduleLayerService.js +121 -0
- package/build/dist/Server/Services/OnCallDutyPolicyScheduleLayerService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyScheduleLayerUserService.js +11 -2
- package/build/dist/Server/Services/OnCallDutyPolicyScheduleLayerUserService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyScheduleService.js +409 -36
- package/build/dist/Server/Services/OnCallDutyPolicyScheduleService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyTimeLogService.js +52 -8
- package/build/dist/Server/Services/OnCallDutyPolicyTimeLogService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyUserOverrideService.js +170 -3
- package/build/dist/Server/Services/OnCallDutyPolicyUserOverrideService.js.map +1 -1
- package/build/dist/Server/Services/ProjectCallSMSConfigService.js +72 -0
- package/build/dist/Server/Services/ProjectCallSMSConfigService.js.map +1 -1
- package/build/dist/Server/Services/ProjectService.js +25 -0
- package/build/dist/Server/Services/ProjectService.js.map +1 -1
- package/build/dist/Server/Services/TeamMemberService.js +6 -0
- package/build/dist/Server/Services/TeamMemberService.js.map +1 -1
- package/build/dist/Server/Services/UserNotificationRuleService.js +12 -30
- package/build/dist/Server/Services/UserNotificationRuleService.js.map +1 -1
- package/build/dist/Server/Services/UserOnCallLogService.js +75 -0
- package/build/dist/Server/Services/UserOnCallLogService.js.map +1 -1
- package/build/dist/Server/Services/UserOnCallLogTimelineService.js +31 -1
- package/build/dist/Server/Services/UserOnCallLogTimelineService.js.map +1 -1
- package/build/dist/Server/Types/AnalyticsDatabase/ModelPermission.js +50 -7
- package/build/dist/Server/Types/AnalyticsDatabase/ModelPermission.js.map +1 -1
- package/build/dist/Server/Types/Database/QueryUtil.js +45 -0
- package/build/dist/Server/Types/Database/QueryUtil.js.map +1 -1
- package/build/dist/Server/Utils/AI/AIChatPrivacyFilter.js +18 -0
- package/build/dist/Server/Utils/AI/AIChatPrivacyFilter.js.map +1 -0
- package/build/dist/Server/Utils/AI/AlertAIContextBuilder.js +6 -1
- package/build/dist/Server/Utils/AI/AlertAIContextBuilder.js.map +1 -1
- package/build/dist/Server/Utils/AI/Chat/ChatAgentRunner.js +756 -0
- package/build/dist/Server/Utils/AI/Chat/ChatAgentRunner.js.map +1 -0
- package/build/dist/Server/Utils/AI/Chat/ObservabilityAssistant.js +165 -0
- package/build/dist/Server/Utils/AI/Chat/ObservabilityAssistant.js.map +1 -0
- package/build/dist/Server/Utils/AI/Chat/ObservabilityChatPrompt.js +44 -0
- package/build/dist/Server/Utils/AI/Chat/ObservabilityChatPrompt.js.map +1 -0
- package/build/dist/Server/Utils/AI/IncidentAIContextBuilder.js +18 -3
- package/build/dist/Server/Utils/AI/IncidentAIContextBuilder.js.map +1 -1
- package/build/dist/Server/Utils/AI/IncidentEpisodeAIContextBuilder.js +6 -1
- package/build/dist/Server/Utils/AI/IncidentEpisodeAIContextBuilder.js.map +1 -1
- package/build/dist/Server/Utils/AI/ScheduledMaintenanceAIContextBuilder.js +12 -2
- package/build/dist/Server/Utils/AI/ScheduledMaintenanceAIContextBuilder.js.map +1 -1
- package/build/dist/Server/Utils/AI/Toolbox/AlertTools.js +167 -0
- package/build/dist/Server/Utils/AI/Toolbox/AlertTools.js.map +1 -0
- package/build/dist/Server/Utils/AI/Toolbox/AlertWriteTools.js +136 -0
- package/build/dist/Server/Utils/AI/Toolbox/AlertWriteTools.js.map +1 -0
- package/build/dist/Server/Utils/AI/Toolbox/ContextTools.js +141 -0
- package/build/dist/Server/Utils/AI/Toolbox/ContextTools.js.map +1 -0
- package/build/dist/Server/Utils/AI/Toolbox/ExceptionTools.js +117 -0
- package/build/dist/Server/Utils/AI/Toolbox/ExceptionTools.js.map +1 -0
- package/build/dist/Server/Utils/AI/Toolbox/IncidentTools.js +318 -0
- package/build/dist/Server/Utils/AI/Toolbox/IncidentTools.js.map +1 -0
- package/build/dist/Server/Utils/AI/Toolbox/IncidentWriteTools.js +280 -0
- package/build/dist/Server/Utils/AI/Toolbox/IncidentWriteTools.js.map +1 -0
- package/build/dist/Server/Utils/AI/Toolbox/Index.js +153 -0
- package/build/dist/Server/Utils/AI/Toolbox/Index.js.map +1 -0
- package/build/dist/Server/Utils/AI/Toolbox/LogTools.js +246 -0
- package/build/dist/Server/Utils/AI/Toolbox/LogTools.js.map +1 -0
- package/build/dist/Server/Utils/AI/Toolbox/MetricTools.js +120 -0
- package/build/dist/Server/Utils/AI/Toolbox/MetricTools.js.map +1 -0
- package/build/dist/Server/Utils/AI/Toolbox/MonitorTools.js +158 -0
- package/build/dist/Server/Utils/AI/Toolbox/MonitorTools.js.map +1 -0
- package/build/dist/Server/Utils/AI/Toolbox/RecentChangesTools.js +165 -0
- package/build/dist/Server/Utils/AI/Toolbox/RecentChangesTools.js.map +1 -0
- package/build/dist/Server/Utils/AI/Toolbox/Serializer.js +228 -0
- package/build/dist/Server/Utils/AI/Toolbox/Serializer.js.map +1 -0
- package/build/dist/Server/Utils/AI/Toolbox/ToolTypes.js +142 -0
- package/build/dist/Server/Utils/AI/Toolbox/ToolTypes.js.map +1 -0
- package/build/dist/Server/Utils/AI/Toolbox/TraceTools.js +309 -0
- package/build/dist/Server/Utils/AI/Toolbox/TraceTools.js.map +1 -0
- package/build/dist/Server/Utils/AI/Toolbox/WidgetBuilder.js +120 -0
- package/build/dist/Server/Utils/AI/Toolbox/WidgetBuilder.js.map +1 -0
- package/build/dist/Server/Utils/Database/MigrationFailureLog.js +174 -0
- package/build/dist/Server/Utils/Database/MigrationFailureLog.js.map +1 -0
- package/build/dist/Server/Utils/IncomingCallPhoneNumber.js +30 -0
- package/build/dist/Server/Utils/IncomingCallPhoneNumber.js.map +1 -0
- package/build/dist/Server/Utils/LLM/LLMService.js +452 -92
- package/build/dist/Server/Utils/LLM/LLMService.js.map +1 -1
- package/build/dist/Server/Utils/Telemetry/IoTSnapshotScan.js +11 -8
- package/build/dist/Server/Utils/Telemetry/IoTSnapshotScan.js.map +1 -1
- package/build/dist/Server/Utils/Telemetry/ProxmoxCephSnapshotScan.js +11 -8
- package/build/dist/Server/Utils/Telemetry/ProxmoxCephSnapshotScan.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js +378 -15
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/Slack/Slack.js +59 -0
- package/build/dist/Server/Utils/Workspace/Slack/Slack.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/Slack/app-manifest.json +16 -1
- package/build/dist/Types/AI/AIChatMessageRole.js +7 -0
- package/build/dist/Types/AI/AIChatMessageRole.js.map +1 -0
- package/build/dist/Types/AI/AIChatMessageStatus.js +27 -0
- package/build/dist/Types/AI/AIChatMessageStatus.js.map +1 -0
- package/build/dist/Types/AI/AIChatPermissionMode.js +53 -0
- package/build/dist/Types/AI/AIChatPermissionMode.js.map +1 -0
- package/build/dist/Types/AI/AIChatTypes.js +74 -0
- package/build/dist/Types/AI/AIChatTypes.js.map +1 -0
- package/build/dist/Types/AI/AIRunEventType.js +18 -0
- package/build/dist/Types/AI/AIRunEventType.js.map +1 -0
- package/build/dist/Types/AI/AIRunStatus.js +26 -0
- package/build/dist/Types/AI/AIRunStatus.js.map +1 -0
- package/build/dist/Types/AI/AIRunType.js +7 -0
- package/build/dist/Types/AI/AIRunType.js.map +1 -0
- package/build/dist/Types/Date.js +153 -15
- package/build/dist/Types/Date.js.map +1 -1
- package/build/dist/Types/LLM/LlmType.js +6 -0
- package/build/dist/Types/LLM/LlmType.js.map +1 -1
- package/build/dist/Types/OnCallDutyPolicy/Layer.js +602 -171
- package/build/dist/Types/OnCallDutyPolicy/Layer.js.map +1 -1
- package/build/dist/Types/OnCallDutyPolicy/RestrictionTimes.js +27 -13
- package/build/dist/Types/OnCallDutyPolicy/RestrictionTimes.js.map +1 -1
- package/build/dist/Types/OnCallDutyPolicy/UserOverrideUtil.js +20 -5
- package/build/dist/Types/OnCallDutyPolicy/UserOverrideUtil.js.map +1 -1
- package/build/dist/UI/Components/Events/RecurringFieldElement.js +13 -0
- package/build/dist/UI/Components/Events/RecurringFieldElement.js.map +1 -1
- package/build/dist/UI/Components/Header/HeaderIconDropdownButton.js +10 -5
- package/build/dist/UI/Components/Header/HeaderIconDropdownButton.js.map +1 -1
- package/build/dist/UI/Components/Markdown.tsx/MarkdownViewer.js +18 -4
- package/build/dist/UI/Components/Markdown.tsx/MarkdownViewer.js.map +1 -1
- package/build/dist/UI/Components/ModelFormModal/ModelFormModal.js.map +1 -1
- package/build/dist/UI/Components/Page/Page.js +3 -1
- package/build/dist/UI/Components/Page/Page.js.map +1 -1
- package/build/dist/UI/Components/RadioButtons/BasicRadioButtons.js +1 -1
- package/build/dist/UI/Components/RadioButtons/BasicRadioButtons.js.map +1 -1
- package/build/dist/UI/Utils/LlmTypeDropdownOptions.js +38 -0
- package/build/dist/UI/Utils/LlmTypeDropdownOptions.js.map +1 -0
- package/build/dist/UI/Utils/TestLLMProvider.js +37 -0
- package/build/dist/UI/Utils/TestLLMProvider.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
import Log from "../../../../Models/AnalyticsModels/Log";
|
|
2
|
+
import DatabaseRequestType from "../../../Types/BaseDatabase/DatabaseRequestType";
|
|
3
|
+
import ModelPermission from "../../../Types/AnalyticsDatabase/ModelPermission";
|
|
4
|
+
import InBetween from "../../../../Types/BaseDatabase/InBetween";
|
|
5
|
+
import Includes from "../../../../Types/BaseDatabase/Includes";
|
|
6
|
+
import Search from "../../../../Types/BaseDatabase/Search";
|
|
7
|
+
import SortOrder from "../../../../Types/BaseDatabase/SortOrder";
|
|
8
|
+
import { JSONObject } from "../../../../Types/JSON";
|
|
9
|
+
import ObjectID from "../../../../Types/ObjectID";
|
|
10
|
+
import Permission from "../../../../Types/Permission";
|
|
11
|
+
import {
|
|
12
|
+
AIChatCitationTarget,
|
|
13
|
+
AIChatCitationTargetType,
|
|
14
|
+
AIChatWidgetSeries,
|
|
15
|
+
} from "../../../../Types/AI/AIChatTypes";
|
|
16
|
+
import LogService from "../../../Services/LogService";
|
|
17
|
+
import LogAggregationService, {
|
|
18
|
+
HistogramBucket,
|
|
19
|
+
} from "../../../Services/LogAggregationService";
|
|
20
|
+
import ToolResultSerializer, { SerializedResult } from "./Serializer";
|
|
21
|
+
import WidgetBuilder from "./WidgetBuilder";
|
|
22
|
+
import {
|
|
23
|
+
ObservabilityTool,
|
|
24
|
+
TimeRangeSchemaProperties,
|
|
25
|
+
ToolArgs,
|
|
26
|
+
ToolContext,
|
|
27
|
+
ToolExecutionResult,
|
|
28
|
+
} from "./ToolTypes";
|
|
29
|
+
|
|
30
|
+
// Keep pivoted histogram rows under the serializer's 50-row cap.
|
|
31
|
+
const MAX_HISTOGRAM_BUCKETS: number = 48;
|
|
32
|
+
|
|
33
|
+
const LOG_READ_PERMISSIONS: Array<Permission> = [
|
|
34
|
+
Permission.ProjectOwner,
|
|
35
|
+
Permission.ProjectAdmin,
|
|
36
|
+
Permission.ProjectMember,
|
|
37
|
+
Permission.Viewer,
|
|
38
|
+
Permission.TelemetryAdmin,
|
|
39
|
+
Permission.TelemetryMember,
|
|
40
|
+
Permission.TelemetryViewer,
|
|
41
|
+
Permission.ReadTelemetryServiceLog,
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
export const SearchLogsTool: ObservabilityTool = {
|
|
45
|
+
name: "search_logs",
|
|
46
|
+
description:
|
|
47
|
+
"Search raw log lines. Filter by time range, severity, body text, trace ID or service. Returns the most recent matching lines. Always pass an explicit time range when investigating a specific window.",
|
|
48
|
+
inputSchema: {
|
|
49
|
+
type: "object",
|
|
50
|
+
properties: {
|
|
51
|
+
...TimeRangeSchemaProperties,
|
|
52
|
+
severityTexts: {
|
|
53
|
+
type: "array",
|
|
54
|
+
items: { type: "string" },
|
|
55
|
+
description: 'Filter by severity, e.g. ["Error", "Fatal"] or ["Warn"].',
|
|
56
|
+
},
|
|
57
|
+
bodySearchText: {
|
|
58
|
+
type: "string",
|
|
59
|
+
description: "Only logs whose body contains this text.",
|
|
60
|
+
},
|
|
61
|
+
traceId: {
|
|
62
|
+
type: "string",
|
|
63
|
+
description: "Only logs belonging to this trace.",
|
|
64
|
+
},
|
|
65
|
+
serviceId: {
|
|
66
|
+
type: "string",
|
|
67
|
+
description:
|
|
68
|
+
"Only logs from this telemetry service (resolve names via lookup_context first).",
|
|
69
|
+
},
|
|
70
|
+
limit: {
|
|
71
|
+
type: "number",
|
|
72
|
+
description: "Maximum log lines to return (default 25, max 50).",
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
requiredPermissions: LOG_READ_PERMISSIONS,
|
|
77
|
+
execute: async (
|
|
78
|
+
args: JSONObject,
|
|
79
|
+
ctx: ToolContext,
|
|
80
|
+
): Promise<ToolExecutionResult> => {
|
|
81
|
+
const { startTime, endTime } = ToolArgs.getTimeRange(args, {
|
|
82
|
+
defaultHours: 1,
|
|
83
|
+
maxDays: 30,
|
|
84
|
+
});
|
|
85
|
+
const limit: number = ToolArgs.getNumber(args, "limit", {
|
|
86
|
+
defaultValue: 25,
|
|
87
|
+
min: 1,
|
|
88
|
+
max: 50,
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
const query: JSONObject = {
|
|
92
|
+
time: new InBetween(startTime, endTime),
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const severityTexts: Array<string> | undefined = ToolArgs.getStringArray(
|
|
96
|
+
args,
|
|
97
|
+
"severityTexts",
|
|
98
|
+
);
|
|
99
|
+
if (severityTexts) {
|
|
100
|
+
query["severityText"] = new Includes(severityTexts);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const bodySearchText: string | undefined = ToolArgs.getString(
|
|
104
|
+
args,
|
|
105
|
+
"bodySearchText",
|
|
106
|
+
);
|
|
107
|
+
if (bodySearchText) {
|
|
108
|
+
query["body"] = new Search(bodySearchText);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const traceId: string | undefined = ToolArgs.getString(args, "traceId");
|
|
112
|
+
if (traceId) {
|
|
113
|
+
query["traceId"] = traceId;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const serviceId: ObjectID | undefined = ToolArgs.getObjectID(
|
|
117
|
+
args,
|
|
118
|
+
"serviceId",
|
|
119
|
+
);
|
|
120
|
+
if (serviceId) {
|
|
121
|
+
query["primaryEntityId"] = serviceId;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const logs: Array<Log> = await LogService.findBy({
|
|
125
|
+
query: query as never,
|
|
126
|
+
select: {
|
|
127
|
+
time: true,
|
|
128
|
+
severityText: true,
|
|
129
|
+
body: true,
|
|
130
|
+
traceId: true,
|
|
131
|
+
spanId: true,
|
|
132
|
+
primaryEntityId: true,
|
|
133
|
+
} as never,
|
|
134
|
+
sort: {
|
|
135
|
+
time: SortOrder.Descending,
|
|
136
|
+
} as never,
|
|
137
|
+
limit: limit,
|
|
138
|
+
skip: 0,
|
|
139
|
+
props: ctx.props,
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
const rows: Array<JSONObject> = logs.map((log: Log) => {
|
|
143
|
+
return {
|
|
144
|
+
time: log.time,
|
|
145
|
+
severity: log.severityText,
|
|
146
|
+
body: log.body,
|
|
147
|
+
traceId: log.traceId,
|
|
148
|
+
spanId: log.spanId,
|
|
149
|
+
};
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
const serialized: SerializedResult =
|
|
153
|
+
ToolResultSerializer.serializeRows(rows);
|
|
154
|
+
|
|
155
|
+
const logsLink: AIChatCitationTarget = {
|
|
156
|
+
type: AIChatCitationTargetType.Logs,
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
return {
|
|
160
|
+
dataForLlm: serialized.text,
|
|
161
|
+
rowCount: serialized.rowCount,
|
|
162
|
+
citationLabel: `Logs ${startTime.toISOString()} – ${endTime.toISOString()} (${serialized.rowCount} shown)`,
|
|
163
|
+
citationTarget: logsLink,
|
|
164
|
+
redactionCount: serialized.redactionCount,
|
|
165
|
+
isTruncated: serialized.isTruncated,
|
|
166
|
+
widget:
|
|
167
|
+
rows.length > 0
|
|
168
|
+
? WidgetBuilder.table({
|
|
169
|
+
title: `Logs (${rows.length})`,
|
|
170
|
+
description: `${startTime.toISOString()} – ${endTime.toISOString()}`,
|
|
171
|
+
columns: [
|
|
172
|
+
{ key: "time", title: "Time", type: "date" },
|
|
173
|
+
{ key: "severity", title: "Severity", type: "text" },
|
|
174
|
+
{ key: "body", title: "Message", type: "text" },
|
|
175
|
+
{ key: "traceId", title: "Trace", type: "text" },
|
|
176
|
+
],
|
|
177
|
+
rows: rows,
|
|
178
|
+
link: logsLink,
|
|
179
|
+
})
|
|
180
|
+
: undefined,
|
|
181
|
+
};
|
|
182
|
+
},
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
export const LogHistogramTool: ObservabilityTool = {
|
|
186
|
+
name: "log_histogram",
|
|
187
|
+
description:
|
|
188
|
+
"Get log volume over time, split by severity. Use this to spot error spikes and quiet periods before drilling into raw logs.",
|
|
189
|
+
inputSchema: {
|
|
190
|
+
type: "object",
|
|
191
|
+
properties: {
|
|
192
|
+
...TimeRangeSchemaProperties,
|
|
193
|
+
severityTexts: {
|
|
194
|
+
type: "array",
|
|
195
|
+
items: { type: "string" },
|
|
196
|
+
description: "Filter to these severities before bucketing.",
|
|
197
|
+
},
|
|
198
|
+
bodySearchText: {
|
|
199
|
+
type: "string",
|
|
200
|
+
description: "Only count logs whose body contains this text.",
|
|
201
|
+
},
|
|
202
|
+
serviceId: {
|
|
203
|
+
type: "string",
|
|
204
|
+
description: "Only logs from this telemetry service.",
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
},
|
|
208
|
+
requiredPermissions: LOG_READ_PERMISSIONS,
|
|
209
|
+
execute: async (
|
|
210
|
+
args: JSONObject,
|
|
211
|
+
ctx: ToolContext,
|
|
212
|
+
): Promise<ToolExecutionResult> => {
|
|
213
|
+
const { startTime, endTime } = ToolArgs.getTimeRange(args, {
|
|
214
|
+
defaultHours: 24,
|
|
215
|
+
maxDays: 30,
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
const windowMinutes: number =
|
|
219
|
+
(endTime.getTime() - startTime.getTime()) / (60 * 1000);
|
|
220
|
+
/*
|
|
221
|
+
* Bound the number of time buckets. getHistogram returns one row per
|
|
222
|
+
* (bucket, severity); after we pivot to one row per bucket that is at most
|
|
223
|
+
* MAX_HISTOGRAM_BUCKETS rows, which stays under the serializer's row cap so
|
|
224
|
+
* the most recent buckets are never dropped (spike detection reads the tail
|
|
225
|
+
* of the window).
|
|
226
|
+
*/
|
|
227
|
+
const bucketSizeInMinutes: number = Math.max(
|
|
228
|
+
1,
|
|
229
|
+
Math.ceil(windowMinutes / MAX_HISTOGRAM_BUCKETS),
|
|
230
|
+
);
|
|
231
|
+
|
|
232
|
+
const serviceId: ObjectID | undefined = ToolArgs.getObjectID(
|
|
233
|
+
args,
|
|
234
|
+
"serviceId",
|
|
235
|
+
);
|
|
236
|
+
|
|
237
|
+
/*
|
|
238
|
+
* getHistogram builds raw aggregation SQL and skips the model layer's
|
|
239
|
+
* owned-scope filter, so a label-restricted user would otherwise see
|
|
240
|
+
* project-wide volume. Constrain to the services this user may read.
|
|
241
|
+
*/
|
|
242
|
+
const accessibleServiceIds: Array<ObjectID> | null =
|
|
243
|
+
await ModelPermission.getAccessibleServiceIdsForAnalyticsModel(
|
|
244
|
+
Log,
|
|
245
|
+
ctx.props,
|
|
246
|
+
DatabaseRequestType.Read,
|
|
247
|
+
);
|
|
248
|
+
|
|
249
|
+
const buckets: Array<HistogramBucket> =
|
|
250
|
+
await LogAggregationService.getHistogram({
|
|
251
|
+
projectId: ctx.projectId,
|
|
252
|
+
startTime: startTime,
|
|
253
|
+
endTime: endTime,
|
|
254
|
+
bucketSizeInMinutes: bucketSizeInMinutes,
|
|
255
|
+
severityTexts: ToolArgs.getStringArray(args, "severityTexts"),
|
|
256
|
+
bodySearchText: ToolArgs.getString(args, "bodySearchText"),
|
|
257
|
+
serviceIds: ToolArgs.scopeServiceIds(accessibleServiceIds, serviceId),
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
/*
|
|
261
|
+
* Pivot (time, severity, count) rows into one row per time bucket with a
|
|
262
|
+
* column per severity, e.g. "time=… | Error=12 | Warn=3". This is both more
|
|
263
|
+
* compact for the model and collapses the row count from
|
|
264
|
+
* buckets×severities down to just buckets.
|
|
265
|
+
*/
|
|
266
|
+
const rowsByTime: Map<string, JSONObject> = new Map();
|
|
267
|
+
for (const bucket of buckets) {
|
|
268
|
+
let row: JSONObject | undefined = rowsByTime.get(bucket.time);
|
|
269
|
+
if (!row) {
|
|
270
|
+
row = { time: bucket.time };
|
|
271
|
+
rowsByTime.set(bucket.time, row);
|
|
272
|
+
}
|
|
273
|
+
row[bucket.severity || "Unspecified"] = bucket.count;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
const rows: Array<JSONObject> = Array.from(rowsByTime.values()).sort(
|
|
277
|
+
(a: JSONObject, b: JSONObject) => {
|
|
278
|
+
return String(a["time"]).localeCompare(String(b["time"]));
|
|
279
|
+
},
|
|
280
|
+
);
|
|
281
|
+
|
|
282
|
+
const serialized: SerializedResult =
|
|
283
|
+
ToolResultSerializer.serializeRows(rows);
|
|
284
|
+
|
|
285
|
+
/*
|
|
286
|
+
* Pivot the per-bucket rows into one series per severity so the widget can
|
|
287
|
+
* render a stacked bar chart (Error on top of Warn on top of Info, etc).
|
|
288
|
+
*/
|
|
289
|
+
const severityKeys: Array<string> = Array.from(
|
|
290
|
+
new Set(
|
|
291
|
+
rows.flatMap((row: JSONObject) => {
|
|
292
|
+
return Object.keys(row).filter((key: string) => {
|
|
293
|
+
return key !== "time";
|
|
294
|
+
});
|
|
295
|
+
}),
|
|
296
|
+
),
|
|
297
|
+
);
|
|
298
|
+
|
|
299
|
+
const series: Array<AIChatWidgetSeries> = severityKeys.map(
|
|
300
|
+
(severity: string) => {
|
|
301
|
+
return {
|
|
302
|
+
name: severity,
|
|
303
|
+
points: rows.map((row: JSONObject) => {
|
|
304
|
+
return {
|
|
305
|
+
x: String(row["time"]),
|
|
306
|
+
y:
|
|
307
|
+
typeof row[severity] === "number"
|
|
308
|
+
? (row[severity] as number)
|
|
309
|
+
: 0,
|
|
310
|
+
};
|
|
311
|
+
}),
|
|
312
|
+
};
|
|
313
|
+
},
|
|
314
|
+
);
|
|
315
|
+
|
|
316
|
+
return {
|
|
317
|
+
dataForLlm: serialized.text,
|
|
318
|
+
rowCount: serialized.rowCount,
|
|
319
|
+
citationLabel: `Log volume by severity, ${startTime.toISOString()} – ${endTime.toISOString()}`,
|
|
320
|
+
citationTarget: {
|
|
321
|
+
type: AIChatCitationTargetType.Logs,
|
|
322
|
+
},
|
|
323
|
+
redactionCount: serialized.redactionCount,
|
|
324
|
+
isTruncated: serialized.isTruncated,
|
|
325
|
+
widget:
|
|
326
|
+
series.length > 0 && rows.length > 0
|
|
327
|
+
? WidgetBuilder.bars({
|
|
328
|
+
title: "Log volume by severity",
|
|
329
|
+
description: `${startTime.toISOString()} – ${endTime.toISOString()}`,
|
|
330
|
+
series: series,
|
|
331
|
+
stacked: true,
|
|
332
|
+
xIsTime: true,
|
|
333
|
+
unit: "logs",
|
|
334
|
+
link: { type: AIChatCitationTargetType.Logs },
|
|
335
|
+
})
|
|
336
|
+
: undefined,
|
|
337
|
+
};
|
|
338
|
+
},
|
|
339
|
+
};
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import Metric from "../../../../Models/AnalyticsModels/Metric";
|
|
2
|
+
import AggregationType from "../../../../Types/BaseDatabase/AggregationType";
|
|
3
|
+
import InBetween from "../../../../Types/BaseDatabase/InBetween";
|
|
4
|
+
import { JSONObject } from "../../../../Types/JSON";
|
|
5
|
+
import ObjectID from "../../../../Types/ObjectID";
|
|
6
|
+
import Permission from "../../../../Types/Permission";
|
|
7
|
+
import BadDataException from "../../../../Types/Exception/BadDataException";
|
|
8
|
+
import {
|
|
9
|
+
AIChatCitationTargetType,
|
|
10
|
+
AIChatWidgetPoint,
|
|
11
|
+
} from "../../../../Types/AI/AIChatTypes";
|
|
12
|
+
import AggregateBy from "../../../Types/AnalyticsDatabase/AggregateBy";
|
|
13
|
+
import MetricService from "../../../Services/MetricService";
|
|
14
|
+
import AggregatedResult from "../../../../Types/BaseDatabase/AggregatedResult";
|
|
15
|
+
import AggregatedModel from "../../../../Types/BaseDatabase/AggregatedModel";
|
|
16
|
+
import ToolResultSerializer, { SerializedResult } from "./Serializer";
|
|
17
|
+
import WidgetBuilder from "./WidgetBuilder";
|
|
18
|
+
import OneUptimeDate from "../../../../Types/Date";
|
|
19
|
+
import {
|
|
20
|
+
ObservabilityTool,
|
|
21
|
+
TimeRangeSchemaProperties,
|
|
22
|
+
ToolArgs,
|
|
23
|
+
ToolContext,
|
|
24
|
+
ToolExecutionResult,
|
|
25
|
+
} from "./ToolTypes";
|
|
26
|
+
|
|
27
|
+
/*
|
|
28
|
+
* Note: metric read access is gated on ReadTelemetryServiceTraces — this
|
|
29
|
+
* mirrors the guard on the dashboard's /telemetry/metrics/* routes.
|
|
30
|
+
*/
|
|
31
|
+
const METRIC_READ_PERMISSIONS: Array<Permission> = [
|
|
32
|
+
Permission.ProjectOwner,
|
|
33
|
+
Permission.ProjectAdmin,
|
|
34
|
+
Permission.ProjectMember,
|
|
35
|
+
Permission.Viewer,
|
|
36
|
+
Permission.TelemetryAdmin,
|
|
37
|
+
Permission.TelemetryMember,
|
|
38
|
+
Permission.TelemetryViewer,
|
|
39
|
+
Permission.ReadTelemetryServiceTraces,
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
export const QueryMetricsTool: ObservabilityTool = {
|
|
43
|
+
name: "query_metrics",
|
|
44
|
+
description:
|
|
45
|
+
"Aggregate a metric over time: Avg, Max, Min, Sum, Count or P50/P90/P95/P99 percentiles (histogram-aware). Requires the exact metric name — discover names via lookup_context. Monitor metrics use reserved names like oneuptime.monitor.response.time with the monitor's ID as entityId.",
|
|
46
|
+
inputSchema: {
|
|
47
|
+
type: "object",
|
|
48
|
+
properties: {
|
|
49
|
+
...TimeRangeSchemaProperties,
|
|
50
|
+
metricName: {
|
|
51
|
+
type: "string",
|
|
52
|
+
description: "Exact metric name (required).",
|
|
53
|
+
},
|
|
54
|
+
aggregationType: {
|
|
55
|
+
type: "string",
|
|
56
|
+
enum: ["Avg", "Max", "Min", "Sum", "Count", "P50", "P90", "P95", "P99"],
|
|
57
|
+
description: "How to aggregate (default Avg).",
|
|
58
|
+
},
|
|
59
|
+
entityId: {
|
|
60
|
+
type: "string",
|
|
61
|
+
description:
|
|
62
|
+
"Only data points from this service/host/monitor (its OneUptime ID).",
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
required: ["metricName"],
|
|
66
|
+
},
|
|
67
|
+
requiredPermissions: METRIC_READ_PERMISSIONS,
|
|
68
|
+
execute: async (
|
|
69
|
+
args: JSONObject,
|
|
70
|
+
ctx: ToolContext,
|
|
71
|
+
): Promise<ToolExecutionResult> => {
|
|
72
|
+
const metricName: string | undefined = ToolArgs.getString(
|
|
73
|
+
args,
|
|
74
|
+
"metricName",
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
if (!metricName) {
|
|
78
|
+
throw new BadDataException(
|
|
79
|
+
"metricName is required. Use lookup_context with type 'metricNames' to discover metric names.",
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const { startTime, endTime } = ToolArgs.getTimeRange(args, {
|
|
84
|
+
defaultHours: 24,
|
|
85
|
+
maxDays: 30,
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
const aggregationTypeString: string =
|
|
89
|
+
ToolArgs.getString(args, "aggregationType") || "Avg";
|
|
90
|
+
|
|
91
|
+
if (
|
|
92
|
+
!Object.values(AggregationType).includes(
|
|
93
|
+
aggregationTypeString as AggregationType,
|
|
94
|
+
)
|
|
95
|
+
) {
|
|
96
|
+
throw new BadDataException(
|
|
97
|
+
`Invalid aggregationType: ${aggregationTypeString}`,
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/*
|
|
102
|
+
* The time filter must be part of the query's WHERE clause. aggregateBy's
|
|
103
|
+
* startTimestamp/endTimestamp only define the bucket grid — without an
|
|
104
|
+
* explicit `time` filter the percentile/aggregate scans the metric's whole
|
|
105
|
+
* retention and mixes in data outside the requested window.
|
|
106
|
+
*/
|
|
107
|
+
const query: JSONObject = {
|
|
108
|
+
name: metricName,
|
|
109
|
+
time: new InBetween(startTime, endTime),
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const entityId: ObjectID | undefined = ToolArgs.getObjectID(
|
|
113
|
+
args,
|
|
114
|
+
"entityId",
|
|
115
|
+
);
|
|
116
|
+
if (entityId) {
|
|
117
|
+
query["primaryEntityId"] = entityId;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const aggregateBy: AggregateBy<Metric> = {
|
|
121
|
+
aggregateColumnName: "value",
|
|
122
|
+
aggregationType: aggregationTypeString as AggregationType,
|
|
123
|
+
aggregationTimestampColumnName: "time",
|
|
124
|
+
startTimestamp: startTime,
|
|
125
|
+
endTimestamp: endTime,
|
|
126
|
+
query: query as never,
|
|
127
|
+
limit: 200,
|
|
128
|
+
skip: 0,
|
|
129
|
+
props: ctx.props,
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
const result: AggregatedResult =
|
|
133
|
+
await MetricService.aggregateBy(aggregateBy);
|
|
134
|
+
|
|
135
|
+
const rows: Array<JSONObject> = result.data.map((item: AggregatedModel) => {
|
|
136
|
+
return {
|
|
137
|
+
timestamp: item.timestamp,
|
|
138
|
+
value: item.value,
|
|
139
|
+
};
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
const serialized: SerializedResult =
|
|
143
|
+
ToolResultSerializer.serializeRows(rows);
|
|
144
|
+
|
|
145
|
+
const points: Array<AIChatWidgetPoint> = result.data.map(
|
|
146
|
+
(item: AggregatedModel) => {
|
|
147
|
+
return {
|
|
148
|
+
x: OneUptimeDate.toString(OneUptimeDate.fromString(item.timestamp)),
|
|
149
|
+
y: typeof item.value === "number" ? item.value : null,
|
|
150
|
+
};
|
|
151
|
+
},
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
const seriesName: string = entityId
|
|
155
|
+
? `${aggregationTypeString}(${metricName}) · ${entityId.toString()}`
|
|
156
|
+
: `${aggregationTypeString}(${metricName})`;
|
|
157
|
+
|
|
158
|
+
return {
|
|
159
|
+
dataForLlm: serialized.text,
|
|
160
|
+
rowCount: serialized.rowCount,
|
|
161
|
+
citationLabel: `${aggregationTypeString}(${metricName}), ${startTime.toISOString()} – ${endTime.toISOString()}`,
|
|
162
|
+
citationTarget: {
|
|
163
|
+
type: AIChatCitationTargetType.Metrics,
|
|
164
|
+
},
|
|
165
|
+
redactionCount: serialized.redactionCount,
|
|
166
|
+
isTruncated: serialized.isTruncated,
|
|
167
|
+
widget:
|
|
168
|
+
points.length > 0
|
|
169
|
+
? WidgetBuilder.timeSeries({
|
|
170
|
+
title: `${aggregationTypeString} of ${metricName}`,
|
|
171
|
+
description: `${startTime.toISOString()} – ${endTime.toISOString()}`,
|
|
172
|
+
series: [{ name: seriesName, points: points }],
|
|
173
|
+
valueLabel: aggregationTypeString,
|
|
174
|
+
link: { type: AIChatCitationTargetType.Metrics },
|
|
175
|
+
})
|
|
176
|
+
: undefined,
|
|
177
|
+
};
|
|
178
|
+
},
|
|
179
|
+
};
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import Monitor from "../../../../Models/DatabaseModels/Monitor";
|
|
2
|
+
import MonitorStatusTimeline from "../../../../Models/DatabaseModels/MonitorStatusTimeline";
|
|
3
|
+
import { JSONObject } from "../../../../Types/JSON";
|
|
4
|
+
import ObjectID from "../../../../Types/ObjectID";
|
|
5
|
+
import Permission from "../../../../Types/Permission";
|
|
6
|
+
import SortOrder from "../../../../Types/BaseDatabase/SortOrder";
|
|
7
|
+
import { AIChatCitationTargetType } from "../../../../Types/AI/AIChatTypes";
|
|
8
|
+
import MonitorService from "../../../Services/MonitorService";
|
|
9
|
+
import MonitorStatusTimelineService from "../../../Services/MonitorStatusTimelineService";
|
|
10
|
+
import QueryHelper from "../../../Types/Database/QueryHelper";
|
|
11
|
+
import ToolResultSerializer, { SerializedResult } from "./Serializer";
|
|
12
|
+
import {
|
|
13
|
+
ObservabilityTool,
|
|
14
|
+
ToolArgs,
|
|
15
|
+
ToolContext,
|
|
16
|
+
ToolExecutionResult,
|
|
17
|
+
} from "./ToolTypes";
|
|
18
|
+
|
|
19
|
+
/*
|
|
20
|
+
* Derived from the model ACL so the tool gate can never drift from RBAC.
|
|
21
|
+
* Resolved lazily rather than at module load: this module is pulled in through
|
|
22
|
+
* the service import graph before the Monitor model class is fully wired up,
|
|
23
|
+
* so calling a model method at import time throws a circular-dependency
|
|
24
|
+
* TypeError. By the time a tool actually executes, every module is loaded.
|
|
25
|
+
*/
|
|
26
|
+
let cachedReadPermissions: Array<Permission> | null = null;
|
|
27
|
+
const resolveReadPermissions: () => Array<Permission> =
|
|
28
|
+
(): Array<Permission> => {
|
|
29
|
+
if (!cachedReadPermissions) {
|
|
30
|
+
cachedReadPermissions = new Monitor().getReadPermissions();
|
|
31
|
+
}
|
|
32
|
+
return cachedReadPermissions;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const QueryMonitorsTool: ObservabilityTool = {
|
|
36
|
+
name: "query_monitors",
|
|
37
|
+
description:
|
|
38
|
+
"List monitors in this project with their current status. Pass monitorId to also get that monitor's recent status timeline (when it went up or down).",
|
|
39
|
+
inputSchema: {
|
|
40
|
+
type: "object",
|
|
41
|
+
properties: {
|
|
42
|
+
monitorId: {
|
|
43
|
+
type: "string",
|
|
44
|
+
description:
|
|
45
|
+
"Get one monitor by its ID, including its recent status timeline.",
|
|
46
|
+
},
|
|
47
|
+
nameSearch: {
|
|
48
|
+
type: "string",
|
|
49
|
+
description: "Filter monitors whose name contains this text.",
|
|
50
|
+
},
|
|
51
|
+
limit: {
|
|
52
|
+
type: "number",
|
|
53
|
+
description: "Maximum monitors to return (default 25, max 50).",
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
get requiredPermissions(): Array<Permission> {
|
|
58
|
+
return resolveReadPermissions();
|
|
59
|
+
},
|
|
60
|
+
execute: async (
|
|
61
|
+
args: JSONObject,
|
|
62
|
+
ctx: ToolContext,
|
|
63
|
+
): Promise<ToolExecutionResult> => {
|
|
64
|
+
const monitorId: ObjectID | undefined = ToolArgs.getObjectID(
|
|
65
|
+
args,
|
|
66
|
+
"monitorId",
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
if (monitorId) {
|
|
70
|
+
const monitor: Monitor | null = await MonitorService.findOneById({
|
|
71
|
+
id: monitorId,
|
|
72
|
+
select: {
|
|
73
|
+
_id: true,
|
|
74
|
+
name: true,
|
|
75
|
+
monitorType: true,
|
|
76
|
+
currentMonitorStatus: {
|
|
77
|
+
name: true,
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
props: ctx.props,
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const timeline: Array<MonitorStatusTimeline> =
|
|
84
|
+
await MonitorStatusTimelineService.findBy({
|
|
85
|
+
query: {
|
|
86
|
+
monitorId: monitorId,
|
|
87
|
+
},
|
|
88
|
+
select: {
|
|
89
|
+
createdAt: true,
|
|
90
|
+
monitorStatus: {
|
|
91
|
+
name: true,
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
sort: {
|
|
95
|
+
createdAt: SortOrder.Descending,
|
|
96
|
+
},
|
|
97
|
+
limit: 20,
|
|
98
|
+
skip: 0,
|
|
99
|
+
props: ctx.props,
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
const rows: Array<JSONObject> = [];
|
|
103
|
+
|
|
104
|
+
if (monitor) {
|
|
105
|
+
rows.push({
|
|
106
|
+
record: "monitor",
|
|
107
|
+
id: monitor.id?.toString(),
|
|
108
|
+
name: monitor.name,
|
|
109
|
+
type: monitor.monitorType,
|
|
110
|
+
currentStatus: monitor.currentMonitorStatus?.name,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
for (const item of timeline) {
|
|
115
|
+
rows.push({
|
|
116
|
+
record: "statusChange",
|
|
117
|
+
status: item.monitorStatus?.name,
|
|
118
|
+
at: item.createdAt,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const serialized: SerializedResult =
|
|
123
|
+
ToolResultSerializer.serializeRows(rows);
|
|
124
|
+
|
|
125
|
+
return {
|
|
126
|
+
dataForLlm: serialized.text,
|
|
127
|
+
rowCount: serialized.rowCount,
|
|
128
|
+
citationLabel: `Monitor ${monitor?.name || monitorId.toString()} + status timeline`,
|
|
129
|
+
citationTarget: {
|
|
130
|
+
type: AIChatCitationTargetType.MonitorView,
|
|
131
|
+
params: { monitorId: monitorId.toString() },
|
|
132
|
+
},
|
|
133
|
+
redactionCount: serialized.redactionCount,
|
|
134
|
+
isTruncated: serialized.isTruncated,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const limit: number = ToolArgs.getNumber(args, "limit", {
|
|
139
|
+
defaultValue: 25,
|
|
140
|
+
min: 1,
|
|
141
|
+
max: 50,
|
|
142
|
+
});
|
|
143
|
+
const nameSearch: string | undefined = ToolArgs.getString(
|
|
144
|
+
args,
|
|
145
|
+
"nameSearch",
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
const monitors: Array<Monitor> = await MonitorService.findBy({
|
|
149
|
+
query: nameSearch
|
|
150
|
+
? {
|
|
151
|
+
name: QueryHelper.search(nameSearch),
|
|
152
|
+
}
|
|
153
|
+
: {},
|
|
154
|
+
select: {
|
|
155
|
+
_id: true,
|
|
156
|
+
name: true,
|
|
157
|
+
monitorType: true,
|
|
158
|
+
currentMonitorStatus: {
|
|
159
|
+
name: true,
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
sort: {
|
|
163
|
+
name: SortOrder.Ascending,
|
|
164
|
+
},
|
|
165
|
+
limit: limit,
|
|
166
|
+
skip: 0,
|
|
167
|
+
props: ctx.props,
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
const rows: Array<JSONObject> = monitors.map((monitor: Monitor) => {
|
|
171
|
+
return {
|
|
172
|
+
id: monitor.id?.toString(),
|
|
173
|
+
name: monitor.name,
|
|
174
|
+
type: monitor.monitorType,
|
|
175
|
+
currentStatus: monitor.currentMonitorStatus?.name,
|
|
176
|
+
};
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
const serialized: SerializedResult =
|
|
180
|
+
ToolResultSerializer.serializeRows(rows);
|
|
181
|
+
|
|
182
|
+
return {
|
|
183
|
+
dataForLlm: serialized.text,
|
|
184
|
+
rowCount: serialized.rowCount,
|
|
185
|
+
citationLabel: `Monitors (${serialized.rowCount} found)`,
|
|
186
|
+
citationTarget: {
|
|
187
|
+
type: AIChatCitationTargetType.Monitors,
|
|
188
|
+
},
|
|
189
|
+
redactionCount: serialized.redactionCount,
|
|
190
|
+
isTruncated: serialized.isTruncated,
|
|
191
|
+
};
|
|
192
|
+
},
|
|
193
|
+
};
|