@oneuptime/common 11.5.8 → 11.5.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Models/AnalyticsModels/Index.ts +13 -0
- package/Models/AnalyticsModels/MetricItemAggMV1mByContainer.ts +178 -0
- package/Models/AnalyticsModels/MetricItemAggMV1mByK8sCluster.ts +179 -0
- package/Models/AnalyticsModels/MetricItemAggMV1mByService.ts +179 -0
- package/Models/AnalyticsModels/NetworkFlow.ts +397 -0
- package/Models/DatabaseModels/AIAgentTaskPullRequest.ts +15 -6
- package/Models/DatabaseModels/AIRun.ts +37 -0
- package/Models/DatabaseModels/AIRunEvent.ts +34 -1
- package/Models/DatabaseModels/EnterpriseLicenseInstance.ts +18 -0
- package/Models/DatabaseModels/GlobalConfig.ts +36 -0
- package/Models/DatabaseModels/Index.ts +2 -0
- package/Models/DatabaseModels/MarketingConversion.ts +198 -0
- package/Models/DatabaseModels/MetricSavedView.ts +34 -0
- package/Models/DatabaseModels/MetricType.ts +74 -0
- package/Models/DatabaseModels/NetworkDevice.ts +332 -0
- package/Models/DatabaseModels/NetworkDeviceDiscoveryScan.ts +328 -0
- package/Models/DatabaseModels/NetworkInterface.ts +58 -0
- package/Models/DatabaseModels/Project.ts +62 -0
- package/Models/DatabaseModels/StatusPage.ts +42 -0
- package/Models/DatabaseModels/User.ts +37 -0
- package/Server/API/AIAgentTaskAPI.ts +38 -12
- package/Server/API/AIAgentTaskLogAPI.ts +49 -0
- package/Server/API/AIChatAPI.ts +16 -0
- package/Server/API/AIReadinessAPI.ts +84 -0
- package/Server/API/BaseAnalyticsAPI.ts +23 -0
- package/Server/API/CodeFixRunAPI.ts +182 -0
- package/Server/API/EnterpriseLicenseAPI.ts +14 -0
- package/Server/API/TelemetryExceptionAPI.ts +6 -1
- package/Server/EnvironmentConfig.ts +84 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1784124919694-AddAITaskNumberAndRunTranscript.ts +95 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1784135099754-AllowNullAiAgentOnPullRequest.ts +52 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1784137457184-AddEnableMcpServerToStatusPage.ts +30 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1784191414522-AddCounterSemanticsToMetricType.ts +38 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1784191414600-AddViewTypeToMetricSavedView.ts +28 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1784200000000-AddSnmpV3ColumnsToNetworkDeviceDiscoveryScan.ts +49 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1784211212164-AddNetworkDeviceInventoryAndDiscoverySchedule.ts +108 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1784218257664-AddEnterpriseLicenseNotificationColumns.ts +31 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1784293516000-AddAttributionColumnsToUserAndProject.ts +29 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1784298000000-AddMarketingConversionTable.ts +35 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +20 -0
- package/Server/Services/AIRunEventService.ts +15 -1
- package/Server/Services/AIRunService.ts +38 -1
- package/Server/Services/AnalyticsDatabaseService.ts +70 -1
- package/Server/Services/IncidentService.ts +13 -0
- package/Server/Services/Index.ts +10 -0
- package/Server/Services/LlmProviderService.ts +2 -0
- package/Server/Services/MarketingConversionService.ts +10 -0
- package/Server/Services/MetricItemAggMV1mByContainerService.ts +31 -0
- package/Server/Services/MetricItemAggMV1mByK8sClusterService.ts +31 -0
- package/Server/Services/MetricItemAggMV1mByServiceService.ts +31 -0
- package/Server/Services/MetricService.ts +970 -122
- package/Server/Services/MonitorService.ts +14 -0
- package/Server/Services/NetworkDeviceOwnerTeamService.ts +42 -0
- package/Server/Services/NetworkDeviceOwnerUserService.ts +106 -0
- package/Server/Services/NetworkFlowService.ts +11 -0
- package/Server/Services/OnCallDutyPolicyService.ts +11 -1
- package/Server/Services/ProjectService.ts +178 -0
- package/Server/Services/SpanService.ts +13 -9
- package/Server/Services/StatusPageService.ts +97 -0
- package/Server/Services/TeamMemberService.ts +11 -0
- package/Server/Services/TelemetryExceptionService.ts +19 -90
- package/Server/Services/UserService.ts +59 -0
- package/Server/Types/AnalyticsDatabase/AggregateBy.ts +37 -7
- package/Server/Types/Markdown.ts +9 -9
- package/Server/Types/MarkdownSlugify.ts +47 -0
- package/Server/Utils/AI/AIRunTranscript.ts +240 -0
- package/Server/Utils/AI/Chat/ChatAgentRunner.ts +9 -0
- package/Server/Utils/AI/Chat/ObservabilityChatPrompt.ts +119 -5
- package/Server/Utils/AI/CodeFix/CodeFixAgentCompletion.ts +75 -0
- package/Server/Utils/AI/CodeFix/CodeFixReadiness.ts +235 -0
- package/Server/Utils/AI/SRE/Insights/FixRouting.ts +2 -3
- package/Server/Utils/AI/Toolbox/CodeTools.ts +883 -0
- package/Server/Utils/AI/Toolbox/CodeWriteTools.ts +519 -0
- package/Server/Utils/AI/Toolbox/Index.ts +27 -0
- package/Server/Utils/AI/Toolbox/ScheduledMaintenanceTools.ts +279 -0
- package/Server/Utils/AnalyticsDatabase/ClickhouseCapacity.ts +19 -1
- package/Server/Utils/Attribution.ts +99 -0
- package/Server/Utils/CodeRepository/GitHub/GitHub.ts +600 -0
- package/Server/Utils/CodeRepository/StackTraceRepoResolver.ts +7 -2
- package/Server/Utils/LLM/LLMService.ts +397 -18
- package/Server/Utils/Marketing/ConversionUploadProvider.ts +103 -0
- package/Server/Utils/Marketing/ConversionUploadProviders.ts +22 -0
- package/Server/Utils/Marketing/Providers/GoogleAds.ts +270 -0
- package/Server/Utils/Marketing/Providers/LinkedIn.ts +147 -0
- package/Server/Utils/Marketing/Providers/Meta.ts +148 -0
- package/Server/Utils/Marketing/Providers/MicrosoftAds.ts +196 -0
- package/Server/Utils/Marketing/Providers/Reddit.ts +178 -0
- package/Server/Utils/Monitor/MonitorAlert.ts +71 -7
- package/Server/Utils/Monitor/MonitorCriteriaEvaluator.ts +31 -19
- package/Server/Utils/Monitor/MonitorIncident.ts +71 -7
- package/Server/Utils/Monitor/MonitorMetricUtil.ts +57 -0
- package/Server/Utils/Monitor/MonitorTemplateUtil.ts +94 -0
- package/Server/Utils/Monitor/NetworkDeviceHydrationUtil.ts +19 -11
- package/Server/Utils/Monitor/NetworkInventoryUtil.ts +125 -14
- package/Server/Utils/ProductAnalytics.ts +133 -0
- package/Server/Utils/Telemetry/Telemetry.ts +39 -0
- package/Server/Utils/Telemetry/TelemetryEntity.ts +21 -0
- package/Tests/Models/StatusPageEnableMcpServer.test.ts +125 -0
- package/Tests/Server/API/BaseAnalyticsAPI.test.ts +72 -0
- package/Tests/Server/Infrastructure/SemaphorePermit.test.ts +9 -1
- package/Tests/Server/Services/AnalyticsDatabaseService.test.ts +21 -2
- package/Tests/Server/Services/MetricEntityMVKeyParity.test.ts +173 -0
- package/Tests/Server/Services/MetricServiceAggregate.test.ts +1391 -0
- package/Tests/Server/Services/NetworkDeviceOwnerServices.test.ts +260 -0
- package/Tests/Server/Services/StatusPageServiceMcp.test.ts +223 -0
- package/Tests/Server/Services/TelemetryExceptionAIFixReadiness.test.ts +26 -3
- package/Tests/Server/Services/TelemetryExceptionCodeFixRun.test.ts +12 -0
- package/Tests/Server/Types/Markdown.test.ts +106 -0
- package/Tests/Server/Utils/AI/AIRunTranscript.test.ts +182 -0
- package/Tests/Server/Utils/AI/CodeFixReadiness.test.ts +411 -0
- package/Tests/Server/Utils/AI/CodeTools.test.ts +596 -0
- package/Tests/Server/Utils/AI/CodeWriteTools.test.ts +475 -0
- package/Tests/Server/Utils/AI/LLMServiceModelCompatibility.test.ts +548 -0
- package/Tests/Server/Utils/AI/ObservabilityChatPrompt.test.ts +142 -0
- package/Tests/Server/Utils/AI/ScheduledMaintenanceTools.test.ts +176 -0
- package/Tests/Server/Utils/AnalyticsDatabase/ClickhouseCapacity.test.ts +63 -0
- package/Tests/Server/Utils/GitHubGetFileContent.test.ts +197 -0
- package/Tests/Server/Utils/Monitor/MonitorTemplateUtilNetworkDevice.test.ts +389 -0
- package/Tests/Server/Utils/Monitor/NetworkDeviceHydrationUtil.test.ts +502 -0
- package/Tests/Server/Utils/Monitor/NetworkInventoryUtil.test.ts +764 -0
- package/Tests/Types/AI/AIAgentTaskStatus.test.ts +7 -6
- package/Tests/Types/AI/AIChatPageContext.test.ts +0 -0
- package/Tests/Types/AI/AIRunStatus.test.ts +42 -0
- package/Tests/Types/BaseDatabase/AggregationIntervalUtil.test.ts +111 -2
- package/Tests/Types/Database/EndsWith.test.ts +64 -0
- package/Tests/Types/Database/GreaterThan.test.ts +62 -0
- package/Tests/Types/Database/GreaterThanOrEqual.test.ts +65 -0
- package/Tests/Types/Database/GreaterThanOrNull.test.ts +63 -0
- package/Tests/Types/Database/Includes.test.ts +65 -0
- package/Tests/Types/Database/IncludesAll.test.ts +65 -0
- package/Tests/Types/Database/IncludesNone.test.ts +65 -0
- package/Tests/Types/Database/IsNull.test.ts +44 -0
- package/Tests/Types/Database/LessThan.test.ts +62 -0
- package/Tests/Types/Database/LessThanOrEqual.test.ts +62 -0
- package/Tests/Types/Database/LessThanOrNull.test.ts +62 -0
- package/Tests/Types/Database/MultiSearch.test.ts +81 -0
- package/Tests/Types/Database/NotContains.test.ts +64 -0
- package/Tests/Types/Database/NotNull.test.ts +44 -0
- package/Tests/Types/Database/StartsWith.test.ts +64 -0
- package/Tests/Types/Log/LogSeverity.test.ts +78 -0
- package/Tests/Types/Monitor/MonitorStepSqlMonitor.test.ts +83 -1
- package/Tests/Types/Monitor/SnmpV3EnumParsing.test.ts +247 -0
- package/Tests/Types/Monitor/SnmpVendorTemplate.test.ts +263 -0
- package/Tests/UI/Components/BasicFormDropdownNormalization.test.tsx +167 -0
- package/Tests/UI/Components/Charts/AxisTickColor.test.tsx +66 -0
- package/Tests/UI/Components/XAxis.test.ts +5 -3
- package/Tests/UI/Utils/AIChatExport/ChatWidgetData.test.ts +319 -0
- package/Tests/UI/Utils/AIChatExport/ChatWidgetMarkdown.test.ts +188 -0
- package/Tests/Utils/EnterpriseLicenseUsage.test.ts +76 -0
- package/Tests/Utils/Metrics/MetricExplorerUrl.test.ts +622 -0
- package/Tests/Utils/Metrics/MetricFormulaEvaluator.test.ts +474 -0
- package/Tests/Utils/Telemetry/HeartbeatAvailability.test.ts +52 -4
- package/Types/AI/AIAgentTaskStatus.ts +13 -0
- package/Types/AI/AIChatPageContext.ts +137 -0
- package/Types/AI/AIChatTypes.ts +44 -0
- package/Types/AI/AIFixReadiness.ts +46 -0
- package/Types/AI/AIRunStatus.ts +11 -0
- package/Types/AnalyticsDatabase/AnalyticsTableName.ts +11 -0
- package/Types/BaseDatabase/AggregateBy.ts +31 -2
- package/Types/BaseDatabase/AggregatedResult.ts +22 -0
- package/Types/BaseDatabase/AggregationInterval.ts +11 -0
- package/Types/BaseDatabase/AggregationIntervalUtil.ts +30 -5
- package/Types/Dashboard/DashboardComponents/DashboardTraceChartComponent.ts +16 -0
- package/Types/Email/EmailTemplateType.ts +3 -0
- package/Types/Log/LogSeverity.ts +61 -0
- package/Types/Marketing/MarketingConversion.ts +11 -0
- package/Types/Metrics/MetricQueryConfigData.ts +21 -0
- package/Types/Metrics/MetricQueryData.ts +8 -0
- package/Types/Metrics/MetricViewData.ts +8 -0
- package/Types/Monitor/MonitorMetricType.ts +8 -0
- package/Types/Monitor/MonitorStep.ts +9 -0
- package/Types/Monitor/MonitorStepSqlMonitor.ts +12 -0
- package/Types/Monitor/MonitorType.ts +2 -1
- package/Types/Monitor/SSLMonitor/SslMonitorResponse.ts +17 -12
- package/Types/Monitor/SnmpMonitor/CdpNeighbor.ts +13 -0
- package/Types/Monitor/SnmpMonitor/NetworkTopology.ts +37 -3
- package/Types/Monitor/SnmpMonitor/SnmpAuthProtocol.ts +46 -0
- package/Types/Monitor/SnmpMonitor/SnmpEntityInfo.ts +15 -0
- package/Types/Monitor/SnmpMonitor/SnmpInterface.ts +8 -0
- package/Types/Monitor/SnmpMonitor/SnmpMonitorResponse.ts +17 -8
- package/Types/Monitor/SnmpMonitor/SnmpPrivProtocol.ts +53 -0
- package/Types/Monitor/SnmpMonitor/SnmpSecurityLevel.ts +43 -0
- package/Types/Monitor/SnmpMonitor/SnmpSystemInfo.ts +16 -0
- package/Types/Monitor/SnmpMonitor/SnmpVendorTemplate.ts +119 -3
- package/Types/Monitor/SnmpMonitor/SnmpVersion.ts +40 -0
- package/Types/NetFlow/NetworkFlowRecord.ts +25 -0
- package/Types/Syslog/SyslogMessage.ts +18 -0
- package/Types/Telemetry/TelemetrySavedViewState.ts +9 -0
- package/Types/Telemetry/TelemetrySavedViewType.ts +12 -0
- package/UI/Components/Charts/Area/AreaChart.tsx +51 -0
- package/UI/Components/Charts/Bar/BarChart.tsx +51 -1
- package/UI/Components/Charts/ChartGroup/ChartGroup.tsx +97 -26
- package/UI/Components/Charts/ChartLibrary/AreaChart/AreaChart.tsx +336 -3
- package/UI/Components/Charts/ChartLibrary/BarChart/BarChart.tsx +118 -1
- package/UI/Components/Charts/ChartLibrary/LineChart/LineChart.tsx +336 -3
- package/UI/Components/Charts/ChartLibrary/Types/ChartDataPoint.ts +7 -0
- package/UI/Components/Charts/ChartLibrary/Types/FormattedReferenceRegion.ts +15 -0
- package/UI/Components/Charts/ChartLibrary/Types/FormattedTimeReferenceLine.ts +13 -0
- package/UI/Components/Charts/Line/LineChart.tsx +51 -0
- package/UI/Components/Charts/Types/ReferenceRegionProps.ts +12 -0
- package/UI/Components/Charts/Types/TimeReferenceLineProps.ts +12 -0
- package/UI/Components/Charts/Types/XAxis/XAxisPrecision.ts +1 -0
- package/UI/Components/Charts/Utils/DataPoint.ts +0 -0
- package/UI/Components/Charts/Utils/TimeAnnotation.ts +169 -0
- package/UI/Components/Charts/Utils/XAxis.ts +28 -4
- package/UI/Components/Forms/BasicForm.tsx +26 -8
- package/UI/Components/Icon/Icon.tsx +33 -13
- package/UI/Components/Markdown.tsx/MarkdownViewer.tsx +9 -0
- package/UI/Components/MonitorTemplateVariables/TemplateVariablesCatalog.ts +67 -0
- package/UI/Components/Page/ModelPage.tsx +6 -1
- package/UI/Components/TelemetryViewer/components/SavedViewsDropdown.tsx +33 -4
- package/UI/Styles/Theme.css +1324 -0
- package/UI/Utils/AIChatExport/ChatWidgetData.ts +316 -0
- package/UI/Utils/AIChatExport/ChatWidgetMarkdown.ts +349 -0
- package/UI/Utils/AIChatExport/ConversationMarkdown.ts +177 -0
- package/UI/Utils/AIChatExport/MarkdownBlocks.ts +327 -0
- package/UI/Utils/AIChatExport/MarkdownSafety.ts +215 -0
- package/UI/Utils/DownloadFile.ts +54 -0
- package/UI/Utils/User.ts +41 -2
- package/Utils/Analytics.ts +8 -6
- package/Utils/EnterpriseLicense/EnterpriseLicenseUsage.ts +74 -0
- package/Utils/Metrics/MetricExplorerUrl.ts +771 -0
- package/Utils/Metrics/MetricFormulaEvaluator.ts +410 -46
- package/Utils/Monitor/NetworkTopologyUtil.ts +261 -49
- package/Utils/ValueFormatter.ts +22 -1
- package/build/dist/Models/AnalyticsModels/Index.js +13 -0
- package/build/dist/Models/AnalyticsModels/Index.js.map +1 -1
- package/build/dist/Models/AnalyticsModels/MetricItemAggMV1mByContainer.js +159 -0
- package/build/dist/Models/AnalyticsModels/MetricItemAggMV1mByContainer.js.map +1 -0
- package/build/dist/Models/AnalyticsModels/MetricItemAggMV1mByK8sCluster.js +158 -0
- package/build/dist/Models/AnalyticsModels/MetricItemAggMV1mByK8sCluster.js.map +1 -0
- package/build/dist/Models/AnalyticsModels/MetricItemAggMV1mByService.js +160 -0
- package/build/dist/Models/AnalyticsModels/MetricItemAggMV1mByService.js.map +1 -0
- package/build/dist/Models/AnalyticsModels/NetworkFlow.js +351 -0
- package/build/dist/Models/AnalyticsModels/NetworkFlow.js.map +1 -0
- package/build/dist/Models/DatabaseModels/AIAgentTaskPullRequest.js +15 -7
- package/build/dist/Models/DatabaseModels/AIAgentTaskPullRequest.js.map +1 -1
- package/build/dist/Models/DatabaseModels/AIRun.js +38 -0
- package/build/dist/Models/DatabaseModels/AIRun.js.map +1 -1
- package/build/dist/Models/DatabaseModels/AIRunEvent.js +31 -0
- package/build/dist/Models/DatabaseModels/AIRunEvent.js.map +1 -1
- package/build/dist/Models/DatabaseModels/EnterpriseLicenseInstance.js +19 -0
- package/build/dist/Models/DatabaseModels/EnterpriseLicenseInstance.js.map +1 -1
- package/build/dist/Models/DatabaseModels/GlobalConfig.js +38 -0
- package/build/dist/Models/DatabaseModels/GlobalConfig.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Index.js +2 -0
- package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
- package/build/dist/Models/DatabaseModels/MarketingConversion.js +219 -0
- package/build/dist/Models/DatabaseModels/MarketingConversion.js.map +1 -0
- package/build/dist/Models/DatabaseModels/MetricSavedView.js +35 -0
- package/build/dist/Models/DatabaseModels/MetricSavedView.js.map +1 -1
- package/build/dist/Models/DatabaseModels/MetricType.js +76 -0
- package/build/dist/Models/DatabaseModels/MetricType.js.map +1 -1
- package/build/dist/Models/DatabaseModels/NetworkDevice.js +341 -0
- package/build/dist/Models/DatabaseModels/NetworkDevice.js.map +1 -1
- package/build/dist/Models/DatabaseModels/NetworkDeviceDiscoveryScan.js +341 -0
- package/build/dist/Models/DatabaseModels/NetworkDeviceDiscoveryScan.js.map +1 -1
- package/build/dist/Models/DatabaseModels/NetworkInterface.js +60 -0
- package/build/dist/Models/DatabaseModels/NetworkInterface.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Project.js +65 -0
- package/build/dist/Models/DatabaseModels/Project.js.map +1 -1
- package/build/dist/Models/DatabaseModels/StatusPage.js +43 -0
- package/build/dist/Models/DatabaseModels/StatusPage.js.map +1 -1
- package/build/dist/Models/DatabaseModels/User.js +38 -0
- package/build/dist/Models/DatabaseModels/User.js.map +1 -1
- package/build/dist/Server/API/AIAgentTaskAPI.js +37 -11
- package/build/dist/Server/API/AIAgentTaskAPI.js.map +1 -1
- package/build/dist/Server/API/AIAgentTaskLogAPI.js +32 -7
- package/build/dist/Server/API/AIAgentTaskLogAPI.js.map +1 -1
- package/build/dist/Server/API/AIChatAPI.js +9 -0
- package/build/dist/Server/API/AIChatAPI.js.map +1 -1
- package/build/dist/Server/API/AIReadinessAPI.js +57 -0
- package/build/dist/Server/API/AIReadinessAPI.js.map +1 -0
- package/build/dist/Server/API/BaseAnalyticsAPI.js +19 -0
- package/build/dist/Server/API/BaseAnalyticsAPI.js.map +1 -1
- package/build/dist/Server/API/CodeFixRunAPI.js +142 -0
- package/build/dist/Server/API/CodeFixRunAPI.js.map +1 -1
- package/build/dist/Server/API/EnterpriseLicenseAPI.js +8 -0
- package/build/dist/Server/API/EnterpriseLicenseAPI.js.map +1 -1
- package/build/dist/Server/API/TelemetryExceptionAPI.js +4 -0
- package/build/dist/Server/API/TelemetryExceptionAPI.js.map +1 -1
- package/build/dist/Server/EnvironmentConfig.js +51 -0
- package/build/dist/Server/EnvironmentConfig.js.map +1 -1
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1784124919694-AddAITaskNumberAndRunTranscript.js +80 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1784124919694-AddAITaskNumberAndRunTranscript.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1784135099754-AllowNullAiAgentOnPullRequest.js +37 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1784135099754-AllowNullAiAgentOnPullRequest.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1784137457184-AddEnableMcpServerToStatusPage.js +23 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1784137457184-AddEnableMcpServerToStatusPage.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1784191414522-AddCounterSemanticsToMetricType.js +27 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1784191414522-AddCounterSemanticsToMetricType.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1784191414600-AddViewTypeToMetricSavedView.js +21 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1784191414600-AddViewTypeToMetricSavedView.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1784200000000-AddSnmpV3ColumnsToNetworkDeviceDiscoveryScan.js +22 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1784200000000-AddSnmpV3ColumnsToNetworkDeviceDiscoveryScan.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1784211212164-AddNetworkDeviceInventoryAndDiscoverySchedule.js +47 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1784211212164-AddNetworkDeviceInventoryAndDiscoverySchedule.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1784218257664-AddEnterpriseLicenseNotificationColumns.js +16 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1784218257664-AddEnterpriseLicenseNotificationColumns.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1784293516000-AddAttributionColumnsToUserAndProject.js +18 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1784293516000-AddAttributionColumnsToUserAndProject.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1784298000000-AddMarketingConversionTable.js +20 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1784298000000-AddMarketingConversionTable.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +20 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
- package/build/dist/Server/Services/AIRunEventService.js +8 -0
- package/build/dist/Server/Services/AIRunEventService.js.map +1 -1
- package/build/dist/Server/Services/AIRunService.js +29 -0
- package/build/dist/Server/Services/AIRunService.js.map +1 -1
- package/build/dist/Server/Services/AnalyticsDatabaseService.js +58 -4
- package/build/dist/Server/Services/AnalyticsDatabaseService.js.map +1 -1
- package/build/dist/Server/Services/IncidentService.js +12 -0
- package/build/dist/Server/Services/IncidentService.js.map +1 -1
- package/build/dist/Server/Services/Index.js +10 -0
- package/build/dist/Server/Services/Index.js.map +1 -1
- package/build/dist/Server/Services/LlmProviderService.js +2 -0
- package/build/dist/Server/Services/LlmProviderService.js.map +1 -1
- package/build/dist/Server/Services/MarketingConversionService.js +9 -0
- package/build/dist/Server/Services/MarketingConversionService.js.map +1 -0
- package/build/dist/Server/Services/MetricItemAggMV1mByContainerService.js +29 -0
- package/build/dist/Server/Services/MetricItemAggMV1mByContainerService.js.map +1 -0
- package/build/dist/Server/Services/MetricItemAggMV1mByK8sClusterService.js +29 -0
- package/build/dist/Server/Services/MetricItemAggMV1mByK8sClusterService.js.map +1 -0
- package/build/dist/Server/Services/MetricItemAggMV1mByServiceService.js +29 -0
- package/build/dist/Server/Services/MetricItemAggMV1mByServiceService.js.map +1 -0
- package/build/dist/Server/Services/MetricService.js +761 -125
- package/build/dist/Server/Services/MetricService.js.map +1 -1
- package/build/dist/Server/Services/MonitorService.js +18 -5
- package/build/dist/Server/Services/MonitorService.js.map +1 -1
- package/build/dist/Server/Services/NetworkDeviceOwnerTeamService.js +44 -0
- package/build/dist/Server/Services/NetworkDeviceOwnerTeamService.js.map +1 -1
- package/build/dist/Server/Services/NetworkDeviceOwnerUserService.js +88 -0
- package/build/dist/Server/Services/NetworkDeviceOwnerUserService.js.map +1 -1
- package/build/dist/Server/Services/NetworkFlowService.js +9 -0
- package/build/dist/Server/Services/NetworkFlowService.js.map +1 -0
- package/build/dist/Server/Services/OnCallDutyPolicyService.js +15 -6
- package/build/dist/Server/Services/OnCallDutyPolicyService.js.map +1 -1
- package/build/dist/Server/Services/ProjectService.js +146 -6
- package/build/dist/Server/Services/ProjectService.js.map +1 -1
- package/build/dist/Server/Services/SpanService.js +8 -6
- package/build/dist/Server/Services/SpanService.js.map +1 -1
- package/build/dist/Server/Services/StatusPageService.js +91 -0
- package/build/dist/Server/Services/StatusPageService.js.map +1 -1
- package/build/dist/Server/Services/TeamMemberService.js +11 -0
- package/build/dist/Server/Services/TeamMemberService.js.map +1 -1
- package/build/dist/Server/Services/TelemetryExceptionService.js +14 -61
- package/build/dist/Server/Services/TelemetryExceptionService.js.map +1 -1
- package/build/dist/Server/Services/UserService.js +52 -0
- package/build/dist/Server/Services/UserService.js.map +1 -1
- package/build/dist/Server/Types/AnalyticsDatabase/AggregateBy.js +33 -7
- package/build/dist/Server/Types/AnalyticsDatabase/AggregateBy.js.map +1 -1
- package/build/dist/Server/Types/Markdown.js +8 -8
- package/build/dist/Server/Types/Markdown.js.map +1 -1
- package/build/dist/Server/Types/MarkdownSlugify.js +47 -0
- package/build/dist/Server/Types/MarkdownSlugify.js.map +1 -0
- package/build/dist/Server/Utils/AI/AIRunTranscript.js +180 -0
- package/build/dist/Server/Utils/AI/AIRunTranscript.js.map +1 -0
- package/build/dist/Server/Utils/AI/Chat/ChatAgentRunner.js +1 -0
- package/build/dist/Server/Utils/AI/Chat/ChatAgentRunner.js.map +1 -1
- package/build/dist/Server/Utils/AI/Chat/ObservabilityChatPrompt.js +103 -5
- package/build/dist/Server/Utils/AI/Chat/ObservabilityChatPrompt.js.map +1 -1
- package/build/dist/Server/Utils/AI/CodeFix/CodeFixAgentCompletion.js +55 -0
- package/build/dist/Server/Utils/AI/CodeFix/CodeFixAgentCompletion.js.map +1 -1
- package/build/dist/Server/Utils/AI/CodeFix/CodeFixReadiness.js +211 -0
- package/build/dist/Server/Utils/AI/CodeFix/CodeFixReadiness.js.map +1 -0
- package/build/dist/Server/Utils/AI/SRE/Insights/FixRouting.js.map +1 -1
- package/build/dist/Server/Utils/AI/Toolbox/CodeTools.js +654 -0
- package/build/dist/Server/Utils/AI/Toolbox/CodeTools.js.map +1 -0
- package/build/dist/Server/Utils/AI/Toolbox/CodeWriteTools.js +389 -0
- package/build/dist/Server/Utils/AI/Toolbox/CodeWriteTools.js.map +1 -0
- package/build/dist/Server/Utils/AI/Toolbox/Index.js +19 -0
- package/build/dist/Server/Utils/AI/Toolbox/Index.js.map +1 -1
- package/build/dist/Server/Utils/AI/Toolbox/ScheduledMaintenanceTools.js +239 -0
- package/build/dist/Server/Utils/AI/Toolbox/ScheduledMaintenanceTools.js.map +1 -0
- package/build/dist/Server/Utils/AnalyticsDatabase/ClickhouseCapacity.js +19 -1
- package/build/dist/Server/Utils/AnalyticsDatabase/ClickhouseCapacity.js.map +1 -1
- package/build/dist/Server/Utils/Attribution.js +74 -0
- package/build/dist/Server/Utils/Attribution.js.map +1 -0
- package/build/dist/Server/Utils/CodeRepository/GitHub/GitHub.js +439 -0
- package/build/dist/Server/Utils/CodeRepository/GitHub/GitHub.js.map +1 -1
- package/build/dist/Server/Utils/CodeRepository/StackTraceRepoResolver.js +1 -1
- package/build/dist/Server/Utils/CodeRepository/StackTraceRepoResolver.js.map +1 -1
- package/build/dist/Server/Utils/LLM/LLMService.js +275 -19
- package/build/dist/Server/Utils/LLM/LLMService.js.map +1 -1
- package/build/dist/Server/Utils/Marketing/ConversionUploadProvider.js +40 -0
- package/build/dist/Server/Utils/Marketing/ConversionUploadProvider.js.map +1 -0
- package/build/dist/Server/Utils/Marketing/ConversionUploadProviders.js +20 -0
- package/build/dist/Server/Utils/Marketing/ConversionUploadProviders.js.map +1 -0
- package/build/dist/Server/Utils/Marketing/Providers/GoogleAds.js +177 -0
- package/build/dist/Server/Utils/Marketing/Providers/GoogleAds.js.map +1 -0
- package/build/dist/Server/Utils/Marketing/Providers/LinkedIn.js +113 -0
- package/build/dist/Server/Utils/Marketing/Providers/LinkedIn.js.map +1 -0
- package/build/dist/Server/Utils/Marketing/Providers/Meta.js +109 -0
- package/build/dist/Server/Utils/Marketing/Providers/Meta.js.map +1 -0
- package/build/dist/Server/Utils/Marketing/Providers/MicrosoftAds.js +130 -0
- package/build/dist/Server/Utils/Marketing/Providers/MicrosoftAds.js.map +1 -0
- package/build/dist/Server/Utils/Marketing/Providers/Reddit.js +126 -0
- package/build/dist/Server/Utils/Marketing/Providers/Reddit.js.map +1 -0
- package/build/dist/Server/Utils/Monitor/MonitorAlert.js +53 -9
- package/build/dist/Server/Utils/Monitor/MonitorAlert.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaEvaluator.js +21 -10
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaEvaluator.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorIncident.js +54 -11
- package/build/dist/Server/Utils/Monitor/MonitorIncident.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorMetricUtil.js +43 -3
- package/build/dist/Server/Utils/Monitor/MonitorMetricUtil.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorTemplateUtil.js +68 -0
- package/build/dist/Server/Utils/Monitor/MonitorTemplateUtil.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/NetworkDeviceHydrationUtil.js +17 -11
- package/build/dist/Server/Utils/Monitor/NetworkDeviceHydrationUtil.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/NetworkInventoryUtil.js +100 -15
- package/build/dist/Server/Utils/Monitor/NetworkInventoryUtil.js.map +1 -1
- package/build/dist/Server/Utils/ProductAnalytics.js +111 -0
- package/build/dist/Server/Utils/ProductAnalytics.js.map +1 -0
- package/build/dist/Server/Utils/Telemetry/Telemetry.js +32 -5
- package/build/dist/Server/Utils/Telemetry/Telemetry.js.map +1 -1
- package/build/dist/Server/Utils/Telemetry/TelemetryEntity.js +17 -0
- package/build/dist/Server/Utils/Telemetry/TelemetryEntity.js.map +1 -1
- package/build/dist/Types/AI/AIAgentTaskStatus.js +12 -0
- package/build/dist/Types/AI/AIAgentTaskStatus.js.map +1 -1
- package/build/dist/Types/AI/AIChatPageContext.js +101 -0
- package/build/dist/Types/AI/AIChatPageContext.js.map +1 -0
- package/build/dist/Types/AI/AIChatTypes.js +2 -0
- package/build/dist/Types/AI/AIChatTypes.js.map +1 -1
- package/build/dist/Types/AI/AIFixReadiness.js +9 -0
- package/build/dist/Types/AI/AIFixReadiness.js.map +1 -0
- package/build/dist/Types/AI/AIRunStatus.js +11 -0
- package/build/dist/Types/AI/AIRunStatus.js.map +1 -1
- package/build/dist/Types/AnalyticsDatabase/AnalyticsTableName.js +11 -0
- package/build/dist/Types/AnalyticsDatabase/AnalyticsTableName.js.map +1 -1
- package/build/dist/Types/BaseDatabase/AggregationInterval.js +11 -0
- package/build/dist/Types/BaseDatabase/AggregationInterval.js.map +1 -1
- package/build/dist/Types/BaseDatabase/AggregationIntervalUtil.js +33 -5
- package/build/dist/Types/BaseDatabase/AggregationIntervalUtil.js.map +1 -1
- package/build/dist/Types/Email/EmailTemplateType.js +2 -0
- package/build/dist/Types/Email/EmailTemplateType.js.map +1 -1
- package/build/dist/Types/Log/LogSeverity.js +56 -0
- package/build/dist/Types/Log/LogSeverity.js.map +1 -1
- package/build/dist/Types/Marketing/MarketingConversion.js +13 -0
- package/build/dist/Types/Marketing/MarketingConversion.js.map +1 -0
- package/build/dist/Types/Monitor/MonitorMetricType.js +7 -0
- package/build/dist/Types/Monitor/MonitorMetricType.js.map +1 -1
- package/build/dist/Types/Monitor/MonitorStep.js +6 -0
- package/build/dist/Types/Monitor/MonitorStep.js.map +1 -1
- package/build/dist/Types/Monitor/MonitorStepSqlMonitor.js +3 -0
- package/build/dist/Types/Monitor/MonitorStepSqlMonitor.js.map +1 -1
- package/build/dist/Types/Monitor/MonitorType.js +2 -1
- package/build/dist/Types/Monitor/MonitorType.js.map +1 -1
- package/build/dist/Types/Monitor/SnmpMonitor/CdpNeighbor.js +2 -0
- package/build/dist/Types/Monitor/SnmpMonitor/CdpNeighbor.js.map +1 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpAuthProtocol.js +41 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpAuthProtocol.js.map +1 -1
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpEntityInfo.js +2 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpEntityInfo.js.map +1 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpPrivProtocol.js +48 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpPrivProtocol.js.map +1 -1
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpSecurityLevel.js +38 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpSecurityLevel.js.map +1 -1
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpSystemInfo.js +2 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpSystemInfo.js.map +1 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpVendorTemplate.js +96 -3
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpVendorTemplate.js.map +1 -1
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpVersion.js +38 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpVersion.js.map +1 -1
- package/build/dist/Types/NetFlow/NetworkFlowRecord.js +2 -0
- package/build/dist/Types/NetFlow/NetworkFlowRecord.js.map +1 -0
- package/build/dist/Types/Syslog/SyslogMessage.js +2 -0
- package/build/dist/Types/Syslog/SyslogMessage.js.map +1 -0
- package/build/dist/Types/Telemetry/TelemetrySavedViewState.js +0 -7
- package/build/dist/Types/Telemetry/TelemetrySavedViewState.js.map +1 -1
- package/build/dist/Types/Telemetry/TelemetrySavedViewType.js +13 -0
- package/build/dist/Types/Telemetry/TelemetrySavedViewType.js.map +1 -0
- package/build/dist/UI/Components/Charts/Area/AreaChart.js +25 -1
- package/build/dist/UI/Components/Charts/Area/AreaChart.js.map +1 -1
- package/build/dist/UI/Components/Charts/Bar/BarChart.js +26 -2
- package/build/dist/UI/Components/Charts/Bar/BarChart.js.map +1 -1
- package/build/dist/UI/Components/Charts/ChartGroup/ChartGroup.js +36 -12
- package/build/dist/UI/Components/Charts/ChartGroup/ChartGroup.js.map +1 -1
- package/build/dist/UI/Components/Charts/ChartLibrary/AreaChart/AreaChart.js +217 -8
- package/build/dist/UI/Components/Charts/ChartLibrary/AreaChart/AreaChart.js.map +1 -1
- package/build/dist/UI/Components/Charts/ChartLibrary/BarChart/BarChart.js +55 -4
- package/build/dist/UI/Components/Charts/ChartLibrary/BarChart/BarChart.js.map +1 -1
- package/build/dist/UI/Components/Charts/ChartLibrary/LineChart/LineChart.js +217 -8
- package/build/dist/UI/Components/Charts/ChartLibrary/LineChart/LineChart.js.map +1 -1
- package/build/dist/UI/Components/Charts/ChartLibrary/Types/ChartDataPoint.js +6 -1
- package/build/dist/UI/Components/Charts/ChartLibrary/Types/ChartDataPoint.js.map +1 -1
- package/build/dist/UI/Components/Charts/ChartLibrary/Types/FormattedReferenceRegion.js +2 -0
- package/build/dist/UI/Components/Charts/ChartLibrary/Types/FormattedReferenceRegion.js.map +1 -0
- package/build/dist/UI/Components/Charts/ChartLibrary/Types/FormattedTimeReferenceLine.js +2 -0
- package/build/dist/UI/Components/Charts/ChartLibrary/Types/FormattedTimeReferenceLine.js.map +1 -0
- package/build/dist/UI/Components/Charts/Line/LineChart.js +25 -1
- package/build/dist/UI/Components/Charts/Line/LineChart.js.map +1 -1
- package/build/dist/UI/Components/Charts/Types/ReferenceRegionProps.js +2 -0
- package/build/dist/UI/Components/Charts/Types/ReferenceRegionProps.js.map +1 -0
- package/build/dist/UI/Components/Charts/Types/TimeReferenceLineProps.js +2 -0
- package/build/dist/UI/Components/Charts/Types/TimeReferenceLineProps.js.map +1 -0
- package/build/dist/UI/Components/Charts/Types/XAxis/XAxisPrecision.js +1 -0
- package/build/dist/UI/Components/Charts/Types/XAxis/XAxisPrecision.js.map +1 -1
- package/build/dist/UI/Components/Charts/Utils/DataPoint.js +0 -0
- package/build/dist/UI/Components/Charts/Utils/DataPoint.js.map +1 -1
- package/build/dist/UI/Components/Charts/Utils/TimeAnnotation.js +121 -0
- package/build/dist/UI/Components/Charts/Utils/TimeAnnotation.js.map +1 -0
- package/build/dist/UI/Components/Charts/Utils/XAxis.js +27 -4
- package/build/dist/UI/Components/Charts/Utils/XAxis.js.map +1 -1
- package/build/dist/UI/Components/Forms/BasicForm.js +24 -6
- package/build/dist/UI/Components/Forms/BasicForm.js.map +1 -1
- package/build/dist/UI/Components/Icon/Icon.js +15 -8
- package/build/dist/UI/Components/Icon/Icon.js.map +1 -1
- package/build/dist/UI/Components/Markdown.tsx/MarkdownViewer.js.map +1 -1
- package/build/dist/UI/Components/MonitorTemplateVariables/TemplateVariablesCatalog.js +58 -0
- package/build/dist/UI/Components/MonitorTemplateVariables/TemplateVariablesCatalog.js.map +1 -1
- package/build/dist/UI/Components/Page/ModelPage.js +7 -1
- package/build/dist/UI/Components/Page/ModelPage.js.map +1 -1
- package/build/dist/UI/Components/TelemetryViewer/components/SavedViewsDropdown.js +10 -4
- package/build/dist/UI/Components/TelemetryViewer/components/SavedViewsDropdown.js.map +1 -1
- package/build/dist/UI/Utils/AIChatExport/ChatWidgetData.js +217 -0
- package/build/dist/UI/Utils/AIChatExport/ChatWidgetData.js.map +1 -0
- package/build/dist/UI/Utils/AIChatExport/ChatWidgetMarkdown.js +234 -0
- package/build/dist/UI/Utils/AIChatExport/ChatWidgetMarkdown.js.map +1 -0
- package/build/dist/UI/Utils/AIChatExport/ConversationMarkdown.js +111 -0
- package/build/dist/UI/Utils/AIChatExport/ConversationMarkdown.js.map +1 -0
- package/build/dist/UI/Utils/AIChatExport/MarkdownBlocks.js +233 -0
- package/build/dist/UI/Utils/AIChatExport/MarkdownBlocks.js.map +1 -0
- package/build/dist/UI/Utils/AIChatExport/MarkdownSafety.js +134 -0
- package/build/dist/UI/Utils/AIChatExport/MarkdownSafety.js.map +1 -0
- package/build/dist/UI/Utils/DownloadFile.js +41 -0
- package/build/dist/UI/Utils/DownloadFile.js.map +1 -0
- package/build/dist/UI/Utils/User.js +35 -2
- package/build/dist/UI/Utils/User.js.map +1 -1
- package/build/dist/Utils/Analytics.js +8 -5
- package/build/dist/Utils/Analytics.js.map +1 -1
- package/build/dist/Utils/EnterpriseLicense/EnterpriseLicenseUsage.js +57 -0
- package/build/dist/Utils/EnterpriseLicense/EnterpriseLicenseUsage.js.map +1 -1
- package/build/dist/Utils/Metrics/MetricExplorerUrl.js +418 -0
- package/build/dist/Utils/Metrics/MetricExplorerUrl.js.map +1 -0
- package/build/dist/Utils/Metrics/MetricFormulaEvaluator.js +296 -37
- package/build/dist/Utils/Metrics/MetricFormulaEvaluator.js.map +1 -1
- package/build/dist/Utils/Monitor/NetworkTopologyUtil.js +176 -40
- package/build/dist/Utils/Monitor/NetworkTopologyUtil.js.map +1 -1
- package/build/dist/Utils/ValueFormatter.js +20 -1
- package/build/dist/Utils/ValueFormatter.js.map +1 -1
- package/package.json +6 -2
|
@@ -0,0 +1,548 @@
|
|
|
1
|
+
import API from "../../../../Utils/API";
|
|
2
|
+
import logger from "../../../../Server/Utils/Logger";
|
|
3
|
+
import HTTPErrorResponse from "../../../../Types/API/HTTPErrorResponse";
|
|
4
|
+
import HTTPResponse from "../../../../Types/API/HTTPResponse";
|
|
5
|
+
import { JSONObject } from "../../../../Types/JSON";
|
|
6
|
+
import LlmType from "../../../../Types/LLM/LlmType";
|
|
7
|
+
import LLMService, {
|
|
8
|
+
LLMProviderConfig,
|
|
9
|
+
} from "../../../../Server/Utils/LLM/LLMService";
|
|
10
|
+
import {
|
|
11
|
+
afterEach,
|
|
12
|
+
beforeEach,
|
|
13
|
+
describe,
|
|
14
|
+
expect,
|
|
15
|
+
jest,
|
|
16
|
+
test,
|
|
17
|
+
} from "@jest/globals";
|
|
18
|
+
|
|
19
|
+
type PostSpy = ReturnType<typeof jest.spyOn>;
|
|
20
|
+
|
|
21
|
+
const SUCCESS_BODY: JSONObject = {
|
|
22
|
+
choices: [{ message: { content: "OK" } }],
|
|
23
|
+
usage: { prompt_tokens: 5, completion_tokens: 1, total_tokens: 6 },
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
function successResponse(): HTTPResponse<JSONObject> {
|
|
27
|
+
return { jsonData: SUCCESS_BODY } as unknown as HTTPResponse<JSONObject>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** The verbatim 400 an o-series / gpt-5 deployment returns for max_tokens. */
|
|
31
|
+
function maxTokensUnsupportedResponse(): HTTPErrorResponse {
|
|
32
|
+
return new HTTPErrorResponse(
|
|
33
|
+
400,
|
|
34
|
+
{
|
|
35
|
+
error: {
|
|
36
|
+
message:
|
|
37
|
+
"Unsupported parameter: 'max_tokens' is not supported with this model. Use 'max_completion_tokens' instead.",
|
|
38
|
+
type: "invalid_request_error",
|
|
39
|
+
param: "max_tokens",
|
|
40
|
+
code: "unsupported_parameter",
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
{},
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Older models / Azure api-versions before 2024-08-01-preview. param and code are null. */
|
|
48
|
+
function maxCompletionTokensUnrecognizedResponse(): HTTPErrorResponse {
|
|
49
|
+
return new HTTPErrorResponse(
|
|
50
|
+
400,
|
|
51
|
+
{
|
|
52
|
+
error: {
|
|
53
|
+
message:
|
|
54
|
+
"Unrecognized request argument supplied: max_completion_tokens",
|
|
55
|
+
type: "invalid_request_error",
|
|
56
|
+
param: null,
|
|
57
|
+
code: null,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
{},
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function temperatureUnsupportedResponse(): HTTPErrorResponse {
|
|
65
|
+
return new HTTPErrorResponse(
|
|
66
|
+
400,
|
|
67
|
+
{
|
|
68
|
+
error: {
|
|
69
|
+
message:
|
|
70
|
+
"Unsupported value: 'temperature' does not support 0 with this model. Only the default (1) value is supported.",
|
|
71
|
+
type: "invalid_request_error",
|
|
72
|
+
param: "temperature",
|
|
73
|
+
code: "unsupported_value",
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
{},
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const AZURE_CONFIG: LLMProviderConfig = {
|
|
81
|
+
llmType: LlmType.AzureOpenAI,
|
|
82
|
+
apiKey: "azure-key",
|
|
83
|
+
baseUrl: "https://example.openai.azure.com/openai/deployments/my-deployment",
|
|
84
|
+
// Azure sends the *deployment* name, which need not resemble the model.
|
|
85
|
+
modelName: "my-deployment",
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
function bodyOf(spy: PostSpy, callIndex: number): JSONObject {
|
|
89
|
+
return (spy.mock.calls[callIndex]![0] as { data: JSONObject }).data;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
beforeEach(() => {
|
|
93
|
+
LLMService.clearRequestAdaptationCache();
|
|
94
|
+
jest.spyOn(logger, "debug").mockImplementation((): void => {});
|
|
95
|
+
jest.spyOn(logger, "error").mockImplementation((): void => {});
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
afterEach(() => {
|
|
99
|
+
jest.restoreAllMocks();
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
describe("LLMService — Azure OpenAI max_tokens compatibility", () => {
|
|
103
|
+
test("retries with max_completion_tokens when the deployment rejects max_tokens", async () => {
|
|
104
|
+
const spy: PostSpy = jest
|
|
105
|
+
.spyOn(API, "post")
|
|
106
|
+
.mockResolvedValueOnce(maxTokensUnsupportedResponse())
|
|
107
|
+
.mockResolvedValueOnce(successResponse()) as PostSpy;
|
|
108
|
+
|
|
109
|
+
const response: { content: string } = await LLMService.getCompletion({
|
|
110
|
+
llmProviderConfig: AZURE_CONFIG,
|
|
111
|
+
messages: [{ role: "user", content: "Reply with the word: OK" }],
|
|
112
|
+
maxTokens: 16,
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
expect(response.content).toBe("OK");
|
|
116
|
+
expect(spy).toHaveBeenCalledTimes(2);
|
|
117
|
+
|
|
118
|
+
// First attempt used the legacy spelling...
|
|
119
|
+
expect(bodyOf(spy, 0)["max_tokens"]).toBe(16);
|
|
120
|
+
expect(bodyOf(spy, 0)["max_completion_tokens"]).toBeUndefined();
|
|
121
|
+
|
|
122
|
+
// ...the retry swapped it, preserving the cap and dropping the legacy key.
|
|
123
|
+
expect(bodyOf(spy, 1)["max_completion_tokens"]).toBe(16);
|
|
124
|
+
expect(bodyOf(spy, 1)["max_tokens"]).toBeUndefined();
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
test("drops temperature when the deployment rejects it, after the token swap", async () => {
|
|
128
|
+
const spy: PostSpy = jest
|
|
129
|
+
.spyOn(API, "post")
|
|
130
|
+
.mockResolvedValueOnce(maxTokensUnsupportedResponse())
|
|
131
|
+
.mockResolvedValueOnce(temperatureUnsupportedResponse())
|
|
132
|
+
.mockResolvedValueOnce(successResponse()) as PostSpy;
|
|
133
|
+
|
|
134
|
+
const response: { content: string } = await LLMService.getCompletion({
|
|
135
|
+
llmProviderConfig: AZURE_CONFIG,
|
|
136
|
+
messages: [{ role: "user", content: "hi" }],
|
|
137
|
+
temperature: 0,
|
|
138
|
+
maxTokens: 16,
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
expect(response.content).toBe("OK");
|
|
142
|
+
expect(spy).toHaveBeenCalledTimes(3);
|
|
143
|
+
|
|
144
|
+
// Errors arrive one param at a time, so the fixes accumulate.
|
|
145
|
+
expect(bodyOf(spy, 1)["max_completion_tokens"]).toBe(16);
|
|
146
|
+
expect(bodyOf(spy, 1)["temperature"]).toBe(0);
|
|
147
|
+
|
|
148
|
+
expect(bodyOf(spy, 2)["max_completion_tokens"]).toBe(16);
|
|
149
|
+
expect(bodyOf(spy, 2)["temperature"]).toBeUndefined();
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
test("remembers what the deployment accepted so later calls do not re-probe", async () => {
|
|
153
|
+
const spy: PostSpy = jest
|
|
154
|
+
.spyOn(API, "post")
|
|
155
|
+
.mockResolvedValueOnce(maxTokensUnsupportedResponse())
|
|
156
|
+
.mockResolvedValue(successResponse()) as PostSpy;
|
|
157
|
+
|
|
158
|
+
await LLMService.getCompletion({
|
|
159
|
+
llmProviderConfig: AZURE_CONFIG,
|
|
160
|
+
messages: [{ role: "user", content: "hi" }],
|
|
161
|
+
maxTokens: 16,
|
|
162
|
+
});
|
|
163
|
+
expect(spy).toHaveBeenCalledTimes(2);
|
|
164
|
+
|
|
165
|
+
await LLMService.getCompletion({
|
|
166
|
+
llmProviderConfig: AZURE_CONFIG,
|
|
167
|
+
messages: [{ role: "user", content: "hi again" }],
|
|
168
|
+
maxTokens: 32,
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
// One extra call only: the second completion got the shape right first try.
|
|
172
|
+
expect(spy).toHaveBeenCalledTimes(3);
|
|
173
|
+
expect(bodyOf(spy, 2)["max_completion_tokens"]).toBe(32);
|
|
174
|
+
expect(bodyOf(spy, 2)["max_tokens"]).toBeUndefined();
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
test("re-probes when the model name changes", async () => {
|
|
178
|
+
const spy: PostSpy = jest
|
|
179
|
+
.spyOn(API, "post")
|
|
180
|
+
.mockResolvedValueOnce(maxTokensUnsupportedResponse())
|
|
181
|
+
.mockResolvedValue(successResponse()) as PostSpy;
|
|
182
|
+
|
|
183
|
+
await LLMService.getCompletion({
|
|
184
|
+
llmProviderConfig: AZURE_CONFIG,
|
|
185
|
+
messages: [{ role: "user", content: "hi" }],
|
|
186
|
+
maxTokens: 16,
|
|
187
|
+
});
|
|
188
|
+
expect(spy).toHaveBeenCalledTimes(2);
|
|
189
|
+
|
|
190
|
+
await LLMService.getCompletion({
|
|
191
|
+
llmProviderConfig: { ...AZURE_CONFIG, modelName: "other-deployment" },
|
|
192
|
+
messages: [{ role: "user", content: "hi" }],
|
|
193
|
+
maxTokens: 16,
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
// A different deployment is a different model: back to the legacy default.
|
|
197
|
+
expect(bodyOf(spy, 2)["max_tokens"]).toBe(16);
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
describe("LLMService — reasoning model detection by name", () => {
|
|
202
|
+
test.each([
|
|
203
|
+
["gpt-5", true],
|
|
204
|
+
["gpt-5-mini", true],
|
|
205
|
+
["gpt5-mini", true],
|
|
206
|
+
["o1", true],
|
|
207
|
+
["o1-mini", true],
|
|
208
|
+
["o3-mini", true],
|
|
209
|
+
["o4-mini", true],
|
|
210
|
+
["codex-mini", true],
|
|
211
|
+
["gpt-4o", false],
|
|
212
|
+
["gpt-4o-mini", false],
|
|
213
|
+
["gpt-4.1", false],
|
|
214
|
+
["gpt-4-turbo", false],
|
|
215
|
+
["gpt-35-turbo", false],
|
|
216
|
+
])(
|
|
217
|
+
"%s sends max_completion_tokens up front: %s",
|
|
218
|
+
async (modelName: string, expectsMaxCompletionTokens: boolean) => {
|
|
219
|
+
const spy: PostSpy = jest
|
|
220
|
+
.spyOn(API, "post")
|
|
221
|
+
.mockResolvedValue(successResponse()) as PostSpy;
|
|
222
|
+
|
|
223
|
+
await LLMService.getCompletion({
|
|
224
|
+
llmProviderConfig: {
|
|
225
|
+
llmType: LlmType.OpenAI,
|
|
226
|
+
apiKey: "test-key",
|
|
227
|
+
modelName: modelName,
|
|
228
|
+
},
|
|
229
|
+
messages: [{ role: "user", content: "hi" }],
|
|
230
|
+
maxTokens: 16,
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
// Known reasoning models skip the wasted round trip entirely.
|
|
234
|
+
expect(spy).toHaveBeenCalledTimes(1);
|
|
235
|
+
const body: JSONObject = bodyOf(spy, 0);
|
|
236
|
+
|
|
237
|
+
if (expectsMaxCompletionTokens) {
|
|
238
|
+
expect(body["max_completion_tokens"]).toBe(16);
|
|
239
|
+
expect(body["max_tokens"]).toBeUndefined();
|
|
240
|
+
} else {
|
|
241
|
+
expect(body["max_tokens"]).toBe(16);
|
|
242
|
+
expect(body["max_completion_tokens"]).toBeUndefined();
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
);
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
describe("LLMService — legacy models that reject max_completion_tokens", () => {
|
|
249
|
+
test("falls back to max_tokens when the endpoint does not recognize max_completion_tokens", async () => {
|
|
250
|
+
const spy: PostSpy = jest
|
|
251
|
+
.spyOn(API, "post")
|
|
252
|
+
.mockResolvedValueOnce(maxCompletionTokensUnrecognizedResponse())
|
|
253
|
+
.mockResolvedValueOnce(successResponse()) as PostSpy;
|
|
254
|
+
|
|
255
|
+
// A gpt-5-named deployment behind an endpoint that only knows max_tokens.
|
|
256
|
+
const response: { content: string } = await LLMService.getCompletion({
|
|
257
|
+
llmProviderConfig: { ...AZURE_CONFIG, modelName: "gpt-5-mini" },
|
|
258
|
+
messages: [{ role: "user", content: "hi" }],
|
|
259
|
+
maxTokens: 16,
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
expect(response.content).toBe("OK");
|
|
263
|
+
expect(bodyOf(spy, 0)["max_completion_tokens"]).toBe(16);
|
|
264
|
+
expect(bodyOf(spy, 1)["max_tokens"]).toBe(16);
|
|
265
|
+
expect(bodyOf(spy, 1)["max_completion_tokens"]).toBeUndefined();
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
test("does not flip-flop when the endpoint rejects both spellings", async () => {
|
|
269
|
+
const spy: PostSpy = jest
|
|
270
|
+
.spyOn(API, "post")
|
|
271
|
+
.mockResolvedValueOnce(maxCompletionTokensUnrecognizedResponse())
|
|
272
|
+
.mockResolvedValue(maxTokensUnsupportedResponse()) as PostSpy;
|
|
273
|
+
|
|
274
|
+
await expect(
|
|
275
|
+
LLMService.getCompletion({
|
|
276
|
+
llmProviderConfig: { ...AZURE_CONFIG, modelName: "gpt-5-mini" },
|
|
277
|
+
messages: [{ role: "user", content: "hi" }],
|
|
278
|
+
maxTokens: 16,
|
|
279
|
+
}),
|
|
280
|
+
).rejects.toThrow("Azure OpenAI API error");
|
|
281
|
+
|
|
282
|
+
// Each spelling is tried exactly once, then the provider error surfaces.
|
|
283
|
+
expect(spy).toHaveBeenCalledTimes(2);
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
test("does not flip-flop when the name heuristic misses and additionalParams chose the new spelling", async () => {
|
|
287
|
+
const spy: PostSpy = jest
|
|
288
|
+
.spyOn(API, "post")
|
|
289
|
+
.mockResolvedValueOnce(maxCompletionTokensUnrecognizedResponse())
|
|
290
|
+
.mockResolvedValue(maxTokensUnsupportedResponse()) as PostSpy;
|
|
291
|
+
|
|
292
|
+
/*
|
|
293
|
+
* modelName does not match the heuristic, so the adaptation starts at the
|
|
294
|
+
* Default sentinel while additionalParams puts max_completion_tokens on
|
|
295
|
+
* the wire. Both spellings must still be tried at most once each.
|
|
296
|
+
*/
|
|
297
|
+
await expect(
|
|
298
|
+
LLMService.getCompletion({
|
|
299
|
+
llmProviderConfig: { ...AZURE_CONFIG, modelName: "prod" },
|
|
300
|
+
messages: [{ role: "user", content: "hi" }],
|
|
301
|
+
maxTokens: 16,
|
|
302
|
+
additionalParams: { max_completion_tokens: 4000 },
|
|
303
|
+
}),
|
|
304
|
+
).rejects.toThrow("Azure OpenAI API error");
|
|
305
|
+
|
|
306
|
+
expect(spy).toHaveBeenCalledTimes(2);
|
|
307
|
+
expect(bodyOf(spy, 0)["max_completion_tokens"]).toBeDefined();
|
|
308
|
+
expect(bodyOf(spy, 1)["max_tokens"]).toBeDefined();
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
test("adapts a chain longer than four params rather than giving up short", async () => {
|
|
312
|
+
const reject: (param: string) => HTTPErrorResponse = (
|
|
313
|
+
param: string,
|
|
314
|
+
): HTTPErrorResponse => {
|
|
315
|
+
return new HTTPErrorResponse(
|
|
316
|
+
400,
|
|
317
|
+
{
|
|
318
|
+
error: {
|
|
319
|
+
message: `Unsupported parameter: '${param}' is not supported with this model.`,
|
|
320
|
+
type: "invalid_request_error",
|
|
321
|
+
param: param,
|
|
322
|
+
code: "unsupported_parameter",
|
|
323
|
+
},
|
|
324
|
+
},
|
|
325
|
+
{},
|
|
326
|
+
);
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
const spy: PostSpy = jest
|
|
330
|
+
.spyOn(API, "post")
|
|
331
|
+
.mockResolvedValueOnce(maxTokensUnsupportedResponse())
|
|
332
|
+
.mockResolvedValueOnce(reject("temperature"))
|
|
333
|
+
.mockResolvedValueOnce(reject("top_p"))
|
|
334
|
+
.mockResolvedValueOnce(reject("frequency_penalty"))
|
|
335
|
+
.mockResolvedValueOnce(reject("presence_penalty"))
|
|
336
|
+
.mockResolvedValueOnce(successResponse()) as PostSpy;
|
|
337
|
+
|
|
338
|
+
// Five reshapes are needed; the attempt cap must not cut this short.
|
|
339
|
+
const response: { content: string } = await LLMService.getCompletion({
|
|
340
|
+
llmProviderConfig: { ...AZURE_CONFIG, modelName: "prod" },
|
|
341
|
+
messages: [{ role: "user", content: "hi" }],
|
|
342
|
+
temperature: 0,
|
|
343
|
+
maxTokens: 16,
|
|
344
|
+
additionalParams: {
|
|
345
|
+
top_p: 0.9,
|
|
346
|
+
frequency_penalty: 0.2,
|
|
347
|
+
presence_penalty: 0.2,
|
|
348
|
+
},
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
expect(response.content).toBe("OK");
|
|
352
|
+
expect(spy).toHaveBeenCalledTimes(6);
|
|
353
|
+
|
|
354
|
+
const finalBody: JSONObject = bodyOf(spy, 5);
|
|
355
|
+
expect(finalBody["max_completion_tokens"]).toBe(16);
|
|
356
|
+
expect(finalBody["temperature"]).toBeUndefined();
|
|
357
|
+
expect(finalBody["top_p"]).toBeUndefined();
|
|
358
|
+
expect(finalBody["frequency_penalty"]).toBeUndefined();
|
|
359
|
+
expect(finalBody["presence_penalty"]).toBeUndefined();
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
test("remembers dropped params, not just the token spelling", async () => {
|
|
363
|
+
const spy: PostSpy = jest
|
|
364
|
+
.spyOn(API, "post")
|
|
365
|
+
.mockResolvedValueOnce(maxTokensUnsupportedResponse())
|
|
366
|
+
.mockResolvedValueOnce(temperatureUnsupportedResponse())
|
|
367
|
+
.mockResolvedValue(successResponse()) as PostSpy;
|
|
368
|
+
|
|
369
|
+
await LLMService.getCompletion({
|
|
370
|
+
llmProviderConfig: AZURE_CONFIG,
|
|
371
|
+
messages: [{ role: "user", content: "hi" }],
|
|
372
|
+
temperature: 0,
|
|
373
|
+
maxTokens: 16,
|
|
374
|
+
});
|
|
375
|
+
expect(spy).toHaveBeenCalledTimes(3);
|
|
376
|
+
|
|
377
|
+
await LLMService.getCompletion({
|
|
378
|
+
llmProviderConfig: AZURE_CONFIG,
|
|
379
|
+
messages: [{ role: "user", content: "again" }],
|
|
380
|
+
temperature: 0,
|
|
381
|
+
maxTokens: 16,
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
// Both halves of what was learned must survive: the spelling and the drop.
|
|
385
|
+
expect(spy).toHaveBeenCalledTimes(4);
|
|
386
|
+
expect(bodyOf(spy, 3)["max_completion_tokens"]).toBe(16);
|
|
387
|
+
expect(bodyOf(spy, 3)["temperature"]).toBeUndefined();
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
test("keeps two Azure resources that share a deployment name apart", async () => {
|
|
391
|
+
const spy: PostSpy = jest
|
|
392
|
+
.spyOn(API, "post")
|
|
393
|
+
.mockResolvedValueOnce(maxTokensUnsupportedResponse())
|
|
394
|
+
.mockResolvedValue(successResponse()) as PostSpy;
|
|
395
|
+
|
|
396
|
+
await LLMService.getCompletion({
|
|
397
|
+
llmProviderConfig: AZURE_CONFIG,
|
|
398
|
+
messages: [{ role: "user", content: "hi" }],
|
|
399
|
+
maxTokens: 16,
|
|
400
|
+
});
|
|
401
|
+
expect(spy).toHaveBeenCalledTimes(2);
|
|
402
|
+
|
|
403
|
+
await LLMService.getCompletion({
|
|
404
|
+
llmProviderConfig: {
|
|
405
|
+
...AZURE_CONFIG,
|
|
406
|
+
baseUrl:
|
|
407
|
+
"https://other.openai.azure.com/openai/deployments/my-deployment",
|
|
408
|
+
},
|
|
409
|
+
messages: [{ role: "user", content: "hi" }],
|
|
410
|
+
maxTokens: 16,
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
/*
|
|
414
|
+
* Same deployment name, different resource: what one accepts says nothing
|
|
415
|
+
* about the other, so it must re-probe.
|
|
416
|
+
*/
|
|
417
|
+
expect(bodyOf(spy, 2)["max_tokens"]).toBe(16);
|
|
418
|
+
});
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
describe("LLMService — errors that are not parameter-compatibility problems", () => {
|
|
422
|
+
test("a max_tokens value error surfaces as-is instead of triggering a rename", async () => {
|
|
423
|
+
const spy: PostSpy = jest.spyOn(API, "post").mockResolvedValue(
|
|
424
|
+
new HTTPErrorResponse(
|
|
425
|
+
400,
|
|
426
|
+
{
|
|
427
|
+
error: {
|
|
428
|
+
message:
|
|
429
|
+
"max_tokens is too large: 200000. This model supports at most 16384 completion tokens.",
|
|
430
|
+
type: "invalid_request_error",
|
|
431
|
+
param: "max_tokens",
|
|
432
|
+
code: null,
|
|
433
|
+
},
|
|
434
|
+
},
|
|
435
|
+
{},
|
|
436
|
+
),
|
|
437
|
+
) as PostSpy;
|
|
438
|
+
|
|
439
|
+
await expect(
|
|
440
|
+
LLMService.getCompletion({
|
|
441
|
+
llmProviderConfig: {
|
|
442
|
+
llmType: LlmType.OpenAI,
|
|
443
|
+
apiKey: "test-key",
|
|
444
|
+
modelName: "gpt-4o",
|
|
445
|
+
},
|
|
446
|
+
messages: [{ role: "user", content: "hi" }],
|
|
447
|
+
maxTokens: 200000,
|
|
448
|
+
}),
|
|
449
|
+
/*
|
|
450
|
+
* Renaming the param would not fix a too-large value; it would only
|
|
451
|
+
* bury the real complaint under one about a param the caller never set.
|
|
452
|
+
*/
|
|
453
|
+
).rejects.toThrow("max_tokens is too large");
|
|
454
|
+
|
|
455
|
+
expect(spy).toHaveBeenCalledTimes(1);
|
|
456
|
+
});
|
|
457
|
+
|
|
458
|
+
test("the plural unrecognized-argument wording still triggers the fallback", async () => {
|
|
459
|
+
const spy: PostSpy = jest
|
|
460
|
+
.spyOn(API, "post")
|
|
461
|
+
.mockResolvedValueOnce(
|
|
462
|
+
new HTTPErrorResponse(
|
|
463
|
+
400,
|
|
464
|
+
{
|
|
465
|
+
error: {
|
|
466
|
+
message:
|
|
467
|
+
"Unrecognized request arguments supplied: max_completion_tokens, reasoning_effort",
|
|
468
|
+
type: "invalid_request_error",
|
|
469
|
+
param: null,
|
|
470
|
+
code: null,
|
|
471
|
+
},
|
|
472
|
+
},
|
|
473
|
+
{},
|
|
474
|
+
),
|
|
475
|
+
)
|
|
476
|
+
.mockResolvedValueOnce(successResponse()) as PostSpy;
|
|
477
|
+
|
|
478
|
+
const response: { content: string } = await LLMService.getCompletion({
|
|
479
|
+
llmProviderConfig: { ...AZURE_CONFIG, modelName: "gpt-5-mini" },
|
|
480
|
+
messages: [{ role: "user", content: "hi" }],
|
|
481
|
+
maxTokens: 16,
|
|
482
|
+
});
|
|
483
|
+
|
|
484
|
+
expect(response.content).toBe("OK");
|
|
485
|
+
expect(bodyOf(spy, 1)["max_tokens"]).toBe(16);
|
|
486
|
+
});
|
|
487
|
+
|
|
488
|
+
test("an auth failure is surfaced without any retry", async () => {
|
|
489
|
+
const spy: PostSpy = jest.spyOn(API, "post").mockResolvedValue(
|
|
490
|
+
new HTTPErrorResponse(
|
|
491
|
+
401,
|
|
492
|
+
{
|
|
493
|
+
error: {
|
|
494
|
+
message: "Incorrect API key provided.",
|
|
495
|
+
type: "invalid_request_error",
|
|
496
|
+
param: null,
|
|
497
|
+
code: "invalid_api_key",
|
|
498
|
+
},
|
|
499
|
+
},
|
|
500
|
+
{},
|
|
501
|
+
),
|
|
502
|
+
) as PostSpy;
|
|
503
|
+
|
|
504
|
+
await expect(
|
|
505
|
+
LLMService.getCompletion({
|
|
506
|
+
llmProviderConfig: AZURE_CONFIG,
|
|
507
|
+
messages: [{ role: "user", content: "hi" }],
|
|
508
|
+
maxTokens: 16,
|
|
509
|
+
}),
|
|
510
|
+
).rejects.toThrow("Azure OpenAI API error");
|
|
511
|
+
|
|
512
|
+
expect(spy).toHaveBeenCalledTimes(1);
|
|
513
|
+
});
|
|
514
|
+
|
|
515
|
+
test("a failed request is not cached as a working shape", async () => {
|
|
516
|
+
jest
|
|
517
|
+
.spyOn(API, "post")
|
|
518
|
+
.mockResolvedValueOnce(maxTokensUnsupportedResponse())
|
|
519
|
+
.mockResolvedValueOnce(
|
|
520
|
+
new HTTPErrorResponse(500, { error: { message: "upstream boom" } }, {}),
|
|
521
|
+
);
|
|
522
|
+
|
|
523
|
+
await expect(
|
|
524
|
+
LLMService.getCompletion({
|
|
525
|
+
llmProviderConfig: AZURE_CONFIG,
|
|
526
|
+
messages: [{ role: "user", content: "hi" }],
|
|
527
|
+
maxTokens: 16,
|
|
528
|
+
}),
|
|
529
|
+
).rejects.toThrow("Azure OpenAI API error");
|
|
530
|
+
|
|
531
|
+
jest.restoreAllMocks();
|
|
532
|
+
jest.spyOn(logger, "debug").mockImplementation((): void => {});
|
|
533
|
+
jest.spyOn(logger, "error").mockImplementation((): void => {});
|
|
534
|
+
|
|
535
|
+
const spy: PostSpy = jest
|
|
536
|
+
.spyOn(API, "post")
|
|
537
|
+
.mockResolvedValue(successResponse()) as PostSpy;
|
|
538
|
+
|
|
539
|
+
await LLMService.getCompletion({
|
|
540
|
+
llmProviderConfig: AZURE_CONFIG,
|
|
541
|
+
messages: [{ role: "user", content: "hi" }],
|
|
542
|
+
maxTokens: 16,
|
|
543
|
+
});
|
|
544
|
+
|
|
545
|
+
// The swap was never confirmed to work, so it must not be remembered.
|
|
546
|
+
expect(bodyOf(spy, 0)["max_tokens"]).toBe(16);
|
|
547
|
+
});
|
|
548
|
+
});
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildObservabilityChatSystemPrompt,
|
|
3
|
+
buildPageContextSection,
|
|
4
|
+
} from "../../../../Server/Utils/AI/Chat/ObservabilityChatPrompt";
|
|
5
|
+
import AIChatPageContextType, {
|
|
6
|
+
AIChatPageContext,
|
|
7
|
+
} from "../../../../Types/AI/AIChatPageContext";
|
|
8
|
+
import AIChatPermissionMode from "../../../../Types/AI/AIChatPermissionMode";
|
|
9
|
+
import { describe, expect, test } from "@jest/globals";
|
|
10
|
+
|
|
11
|
+
const ENTITY_ID: string = "0f10509d-6656-4a08-b957-235fd4e8c52e";
|
|
12
|
+
const TRACE_ID: string = "4bf92f3577b34da6a3ce929d0e0e4736";
|
|
13
|
+
|
|
14
|
+
describe("buildPageContextSection", () => {
|
|
15
|
+
test("returns an empty string without a context", () => {
|
|
16
|
+
expect(buildPageContextSection(undefined)).toBe("");
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
/*
|
|
20
|
+
* Each entity type must name the tool (and its id argument) that fetches
|
|
21
|
+
* the entity — that pairing is what lets the model resolve "this incident"
|
|
22
|
+
* without guessing.
|
|
23
|
+
*/
|
|
24
|
+
test.each<[AIChatPageContextType, string]>([
|
|
25
|
+
[
|
|
26
|
+
AIChatPageContextType.Incident,
|
|
27
|
+
`query_incidents using incidentId="${ENTITY_ID}"`,
|
|
28
|
+
],
|
|
29
|
+
[AIChatPageContextType.Alert, `query_alerts using alertId="${ENTITY_ID}"`],
|
|
30
|
+
[
|
|
31
|
+
AIChatPageContextType.Monitor,
|
|
32
|
+
`query_monitors using monitorId="${ENTITY_ID}"`,
|
|
33
|
+
],
|
|
34
|
+
[AIChatPageContextType.TelemetryService, `serviceId="${ENTITY_ID}"`],
|
|
35
|
+
[
|
|
36
|
+
AIChatPageContextType.Exception,
|
|
37
|
+
`find_code_for_exception with exceptionId="${ENTITY_ID}"`,
|
|
38
|
+
],
|
|
39
|
+
])(
|
|
40
|
+
"%s guidance names the fetch tool and id",
|
|
41
|
+
(type: AIChatPageContextType, expected: string) => {
|
|
42
|
+
const section: string = buildPageContextSection({
|
|
43
|
+
type: type,
|
|
44
|
+
entityId: ENTITY_ID,
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
expect(section).toContain("## Current page context");
|
|
48
|
+
expect(section).toContain(expected);
|
|
49
|
+
},
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
test("trace guidance uses get_trace with the hex trace id", () => {
|
|
53
|
+
const section: string = buildPageContextSection({
|
|
54
|
+
type: AIChatPageContextType.Trace,
|
|
55
|
+
entityId: TRACE_ID,
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
expect(section).toContain(`get_trace using traceId="${TRACE_ID}"`);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test("scheduled maintenance guidance names query_scheduled_maintenance", () => {
|
|
62
|
+
const section: string = buildPageContextSection({
|
|
63
|
+
type: AIChatPageContextType.ScheduledMaintenanceEvent,
|
|
64
|
+
entityId: ENTITY_ID,
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
expect(section).toContain(
|
|
68
|
+
`query_scheduled_maintenance using scheduledMaintenanceId="${ENTITY_ID}"`,
|
|
69
|
+
);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
test("the entity title is included in quotes when present", () => {
|
|
73
|
+
const section: string = buildPageContextSection({
|
|
74
|
+
type: AIChatPageContextType.Incident,
|
|
75
|
+
entityId: ENTITY_ID,
|
|
76
|
+
entityTitle: "#42 Payment API down",
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
expect(section).toContain('titled "#42 Payment API down"');
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
test.each<[AIChatPageContextType, string]>([
|
|
83
|
+
[AIChatPageContextType.IncidentsList, "query_incidents"],
|
|
84
|
+
[AIChatPageContextType.AlertsList, "query_alerts"],
|
|
85
|
+
[AIChatPageContextType.MonitorsList, "query_monitors"],
|
|
86
|
+
[
|
|
87
|
+
AIChatPageContextType.ScheduledMaintenanceList,
|
|
88
|
+
"query_scheduled_maintenance",
|
|
89
|
+
],
|
|
90
|
+
[AIChatPageContextType.LogsExplorer, "log_histogram"],
|
|
91
|
+
[AIChatPageContextType.TracesExplorer, "query_traces"],
|
|
92
|
+
[AIChatPageContextType.MetricsExplorer, "query_metrics"],
|
|
93
|
+
[AIChatPageContextType.ExceptionsList, "top_exceptions"],
|
|
94
|
+
])(
|
|
95
|
+
"area context %s names its primary tool",
|
|
96
|
+
(type: AIChatPageContextType, expectedTool: string) => {
|
|
97
|
+
const context: AIChatPageContext = { type: type };
|
|
98
|
+
const section: string = buildPageContextSection(context);
|
|
99
|
+
|
|
100
|
+
expect(section).toContain("## Current page context");
|
|
101
|
+
expect(section).toContain(expectedTool);
|
|
102
|
+
},
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
test("every section reminds the model that context is not evidence", () => {
|
|
106
|
+
const section: string = buildPageContextSection({
|
|
107
|
+
type: AIChatPageContextType.Incident,
|
|
108
|
+
entityId: ENTITY_ID,
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
expect(section).toContain("It is not evidence");
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
describe("buildObservabilityChatSystemPrompt with page context", () => {
|
|
116
|
+
test("omits the section when no context is passed", () => {
|
|
117
|
+
const prompt: string = buildObservabilityChatSystemPrompt({
|
|
118
|
+
currentTime: new Date("2026-07-16T00:00:00Z"),
|
|
119
|
+
permissionMode: AIChatPermissionMode.AskForApproval,
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
expect(prompt).not.toContain("## Current page context");
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
test("includes the section without displacing the hard rules", () => {
|
|
126
|
+
const prompt: string = buildObservabilityChatSystemPrompt({
|
|
127
|
+
currentTime: new Date("2026-07-16T00:00:00Z"),
|
|
128
|
+
permissionMode: AIChatPermissionMode.AskForApproval,
|
|
129
|
+
pageContext: {
|
|
130
|
+
type: AIChatPageContextType.Incident,
|
|
131
|
+
entityId: ENTITY_ID,
|
|
132
|
+
entityTitle: "Payment API down",
|
|
133
|
+
},
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
expect(prompt).toContain("## Current page context");
|
|
137
|
+
expect(prompt).toContain(`incidentId="${ENTITY_ID}"`);
|
|
138
|
+
// The binding trust rules survive untouched.
|
|
139
|
+
expect(prompt).toContain("## Hard rules");
|
|
140
|
+
expect(prompt).toContain("Cite your sources.");
|
|
141
|
+
});
|
|
142
|
+
});
|