@oneuptime/common 11.5.7 → 11.5.9
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/AIAgentTaskPullRequest.ts +15 -6
- package/Models/DatabaseModels/AIRun.ts +68 -0
- package/Models/DatabaseModels/AIRunEvent.ts +34 -1
- package/Models/DatabaseModels/NetworkDeviceDiscoveryScan.ts +215 -0
- package/Models/DatabaseModels/Project.ts +25 -0
- package/Models/DatabaseModels/StatusPage.ts +42 -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/CodeFixRunAPI.ts +190 -57
- package/Server/API/TelemetryExceptionAPI.ts +6 -1
- package/Server/Infrastructure/Postgres/SchemaMigrations/1784105912819-BackfillCodeFixTaskType.ts +41 -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/1784200000000-AddSnmpV3ColumnsToNetworkDeviceDiscoveryScan.ts +49 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +10 -0
- package/Server/Middleware/MasterAdminAuthorization.ts +1 -1
- package/Server/Middleware/ProjectAuthorization.ts +1 -1
- package/Server/Services/AIRunEventService.ts +15 -1
- package/Server/Services/AIRunService.ts +48 -12
- package/Server/Services/LlmProviderService.ts +2 -0
- package/Server/Services/ProjectService.ts +42 -0
- package/Server/Services/StatusPageService.ts +87 -0
- package/Server/Services/TelemetryExceptionService.ts +19 -90
- package/Server/Types/Markdown.ts +9 -9
- package/Server/Types/MarkdownSlugify.ts +47 -0
- package/Server/Utils/AI/AIRunPrivacyFilter.ts +106 -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/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/Monitor/NetworkDeviceHydrationUtil.ts +4 -11
- package/Tests/Models/StatusPageEnableMcpServer.test.ts +125 -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/AIRunPrivacyFilter.test.ts +295 -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/NetworkDeviceHydrationUtil.test.ts +502 -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/Log/LogSeverity.test.ts +78 -0
- package/Tests/UI/Components/BasicFormDropdownNormalization.test.tsx +167 -0
- package/Tests/UI/Components/Charts/AxisTickColor.test.tsx +66 -0
- package/Tests/UI/Utils/AIChatExport/ChatWidgetData.test.ts +319 -0
- package/Tests/UI/Utils/AIChatExport/ChatWidgetMarkdown.test.ts +188 -0
- 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/Email/EmailTemplateType.ts +2 -0
- package/Types/Log/LogSeverity.ts +61 -0
- package/Types/Monitor/SnmpMonitor/SnmpVersion.ts +40 -0
- package/UI/Components/Charts/ChartLibrary/AreaChart/AreaChart.tsx +8 -2
- package/UI/Components/Charts/ChartLibrary/BarChart/BarChart.tsx +3 -1
- package/UI/Components/Charts/ChartLibrary/LineChart/LineChart.tsx +8 -2
- package/UI/Components/EditionLabel/EditionLabel.tsx +821 -331
- package/UI/Components/Forms/BasicForm.tsx +26 -8
- package/UI/Styles/Theme.css +1314 -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/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 +69 -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/NetworkDeviceDiscoveryScan.js +225 -0
- package/build/dist/Models/DatabaseModels/NetworkDeviceDiscoveryScan.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Project.js +27 -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/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/CodeFixRunAPI.js +165 -51
- package/build/dist/Server/API/CodeFixRunAPI.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/Infrastructure/Postgres/SchemaMigrations/1784105912819-BackfillCodeFixTaskType.js +36 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1784105912819-BackfillCodeFixTaskType.js.map +1 -0
- 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/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/Index.js +10 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
- package/build/dist/Server/Middleware/MasterAdminAuthorization.js +1 -1
- package/build/dist/Server/Middleware/ProjectAuthorization.js +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 +39 -3
- package/build/dist/Server/Services/AIRunService.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/ProjectService.js +39 -0
- package/build/dist/Server/Services/ProjectService.js.map +1 -1
- package/build/dist/Server/Services/StatusPageService.js +81 -0
- package/build/dist/Server/Services/StatusPageService.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/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/AIRunPrivacyFilter.js +82 -0
- package/build/dist/Server/Utils/AI/AIRunPrivacyFilter.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/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/Monitor/NetworkDeviceHydrationUtil.js +2 -11
- package/build/dist/Server/Utils/Monitor/NetworkDeviceHydrationUtil.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/Email/EmailTemplateType.js +1 -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/Monitor/SnmpMonitor/SnmpVersion.js +38 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpVersion.js.map +1 -1
- package/build/dist/UI/Components/Charts/ChartLibrary/AreaChart/AreaChart.js +9 -2
- package/build/dist/UI/Components/Charts/ChartLibrary/AreaChart/AreaChart.js.map +1 -1
- package/build/dist/UI/Components/Charts/ChartLibrary/BarChart/BarChart.js +3 -1
- package/build/dist/UI/Components/Charts/ChartLibrary/BarChart/BarChart.js.map +1 -1
- package/build/dist/UI/Components/Charts/ChartLibrary/LineChart/LineChart.js +9 -2
- package/build/dist/UI/Components/Charts/ChartLibrary/LineChart/LineChart.js.map +1 -1
- package/build/dist/UI/Components/EditionLabel/EditionLabel.js +424 -139
- package/build/dist/UI/Components/EditionLabel/EditionLabel.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/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/package.json +5 -1
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import ScheduledMaintenance from "../../../../Models/DatabaseModels/ScheduledMaintenance";
|
|
2
|
+
import { JSONObject } from "../../../../Types/JSON";
|
|
3
|
+
import ObjectID from "../../../../Types/ObjectID";
|
|
4
|
+
import Permission from "../../../../Types/Permission";
|
|
5
|
+
import SortOrder from "../../../../Types/BaseDatabase/SortOrder";
|
|
6
|
+
import { AIChatCitationTargetType } from "../../../../Types/AI/AIChatTypes";
|
|
7
|
+
import ScheduledMaintenanceService from "../../../Services/ScheduledMaintenanceService";
|
|
8
|
+
import QueryHelper from "../../../Types/Database/QueryHelper";
|
|
9
|
+
import OneUptimeDate from "../../../../Types/Date";
|
|
10
|
+
import ToolResultSerializer, { SerializedResult } from "./Serializer";
|
|
11
|
+
import WidgetBuilder from "./WidgetBuilder";
|
|
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 model class is fully wired up, so
|
|
23
|
+
* 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 ScheduledMaintenance().getReadPermissions();
|
|
31
|
+
}
|
|
32
|
+
return cachedReadPermissions;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
function joinNames(items: Array<{ name?: string }> | undefined): string {
|
|
36
|
+
return (items || [])
|
|
37
|
+
.map((item: { name?: string }) => {
|
|
38
|
+
return item.name || "";
|
|
39
|
+
})
|
|
40
|
+
.filter((value: string) => {
|
|
41
|
+
return value.length > 0;
|
|
42
|
+
})
|
|
43
|
+
.join(", ");
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const QueryScheduledMaintenanceTool: ObservabilityTool = {
|
|
47
|
+
name: "query_scheduled_maintenance",
|
|
48
|
+
description:
|
|
49
|
+
"Query scheduled maintenance events (planned maintenance windows) in this project — past, ongoing and upcoming. Returns events whose window overlaps the requested range, with their state, window and affected monitors. Pass scheduledMaintenanceId to get full details of one event. Use the event's window to judge whether telemetry changes were expected maintenance rather than a real problem.",
|
|
50
|
+
inputSchema: {
|
|
51
|
+
type: "object",
|
|
52
|
+
properties: {
|
|
53
|
+
scheduledMaintenanceId: {
|
|
54
|
+
type: "string",
|
|
55
|
+
description:
|
|
56
|
+
"Get one scheduled maintenance event by its ID (includes description and affected monitors).",
|
|
57
|
+
},
|
|
58
|
+
pastDays: {
|
|
59
|
+
type: "number",
|
|
60
|
+
description:
|
|
61
|
+
"Include events whose window ends within this many days in the past (default 30, max 365).",
|
|
62
|
+
},
|
|
63
|
+
upcomingDays: {
|
|
64
|
+
type: "number",
|
|
65
|
+
description:
|
|
66
|
+
"Include events whose window starts within this many days in the future (default 30, max 365).",
|
|
67
|
+
},
|
|
68
|
+
limit: {
|
|
69
|
+
type: "number",
|
|
70
|
+
description: "Maximum events to return (default 10, max 25).",
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
get requiredPermissions(): Array<Permission> {
|
|
75
|
+
return resolveReadPermissions();
|
|
76
|
+
},
|
|
77
|
+
execute: async (
|
|
78
|
+
args: JSONObject,
|
|
79
|
+
ctx: ToolContext,
|
|
80
|
+
): Promise<ToolExecutionResult> => {
|
|
81
|
+
const scheduledMaintenanceId: ObjectID | undefined = ToolArgs.getObjectID(
|
|
82
|
+
args,
|
|
83
|
+
"scheduledMaintenanceId",
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
if (scheduledMaintenanceId) {
|
|
87
|
+
const event: ScheduledMaintenance | null =
|
|
88
|
+
await ScheduledMaintenanceService.findOneById({
|
|
89
|
+
id: scheduledMaintenanceId,
|
|
90
|
+
select: {
|
|
91
|
+
_id: true,
|
|
92
|
+
title: true,
|
|
93
|
+
description: true,
|
|
94
|
+
scheduledMaintenanceNumber: true,
|
|
95
|
+
createdAt: true,
|
|
96
|
+
startsAt: true,
|
|
97
|
+
endsAt: true,
|
|
98
|
+
currentScheduledMaintenanceState: {
|
|
99
|
+
name: true,
|
|
100
|
+
},
|
|
101
|
+
monitors: {
|
|
102
|
+
_id: true,
|
|
103
|
+
name: true,
|
|
104
|
+
},
|
|
105
|
+
labels: {
|
|
106
|
+
name: true,
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
props: ctx.props,
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
/*
|
|
113
|
+
* Surface the blast radius (affected monitors) and the exact window so
|
|
114
|
+
* the model can scope log/trace/metric queries to the maintenance
|
|
115
|
+
* period instead of guessing which hours were "expected downtime".
|
|
116
|
+
*/
|
|
117
|
+
const rows: Array<JSONObject> = event
|
|
118
|
+
? [
|
|
119
|
+
{
|
|
120
|
+
id: event.id?.toString(),
|
|
121
|
+
scheduledMaintenanceNumber: event.scheduledMaintenanceNumber,
|
|
122
|
+
title: event.title,
|
|
123
|
+
description: event.description,
|
|
124
|
+
state: event.currentScheduledMaintenanceState?.name,
|
|
125
|
+
startsAt: event.startsAt,
|
|
126
|
+
endsAt: event.endsAt,
|
|
127
|
+
createdAt: event.createdAt,
|
|
128
|
+
affectedMonitors: joinNames(event.monitors) || undefined,
|
|
129
|
+
labels: joinNames(event.labels) || undefined,
|
|
130
|
+
},
|
|
131
|
+
]
|
|
132
|
+
: [];
|
|
133
|
+
|
|
134
|
+
const serialized: SerializedResult =
|
|
135
|
+
ToolResultSerializer.serializeRows(rows);
|
|
136
|
+
|
|
137
|
+
return {
|
|
138
|
+
dataForLlm: serialized.text,
|
|
139
|
+
rowCount: serialized.rowCount,
|
|
140
|
+
citationLabel: `Scheduled maintenance ${
|
|
141
|
+
event?.scheduledMaintenanceNumber
|
|
142
|
+
? `#${event.scheduledMaintenanceNumber}`
|
|
143
|
+
: scheduledMaintenanceId.toString()
|
|
144
|
+
}`,
|
|
145
|
+
citationTarget: {
|
|
146
|
+
type: AIChatCitationTargetType.ScheduledMaintenanceView,
|
|
147
|
+
params: {
|
|
148
|
+
scheduledMaintenanceId: scheduledMaintenanceId.toString(),
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
redactionCount: serialized.redactionCount,
|
|
152
|
+
isTruncated: serialized.isTruncated,
|
|
153
|
+
widget:
|
|
154
|
+
rows.length > 0
|
|
155
|
+
? WidgetBuilder.table({
|
|
156
|
+
title:
|
|
157
|
+
`Scheduled maintenance #${event?.scheduledMaintenanceNumber ?? ""}`.trim(),
|
|
158
|
+
columns: [
|
|
159
|
+
{ key: "title", title: "Title", type: "text" },
|
|
160
|
+
{ key: "state", title: "State", type: "text" },
|
|
161
|
+
{ key: "startsAt", title: "Starts", type: "date" },
|
|
162
|
+
{ key: "endsAt", title: "Ends", type: "date" },
|
|
163
|
+
{
|
|
164
|
+
key: "affectedMonitors",
|
|
165
|
+
title: "Affected monitors",
|
|
166
|
+
type: "text",
|
|
167
|
+
},
|
|
168
|
+
],
|
|
169
|
+
rows: rows,
|
|
170
|
+
link: {
|
|
171
|
+
type: AIChatCitationTargetType.ScheduledMaintenanceView,
|
|
172
|
+
params: {
|
|
173
|
+
scheduledMaintenanceId: scheduledMaintenanceId.toString(),
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
})
|
|
177
|
+
: undefined,
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const pastDays: number = ToolArgs.getNumber(args, "pastDays", {
|
|
182
|
+
defaultValue: 30,
|
|
183
|
+
min: 0,
|
|
184
|
+
max: 365,
|
|
185
|
+
});
|
|
186
|
+
const upcomingDays: number = ToolArgs.getNumber(args, "upcomingDays", {
|
|
187
|
+
defaultValue: 30,
|
|
188
|
+
min: 0,
|
|
189
|
+
max: 365,
|
|
190
|
+
});
|
|
191
|
+
const limit: number = ToolArgs.getNumber(args, "limit", {
|
|
192
|
+
defaultValue: 10,
|
|
193
|
+
min: 1,
|
|
194
|
+
max: 25,
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
const now: Date = OneUptimeDate.getCurrentDate();
|
|
198
|
+
const windowStart: Date = OneUptimeDate.addRemoveDays(now, -1 * pastDays);
|
|
199
|
+
const windowEnd: Date = OneUptimeDate.addRemoveDays(now, upcomingDays);
|
|
200
|
+
|
|
201
|
+
// Overlap: the event's window intersects [windowStart, windowEnd].
|
|
202
|
+
const events: Array<ScheduledMaintenance> =
|
|
203
|
+
await ScheduledMaintenanceService.findBy({
|
|
204
|
+
query: {
|
|
205
|
+
startsAt: QueryHelper.lessThanEqualTo(windowEnd),
|
|
206
|
+
endsAt: QueryHelper.greaterThanEqualTo(windowStart),
|
|
207
|
+
},
|
|
208
|
+
select: {
|
|
209
|
+
_id: true,
|
|
210
|
+
title: true,
|
|
211
|
+
scheduledMaintenanceNumber: true,
|
|
212
|
+
startsAt: true,
|
|
213
|
+
endsAt: true,
|
|
214
|
+
currentScheduledMaintenanceState: {
|
|
215
|
+
name: true,
|
|
216
|
+
},
|
|
217
|
+
monitors: {
|
|
218
|
+
name: true,
|
|
219
|
+
},
|
|
220
|
+
},
|
|
221
|
+
sort: {
|
|
222
|
+
startsAt: SortOrder.Descending,
|
|
223
|
+
},
|
|
224
|
+
limit: limit,
|
|
225
|
+
skip: 0,
|
|
226
|
+
props: ctx.props,
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
const rows: Array<JSONObject> = events.map(
|
|
230
|
+
(event: ScheduledMaintenance) => {
|
|
231
|
+
return {
|
|
232
|
+
id: event.id?.toString(),
|
|
233
|
+
scheduledMaintenanceNumber: event.scheduledMaintenanceNumber,
|
|
234
|
+
title: event.title,
|
|
235
|
+
state: event.currentScheduledMaintenanceState?.name,
|
|
236
|
+
startsAt: event.startsAt,
|
|
237
|
+
endsAt: event.endsAt,
|
|
238
|
+
affectedMonitors: joinNames(event.monitors) || undefined,
|
|
239
|
+
};
|
|
240
|
+
},
|
|
241
|
+
);
|
|
242
|
+
|
|
243
|
+
const serialized: SerializedResult =
|
|
244
|
+
ToolResultSerializer.serializeRows(rows);
|
|
245
|
+
|
|
246
|
+
return {
|
|
247
|
+
dataForLlm: serialized.text,
|
|
248
|
+
rowCount: serialized.rowCount,
|
|
249
|
+
citationLabel: `Scheduled maintenance, -${pastDays}d/+${upcomingDays}d (${serialized.rowCount} found)`,
|
|
250
|
+
citationTarget: {
|
|
251
|
+
type: AIChatCitationTargetType.ScheduledMaintenanceEvents,
|
|
252
|
+
},
|
|
253
|
+
redactionCount: serialized.redactionCount,
|
|
254
|
+
isTruncated: serialized.isTruncated,
|
|
255
|
+
widget:
|
|
256
|
+
rows.length > 0
|
|
257
|
+
? WidgetBuilder.table({
|
|
258
|
+
title: `Scheduled maintenance (${rows.length})`,
|
|
259
|
+
description: `Windows overlapping the last ${pastDays}d and next ${upcomingDays}d`,
|
|
260
|
+
columns: [
|
|
261
|
+
{
|
|
262
|
+
key: "scheduledMaintenanceNumber",
|
|
263
|
+
title: "#",
|
|
264
|
+
type: "number",
|
|
265
|
+
},
|
|
266
|
+
{ key: "title", title: "Title", type: "text" },
|
|
267
|
+
{ key: "state", title: "State", type: "text" },
|
|
268
|
+
{ key: "startsAt", title: "Starts", type: "date" },
|
|
269
|
+
{ key: "endsAt", title: "Ends", type: "date" },
|
|
270
|
+
],
|
|
271
|
+
rows: rows,
|
|
272
|
+
link: {
|
|
273
|
+
type: AIChatCitationTargetType.ScheduledMaintenanceEvents,
|
|
274
|
+
},
|
|
275
|
+
})
|
|
276
|
+
: undefined,
|
|
277
|
+
};
|
|
278
|
+
},
|
|
279
|
+
};
|
|
@@ -520,7 +520,25 @@ export async function dropClickhousePartition(data: {
|
|
|
520
520
|
const cluster: string = escapeStringLiteral(getClickhouseClusterName());
|
|
521
521
|
const partitionId: string = escapeStringLiteral(data.partitionId);
|
|
522
522
|
|
|
523
|
+
/*
|
|
524
|
+
* max_partition_size_to_drop = 0 lifts the server's 50 GB drop guard
|
|
525
|
+
* (query-level since ClickHouse 23.12) for this statement only. That guard
|
|
526
|
+
* exists to stop a human fat-fingering a DROP: it cannot tell a wrong
|
|
527
|
+
* partition from a merely large one, and every partition reaching this call
|
|
528
|
+
* has already cleared the PRUNABLE_LOCAL_TABLES allowlist, the daily
|
|
529
|
+
* partition id check, newest-partition protection and a capacity plan that
|
|
530
|
+
* only selects partitions relieving a disk still over target. A single day
|
|
531
|
+
* of spans routinely exceeds 50 GB, so the guard rejects precisely the drops
|
|
532
|
+
* capacity pruning exists to perform. Setting it per statement rather than
|
|
533
|
+
* in config.xml keeps the guard in force for manual operator DDL, which is
|
|
534
|
+
* the fat-finger case it is actually for.
|
|
535
|
+
*
|
|
536
|
+
* Debugging note: ClickHouse strips this SETTINGS clause from the query text
|
|
537
|
+
* it stores in the distributed DDL queue and propagates the setting in the
|
|
538
|
+
* task's separate settings field, so system.distributed_ddl_queue shows the
|
|
539
|
+
* ALTER without it. The setting is still applied on every replica.
|
|
540
|
+
*/
|
|
523
541
|
await getClient().command({
|
|
524
|
-
query: `ALTER TABLE ${database}.${tableName} ON CLUSTER '${cluster}' DROP PARTITION ID '${partitionId}'`,
|
|
542
|
+
query: `ALTER TABLE ${database}.${tableName} ON CLUSTER '${cluster}' DROP PARTITION ID '${partitionId}' SETTINGS max_partition_size_to_drop = 0`,
|
|
525
543
|
});
|
|
526
544
|
}
|