@oneuptime/common 14.0.9 → 14.0.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/DatabaseModels/AutoRemediationSuggestion.ts +60 -0
- package/Models/DatabaseModels/CephCluster.ts +213 -0
- package/Models/DatabaseModels/DatabaseServer.ts +213 -0
- package/Models/DatabaseModels/DockerHost.ts +213 -0
- package/Models/DatabaseModels/DockerSwarmCluster.ts +213 -0
- package/Models/DatabaseModels/GlobalConfig.ts +1 -1
- package/Models/DatabaseModels/Host.ts +213 -0
- package/Models/DatabaseModels/Index.ts +2 -0
- package/Models/DatabaseModels/PodmanHost.ts +213 -0
- package/Models/DatabaseModels/ProxmoxCluster.ts +213 -0
- package/Models/DatabaseModels/ResourceAiAgent.ts +419 -0
- package/Models/DatabaseModels/RunnerJob.ts +144 -0
- package/Models/DatabaseModels/VMwareVCenter.ts +213 -0
- package/Server/API/AutoRemediationAPI.ts +392 -1
- package/Server/API/ResourceAiAccessAPI.ts +1669 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1796300000000-AddResourceAiAgents.ts +423 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +2 -0
- package/Server/Infrastructure/Semaphore.ts +22 -0
- package/Server/Middleware/TelemetryIngest.ts +15 -5
- package/Server/Services/AnalyticsDatabaseService.ts +45 -1
- package/Server/Services/AutoRemediationRuleEngineService.ts +940 -112
- package/Server/Services/CephClusterService.ts +109 -1
- package/Server/Services/DatabaseServerService.ts +116 -1
- package/Server/Services/DockerHostService.ts +109 -1
- package/Server/Services/DockerSwarmClusterService.ts +113 -1
- package/Server/Services/HostService.ts +126 -4
- package/Server/Services/MetricRecordingRuleService.ts +47 -0
- package/Server/Services/PodmanHostService.ts +109 -1
- package/Server/Services/ProxmoxClusterService.ts +110 -1
- package/Server/Services/ResourceAiAccessService.ts +1439 -0
- package/Server/Services/ResourceAiAgentJobService.ts +202 -0
- package/Server/Services/ResourceAiAgentService.ts +2432 -0
- package/Server/Services/RunnerJobService.ts +611 -4
- package/Server/Services/TelemetryUsageBillingService.ts +28 -0
- package/Server/Services/TraceRecordingRuleService.ts +33 -0
- package/Server/Services/VMwareVCenterService.ts +110 -1
- package/Server/Utils/AI/Remediation/RemediationCommandTools.ts +1434 -32
- package/Server/Utils/AI/Remediation/RemediationExecutionRunner.ts +935 -21
- package/Server/Utils/AI/Remediation/RemediationPlanRunner.ts +25 -1
- package/Server/Utils/AI/ResourceAccess/InfrastructureInvestigationToolkit.ts +577 -0
- package/Server/Utils/AI/ResourceAccess/ResourceAccessContext.ts +271 -0
- package/Server/Utils/AI/ResourceAccess/ResourceAccessToolNames.ts +45 -0
- package/Server/Utils/AI/ResourceAccess/ResourceAiAccessSettings.ts +964 -0
- package/Server/Utils/AI/ResourceAccess/ResourceAiDeleteCleanup.ts +333 -0
- package/Server/Utils/AI/ResourceAccess/ResourceCommandJobRunner.ts +873 -0
- package/Server/Utils/AI/SRE/AIInvestigationEngine.ts +72 -2
- package/Server/Utils/AI/SRE/AlertInvestigationRunner.ts +72 -5
- package/Server/Utils/AI/SRE/IncidentInvestigationRunner.ts +72 -5
- package/Server/Utils/AutoRemediation/CommandPlanExecutor.ts +396 -13
- package/Server/Utils/AutoRemediation/RemediationVerifier.ts +35 -2
- package/Server/Utils/Database/ProjectScopedReferenceValidator.ts +9 -1
- package/Server/Utils/SessionReplay/SessionReplayBudgetMetrics.ts +920 -0
- package/Server/Utils/SessionReplay/SessionReplayUsage.ts +84 -6
- package/Server/Utils/Workspace/MicrosoftTeams/Actions/Alert.ts +35 -15
- package/Server/Utils/Workspace/MicrosoftTeams/Actions/AlertEpisode.ts +33 -15
- package/Server/Utils/Workspace/MicrosoftTeams/Actions/Auth.ts +21 -1
- package/Server/Utils/Workspace/MicrosoftTeams/Actions/Incident.ts +298 -224
- package/Server/Utils/Workspace/MicrosoftTeams/Actions/IncidentEpisode.ts +35 -15
- package/Server/Utils/Workspace/MicrosoftTeams/Actions/ScheduledMaintenance.ts +389 -175
- package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.ts +366 -143
- package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsActivityDeduplicator.ts +163 -0
- package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsCardChoices.ts +396 -0
- package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsCreateCommands.ts +418 -0
- package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsMessageSize.ts +152 -0
- package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsReplies.ts +251 -0
- package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsTimezone.ts +214 -0
- package/Tests/App/Dashboard/ClusterAccessNotice.test.tsx +93 -0
- package/Tests/App/Dashboard/DatabaseDocumentationMarkdown.test.ts +18 -6
- package/Tests/App/Dashboard/InvestigationInfrastructureTools.test.tsx +506 -0
- package/Tests/App/Dashboard/RemediationSuggestionCardDescription.test.tsx +209 -0
- package/Tests/App/Dashboard/RemediationSuggestionCardResource.test.tsx +317 -0
- package/Tests/App/Dashboard/ResourceAiAccessSettingsUtil.test.ts +921 -0
- package/Tests/App/Dashboard/ResourceAiAgentInstall.test.ts +860 -0
- package/Tests/App/Dashboard/ResourceAiAgentPage.test.tsx +1721 -0
- package/Tests/App/Dashboard/ResourceAiAgentStatus.test.ts +1002 -0
- package/Tests/App/Dashboard/ResourceAiInsightsPage.test.tsx +931 -0
- package/Tests/App/Dashboard/ResourceAiNavigation.test.tsx +575 -0
- package/Tests/App/Dashboard/RunbookStepTypeMaps.test.ts +38 -7
- package/Tests/Models/DatabaseModels/DatabaseServerModels.test.ts +33 -1
- package/Tests/Models/DatabaseModels/ResourceAiAccessColumns.test.ts +738 -0
- package/Tests/Models/DatabaseModels/ResourceAiAgentModel.test.ts +842 -0
- package/Tests/Server/API/AutoRemediationApproveResourceRound.test.ts +835 -0
- package/Tests/Server/API/ResourceAiAccessAPI.test.ts +2730 -0
- package/Tests/Server/Infrastructure/Postgres/AddDatabaseServerTablesMigration.test.ts +60 -0
- package/Tests/Server/Infrastructure/Postgres/AddResourceAiAgentsMigration.test.ts +659 -0
- package/Tests/Server/Infrastructure/SemaphoreMutex.test.ts +31 -0
- package/Tests/Server/Middleware/TelemetryIngestBrowserKey.test.ts +63 -5
- package/Tests/Server/Middleware/TelemetryIngestKubernetesAgentRunnerPinnedKey.test.ts +103 -5
- package/Tests/Server/Middleware/TelemetryIngestKubernetesAgentRunnerRateLimit.test.ts +19 -1
- package/Tests/Server/Services/AutoRemediationResourceRuleEngine.test.ts +1279 -0
- package/Tests/Server/Services/DatabaseServerService.test.ts +55 -0
- package/Tests/Server/Services/GroupTelemetryUsageExcludeNames.test.ts +299 -0
- package/Tests/Server/Services/HostServiceFindOrCreateMemo.test.ts +44 -0
- package/Tests/Server/Services/MonitorProbeServiceIntervalScheduling.test.ts +45 -6
- package/Tests/Server/Services/RecordingRuleReservedMetricName.test.ts +171 -0
- package/Tests/Server/Services/ResourceAiAccessChangeAuthorization.test.ts +256 -0
- package/Tests/Server/Services/ResourceAiAccessService.test.ts +1373 -0
- package/Tests/Server/Services/ResourceAiAgentJobService.test.ts +375 -0
- package/Tests/Server/Services/ResourceAiAgentServiceHelpers.test.ts +1114 -0
- package/Tests/Server/Services/ResourceAiAgentServiceLifecycle.test.ts +1050 -0
- package/Tests/Server/Services/ResourceAiAgentServiceRegister.test.ts +2251 -0
- package/Tests/Server/Services/ResourceAiSettingsCreate.test.ts +373 -0
- package/Tests/Server/Services/ResourceAiSettingsPermission.test.ts +1042 -0
- package/Tests/Server/Services/ResourceServiceDeleteCleansUpAi.test.ts +319 -0
- package/Tests/Server/Services/RunnerJobEnqueueKubectl.test.ts +105 -0
- package/Tests/Server/Services/RunnerJobEnqueueResourceCommand.test.ts +986 -0
- package/Tests/Server/Services/RunnerJobResourceCommandLane.test.ts +211 -0
- package/Tests/Server/Services/RunnerJobResourceCommandTimeoutAndRedaction.test.ts +352 -0
- package/Tests/Server/Services/TelemetryUsageBillingSloExclusion.test.ts +218 -0
- package/Tests/Server/TestingUtils/Services/FakeRunnerJobCount.ts +145 -0
- package/Tests/Server/Utils/AI/InvestigationInfrastructureAccessWiring.test.ts +453 -0
- package/Tests/Server/Utils/AI/InvestigationInfrastructureReport.test.ts +721 -0
- package/Tests/Server/Utils/AI/RemediationCommandTools.test.ts +94 -1
- package/Tests/Server/Utils/AI/RemediationCommandToolsResource.test.ts +1530 -0
- package/Tests/Server/Utils/AI/RemediationExecutionRunnerResourceMode.test.ts +1249 -0
- package/Tests/Server/Utils/AI/RemediationPlanRunner.test.ts +117 -0
- package/Tests/Server/Utils/AI/RemediationResourceCopyParity.test.ts +463 -0
- package/Tests/Server/Utils/AI/ResourceAccess/InfrastructureInvestigationToolkit.test.ts +722 -0
- package/Tests/Server/Utils/AI/ResourceAccess/ResourceAccessContext.test.ts +266 -0
- package/Tests/Server/Utils/AI/ResourceAccess/ResourceAiAccessSettings.test.ts +1220 -0
- package/Tests/Server/Utils/AI/ResourceAccess/ResourceAiDeleteCleanup.test.ts +569 -0
- package/Tests/Server/Utils/AI/ResourceAccess/ResourceCommandJobRunner.test.ts +830 -0
- package/Tests/Server/Utils/AutoRemediation/CommandPlanExecutorResource.test.ts +717 -0
- package/Tests/Server/Utils/AutoRemediation/RemediationVerifierResourceFollowUp.test.ts +338 -0
- package/Tests/Server/Utils/Monitor/Criteria/SessionReplayBudgetTemplateCriteria.test.ts +422 -0
- package/Tests/Server/Utils/SessionReplay/SessionReplayBudgetMetrics.test.ts +1647 -0
- package/Tests/Server/Utils/SessionReplay/SessionReplayUsage.test.ts +143 -1
- package/Tests/Server/Utils/Telemetry/TelemetryIngestionKeyGuard.test.ts +33 -3
- package/Tests/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsAccountNotLinked.test.ts +1093 -0
- package/Tests/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsActivityDeduplicator.test.ts +1049 -0
- package/Tests/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsCardChoices.test.ts +1676 -0
- package/Tests/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsCreateCards.test.ts +2884 -0
- package/Tests/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsCreateCommands.test.ts +2490 -0
- package/Tests/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsCreateSubmit.test.ts +2293 -0
- package/Tests/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsCreateSubmitServerTimezone.test.ts +386 -0
- package/Tests/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsMessageSize.test.ts +1477 -0
- package/Tests/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsReplies.test.ts +1967 -0
- package/Tests/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsStripHtmlTags.test.ts +92 -0
- package/Tests/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsSubmittedFormRemoval.test.ts +1819 -0
- package/Tests/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsTimezone.test.ts +1033 -0
- package/Tests/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsTimezoneServerZone.test.ts +610 -0
- package/Tests/Server/Utils/Workspace/MicrosoftTeamsBotMessageHandling.test.ts +2610 -0
- package/Tests/Server/Utils/Workspace/MicrosoftTeamsCreateCommandsEndToEnd.test.ts +4672 -0
- package/Tests/Server/Utils/Workspace/WorkspaceCreateProjectReferences.test.ts +190 -65
- package/Tests/Types/AutoRemediation/AiRemediationCommandPlan.test.ts +10 -4
- package/Tests/Types/AutoRemediation/AiRemediationCommandPlanResourceCommand.test.ts +305 -0
- package/Tests/Types/Monitor/Recommendation/MonitorRecommendationCatalog.test.ts +277 -13
- package/Tests/Types/Monitor/Recommendation/MonitorRecommendationUtil.test.ts +113 -0
- package/Tests/Types/Monitor/RumAlertTemplates.test.ts +773 -2
- package/Tests/Types/ResourceAiAgent/AiResourceType.test.ts +419 -0
- package/Tests/Types/ResourceAiAgent/ResourceAiAccess.test.ts +517 -0
- package/Tests/Types/Runbook/RunbookStepType.test.ts +147 -8
- package/Tests/UI/Rum/RecordingHealthDashboard.test.tsx +769 -1
- package/Tests/Utils/AiRemediation/Resource/CephCommandPolicy.test.ts +1653 -0
- package/Tests/Utils/AiRemediation/Resource/CephOutputRedaction.test.ts +204 -0
- package/Tests/Utils/AiRemediation/Resource/DatabaseCommandPolicy.test.ts +1077 -0
- package/Tests/Utils/AiRemediation/Resource/DatabaseDiagnosticCatalog.test.ts +558 -0
- package/Tests/Utils/AiRemediation/Resource/DatabaseQueryRedactor.test.ts +834 -0
- package/Tests/Utils/AiRemediation/Resource/DockerCliGrammar.test.ts +747 -0
- package/Tests/Utils/AiRemediation/Resource/DockerEngineCommandPolicy.test.ts +1259 -0
- package/Tests/Utils/AiRemediation/Resource/DockerOutputRedaction.test.ts +386 -0
- package/Tests/Utils/AiRemediation/Resource/DockerSwarmCommandPolicy.test.ts +782 -0
- package/Tests/Utils/AiRemediation/Resource/GovcCommandPolicy.test.ts +2259 -0
- package/Tests/Utils/AiRemediation/Resource/HostCommandPolicy.test.ts +2019 -0
- package/Tests/Utils/AiRemediation/Resource/ProxmoxCommandPolicy.test.ts +2497 -0
- package/Tests/Utils/AiRemediation/Resource/ResourceCommandPolicy.test.ts +1305 -0
- package/Tests/Utils/AiRemediation/Resource/ResourceCommandPolicyCore.test.ts +585 -0
- package/Tests/Utils/AiRemediation/Resource/ResourceOutputRedactor.test.ts +334 -0
- package/Tests/Utils/AiRemediation/Resource/ResourceOutputRedactorCopyParity.test.ts +98 -0
- package/Tests/Utils/AiRemediation/Resource/ResourcePolicyImportClosure.test.ts +391 -0
- package/Tests/Utils/AiRemediation/ResourceAiAgentPolicyCopyParity.test.ts +497 -0
- package/Tests/Utils/SessionReplay/SessionReplayBudgetMetricType.test.ts +383 -0
- package/Types/AI/ResourceAiAccessApi.ts +140 -0
- package/Types/AI/ResourceAiAccessPermissions.ts +126 -0
- package/Types/AutoRemediation/AiRemediationCommandPlan.ts +183 -2
- package/Types/Monitor/Recommendation/MonitorRecommendationCatalog.ts +55 -22
- package/Types/Monitor/Recommendation/MonitorRecommendationTypes.ts +35 -3
- package/Types/Monitor/RumAlertTemplates.ts +351 -4
- package/Types/ResourceAiAgent/AiResourceType.ts +310 -0
- package/Types/ResourceAiAgent/ResourceAiAccess.ts +574 -0
- package/Types/Rum/SessionReplayBudgetMetricType.ts +47 -0
- package/Types/Runbook/RunbookStepType.ts +29 -0
- package/Types/Telemetry/TelemetryIngestSurface.ts +14 -2
- package/Utils/AI/InvestigationReport.ts +121 -15
- package/Utils/AiRemediation/Resource/CephCommandPolicy.ts +1936 -0
- package/Utils/AiRemediation/Resource/DatabaseCommandPolicy.ts +166 -0
- package/Utils/AiRemediation/Resource/DatabaseDiagnosticCatalog.ts +1532 -0
- package/Utils/AiRemediation/Resource/DatabaseQueryRedactor.ts +1394 -0
- package/Utils/AiRemediation/Resource/DockerCliGrammar.ts +1839 -0
- package/Utils/AiRemediation/Resource/DockerEngineCommandPolicy.ts +490 -0
- package/Utils/AiRemediation/Resource/DockerSwarmCommandPolicy.ts +687 -0
- package/Utils/AiRemediation/Resource/GovcCommandPolicy.ts +2096 -0
- package/Utils/AiRemediation/Resource/HostCommandPolicy.ts +2982 -0
- package/Utils/AiRemediation/Resource/ProxmoxCommandPolicy.ts +1679 -0
- package/Utils/AiRemediation/Resource/ResourceCommandPolicy.ts +851 -0
- package/Utils/AiRemediation/Resource/ResourceCommandPolicyCore.ts +593 -0
- package/Utils/AiRemediation/Resource/ResourceOutputRedactor.ts +2812 -0
- package/Utils/SessionReplay/SessionReplayBudgetMetricType.ts +184 -0
- package/build/dist/Models/DatabaseModels/AutoRemediationSuggestion.js +62 -0
- package/build/dist/Models/DatabaseModels/AutoRemediationSuggestion.js.map +1 -1
- package/build/dist/Models/DatabaseModels/CephCluster.js +219 -0
- package/build/dist/Models/DatabaseModels/CephCluster.js.map +1 -1
- package/build/dist/Models/DatabaseModels/DatabaseServer.js +219 -0
- package/build/dist/Models/DatabaseModels/DatabaseServer.js.map +1 -1
- package/build/dist/Models/DatabaseModels/DockerHost.js +219 -0
- package/build/dist/Models/DatabaseModels/DockerHost.js.map +1 -1
- package/build/dist/Models/DatabaseModels/DockerSwarmCluster.js +219 -0
- package/build/dist/Models/DatabaseModels/DockerSwarmCluster.js.map +1 -1
- package/build/dist/Models/DatabaseModels/GlobalConfig.js +1 -1
- package/build/dist/Models/DatabaseModels/GlobalConfig.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Host.js +219 -0
- package/build/dist/Models/DatabaseModels/Host.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/PodmanHost.js +219 -0
- package/build/dist/Models/DatabaseModels/PodmanHost.js.map +1 -1
- package/build/dist/Models/DatabaseModels/ProxmoxCluster.js +219 -0
- package/build/dist/Models/DatabaseModels/ProxmoxCluster.js.map +1 -1
- package/build/dist/Models/DatabaseModels/ResourceAiAgent.js +439 -0
- package/build/dist/Models/DatabaseModels/ResourceAiAgent.js.map +1 -0
- package/build/dist/Models/DatabaseModels/RunnerJob.js +145 -0
- package/build/dist/Models/DatabaseModels/RunnerJob.js.map +1 -1
- package/build/dist/Models/DatabaseModels/VMwareVCenter.js +219 -0
- package/build/dist/Models/DatabaseModels/VMwareVCenter.js.map +1 -1
- package/build/dist/Server/API/AutoRemediationAPI.js +231 -1
- package/build/dist/Server/API/AutoRemediationAPI.js.map +1 -1
- package/build/dist/Server/API/ResourceAiAccessAPI.js +1119 -0
- package/build/dist/Server/API/ResourceAiAccessAPI.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1796300000000-AddResourceAiAgents.js +168 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1796300000000-AddResourceAiAgents.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +2 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
- package/build/dist/Server/Infrastructure/Semaphore.js +6 -0
- package/build/dist/Server/Infrastructure/Semaphore.js.map +1 -1
- package/build/dist/Server/Middleware/TelemetryIngest.js +12 -5
- package/build/dist/Server/Middleware/TelemetryIngest.js.map +1 -1
- package/build/dist/Server/Services/AnalyticsDatabaseService.js +26 -1
- package/build/dist/Server/Services/AnalyticsDatabaseService.js.map +1 -1
- package/build/dist/Server/Services/AutoRemediationRuleEngineService.js +601 -3
- package/build/dist/Server/Services/AutoRemediationRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/CephClusterService.js +104 -0
- package/build/dist/Server/Services/CephClusterService.js.map +1 -1
- package/build/dist/Server/Services/DatabaseServerService.js +99 -0
- package/build/dist/Server/Services/DatabaseServerService.js.map +1 -1
- package/build/dist/Server/Services/DockerHostService.js +104 -0
- package/build/dist/Server/Services/DockerHostService.js.map +1 -1
- package/build/dist/Server/Services/DockerSwarmClusterService.js +104 -0
- package/build/dist/Server/Services/DockerSwarmClusterService.js.map +1 -1
- package/build/dist/Server/Services/HostService.js +114 -2
- package/build/dist/Server/Services/HostService.js.map +1 -1
- package/build/dist/Server/Services/MetricRecordingRuleService.js +46 -0
- package/build/dist/Server/Services/MetricRecordingRuleService.js.map +1 -1
- package/build/dist/Server/Services/PodmanHostService.js +104 -0
- package/build/dist/Server/Services/PodmanHostService.js.map +1 -1
- package/build/dist/Server/Services/ProxmoxClusterService.js +104 -0
- package/build/dist/Server/Services/ProxmoxClusterService.js.map +1 -1
- package/build/dist/Server/Services/ResourceAiAccessService.js +1028 -0
- package/build/dist/Server/Services/ResourceAiAccessService.js.map +1 -0
- package/build/dist/Server/Services/ResourceAiAgentJobService.js +173 -0
- package/build/dist/Server/Services/ResourceAiAgentJobService.js.map +1 -0
- package/build/dist/Server/Services/ResourceAiAgentService.js +1687 -0
- package/build/dist/Server/Services/ResourceAiAgentService.js.map +1 -0
- package/build/dist/Server/Services/RunnerJobService.js +344 -5
- package/build/dist/Server/Services/RunnerJobService.js.map +1 -1
- package/build/dist/Server/Services/TelemetryUsageBillingService.js +26 -0
- package/build/dist/Server/Services/TelemetryUsageBillingService.js.map +1 -1
- package/build/dist/Server/Services/TraceRecordingRuleService.js +37 -0
- package/build/dist/Server/Services/TraceRecordingRuleService.js.map +1 -1
- package/build/dist/Server/Services/VMwareVCenterService.js +104 -0
- package/build/dist/Server/Services/VMwareVCenterService.js.map +1 -1
- package/build/dist/Server/Utils/AI/Remediation/RemediationCommandTools.js +1029 -30
- package/build/dist/Server/Utils/AI/Remediation/RemediationCommandTools.js.map +1 -1
- package/build/dist/Server/Utils/AI/Remediation/RemediationExecutionRunner.js +633 -28
- package/build/dist/Server/Utils/AI/Remediation/RemediationExecutionRunner.js.map +1 -1
- package/build/dist/Server/Utils/AI/Remediation/RemediationPlanRunner.js +21 -1
- package/build/dist/Server/Utils/AI/Remediation/RemediationPlanRunner.js.map +1 -1
- package/build/dist/Server/Utils/AI/ResourceAccess/InfrastructureInvestigationToolkit.js +330 -0
- package/build/dist/Server/Utils/AI/ResourceAccess/InfrastructureInvestigationToolkit.js.map +1 -0
- package/build/dist/Server/Utils/AI/ResourceAccess/ResourceAccessContext.js +160 -0
- package/build/dist/Server/Utils/AI/ResourceAccess/ResourceAccessContext.js.map +1 -0
- package/build/dist/Server/Utils/AI/ResourceAccess/ResourceAccessToolNames.js +33 -0
- package/build/dist/Server/Utils/AI/ResourceAccess/ResourceAccessToolNames.js.map +1 -0
- package/build/dist/Server/Utils/AI/ResourceAccess/ResourceAiAccessSettings.js +640 -0
- package/build/dist/Server/Utils/AI/ResourceAccess/ResourceAiAccessSettings.js.map +1 -0
- package/build/dist/Server/Utils/AI/ResourceAccess/ResourceAiDeleteCleanup.js +226 -0
- package/build/dist/Server/Utils/AI/ResourceAccess/ResourceAiDeleteCleanup.js.map +1 -0
- package/build/dist/Server/Utils/AI/ResourceAccess/ResourceCommandJobRunner.js +600 -0
- package/build/dist/Server/Utils/AI/ResourceAccess/ResourceCommandJobRunner.js.map +1 -0
- package/build/dist/Server/Utils/AI/SRE/AIInvestigationEngine.js +50 -4
- package/build/dist/Server/Utils/AI/SRE/AIInvestigationEngine.js.map +1 -1
- package/build/dist/Server/Utils/AI/SRE/AlertInvestigationRunner.js +55 -4
- package/build/dist/Server/Utils/AI/SRE/AlertInvestigationRunner.js.map +1 -1
- package/build/dist/Server/Utils/AI/SRE/IncidentInvestigationRunner.js +55 -4
- package/build/dist/Server/Utils/AI/SRE/IncidentInvestigationRunner.js.map +1 -1
- package/build/dist/Server/Utils/AutoRemediation/CommandPlanExecutor.js +290 -13
- package/build/dist/Server/Utils/AutoRemediation/CommandPlanExecutor.js.map +1 -1
- package/build/dist/Server/Utils/AutoRemediation/RemediationVerifier.js +29 -1
- package/build/dist/Server/Utils/AutoRemediation/RemediationVerifier.js.map +1 -1
- package/build/dist/Server/Utils/Database/ProjectScopedReferenceValidator.js +9 -1
- package/build/dist/Server/Utils/Database/ProjectScopedReferenceValidator.js.map +1 -1
- package/build/dist/Server/Utils/SessionReplay/SessionReplayBudgetMetrics.js +627 -0
- package/build/dist/Server/Utils/SessionReplay/SessionReplayBudgetMetrics.js.map +1 -0
- package/build/dist/Server/Utils/SessionReplay/SessionReplayUsage.js +60 -5
- package/build/dist/Server/Utils/SessionReplay/SessionReplayUsage.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Alert.js +19 -15
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Alert.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/AlertEpisode.js +19 -15
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/AlertEpisode.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Auth.js +17 -1
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Auth.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Incident.js +183 -209
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Incident.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/IncidentEpisode.js +19 -15
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/IncidentEpisode.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/ScheduledMaintenance.js +233 -167
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/ScheduledMaintenance.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js +263 -110
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsActivityDeduplicator.js +129 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsActivityDeduplicator.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsCardChoices.js +266 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsCardChoices.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsCreateCommands.js +258 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsCreateCommands.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsMessageSize.js +104 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsMessageSize.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsReplies.js +183 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsReplies.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsTimezone.js +123 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeamsTimezone.js.map +1 -0
- package/build/dist/Types/AI/ResourceAiAccessApi.js +30 -0
- package/build/dist/Types/AI/ResourceAiAccessApi.js.map +1 -0
- package/build/dist/Types/AI/ResourceAiAccessPermissions.js +98 -0
- package/build/dist/Types/AI/ResourceAiAccessPermissions.js.map +1 -0
- package/build/dist/Types/AutoRemediation/AiRemediationCommandPlan.js +116 -29
- package/build/dist/Types/AutoRemediation/AiRemediationCommandPlan.js.map +1 -1
- package/build/dist/Types/Monitor/Recommendation/MonitorRecommendationCatalog.js +47 -21
- package/build/dist/Types/Monitor/Recommendation/MonitorRecommendationCatalog.js.map +1 -1
- package/build/dist/Types/Monitor/Recommendation/MonitorRecommendationTypes.js +5 -0
- package/build/dist/Types/Monitor/Recommendation/MonitorRecommendationTypes.js.map +1 -1
- package/build/dist/Types/Monitor/RumAlertTemplates.js +199 -3
- package/build/dist/Types/Monitor/RumAlertTemplates.js.map +1 -1
- package/build/dist/Types/ResourceAiAgent/AiResourceType.js +242 -0
- package/build/dist/Types/ResourceAiAgent/AiResourceType.js.map +1 -0
- package/build/dist/Types/ResourceAiAgent/ResourceAiAccess.js +275 -0
- package/build/dist/Types/ResourceAiAgent/ResourceAiAccess.js.map +1 -0
- package/build/dist/Types/Rum/SessionReplayBudgetMetricType.js +45 -0
- package/build/dist/Types/Rum/SessionReplayBudgetMetricType.js.map +1 -0
- package/build/dist/Types/Runbook/RunbookStepType.js +27 -0
- package/build/dist/Types/Runbook/RunbookStepType.js.map +1 -1
- package/build/dist/Types/Telemetry/TelemetryIngestSurface.js +13 -2
- package/build/dist/Types/Telemetry/TelemetryIngestSurface.js.map +1 -1
- package/build/dist/Utils/AI/InvestigationReport.js +71 -11
- package/build/dist/Utils/AI/InvestigationReport.js.map +1 -1
- package/build/dist/Utils/AiRemediation/Resource/CephCommandPolicy.js +1462 -0
- package/build/dist/Utils/AiRemediation/Resource/CephCommandPolicy.js.map +1 -0
- package/build/dist/Utils/AiRemediation/Resource/DatabaseCommandPolicy.js +122 -0
- package/build/dist/Utils/AiRemediation/Resource/DatabaseCommandPolicy.js.map +1 -0
- package/build/dist/Utils/AiRemediation/Resource/DatabaseDiagnosticCatalog.js +1139 -0
- package/build/dist/Utils/AiRemediation/Resource/DatabaseDiagnosticCatalog.js.map +1 -0
- package/build/dist/Utils/AiRemediation/Resource/DatabaseQueryRedactor.js +1060 -0
- package/build/dist/Utils/AiRemediation/Resource/DatabaseQueryRedactor.js.map +1 -0
- package/build/dist/Utils/AiRemediation/Resource/DockerCliGrammar.js +1301 -0
- package/build/dist/Utils/AiRemediation/Resource/DockerCliGrammar.js.map +1 -0
- package/build/dist/Utils/AiRemediation/Resource/DockerEngineCommandPolicy.js +370 -0
- package/build/dist/Utils/AiRemediation/Resource/DockerEngineCommandPolicy.js.map +1 -0
- package/build/dist/Utils/AiRemediation/Resource/DockerSwarmCommandPolicy.js +498 -0
- package/build/dist/Utils/AiRemediation/Resource/DockerSwarmCommandPolicy.js.map +1 -0
- package/build/dist/Utils/AiRemediation/Resource/GovcCommandPolicy.js +1565 -0
- package/build/dist/Utils/AiRemediation/Resource/GovcCommandPolicy.js.map +1 -0
- package/build/dist/Utils/AiRemediation/Resource/HostCommandPolicy.js +2206 -0
- package/build/dist/Utils/AiRemediation/Resource/HostCommandPolicy.js.map +1 -0
- package/build/dist/Utils/AiRemediation/Resource/ProxmoxCommandPolicy.js +1129 -0
- package/build/dist/Utils/AiRemediation/Resource/ProxmoxCommandPolicy.js.map +1 -0
- package/build/dist/Utils/AiRemediation/Resource/ResourceCommandPolicy.js +565 -0
- package/build/dist/Utils/AiRemediation/Resource/ResourceCommandPolicy.js.map +1 -0
- package/build/dist/Utils/AiRemediation/Resource/ResourceCommandPolicyCore.js +408 -0
- package/build/dist/Utils/AiRemediation/Resource/ResourceCommandPolicyCore.js.map +1 -0
- package/build/dist/Utils/AiRemediation/Resource/ResourceOutputRedactor.js +1910 -0
- package/build/dist/Utils/AiRemediation/Resource/ResourceOutputRedactor.js.map +1 -0
- package/build/dist/Utils/SessionReplay/SessionReplayBudgetMetricType.js +160 -0
- package/build/dist/Utils/SessionReplay/SessionReplayBudgetMetricType.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,593 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The tool-agnostic half of the resource command policy: the tokenizer,
|
|
3
|
+
* the result shape every tool policy returns, display rendering, glob and
|
|
4
|
+
* allowlist matching, and the auto-execution ladder.
|
|
5
|
+
*
|
|
6
|
+
* Every command OneUptime AI composes for an infrastructure resource is an
|
|
7
|
+
* argv — never a shell line. The agent spawns argv[0] with argv[1..] and no
|
|
8
|
+
* shell, so shell syntax could never do what the model meant by it; it is
|
|
9
|
+
* refused here with a message that says so, rather than being passed to the
|
|
10
|
+
* program as literal words it would misread.
|
|
11
|
+
*
|
|
12
|
+
* Pure and import-closed on purpose: this directory (with
|
|
13
|
+
* Types/ResourceAiAgent and Types/AutoRemediation/
|
|
14
|
+
* AiRemediationCommandPolicyVerdict) is copied byte-identically into the
|
|
15
|
+
* resource AI agent (agents/ResourceAIAgent), which enforces the same policy
|
|
16
|
+
* before it spawns anything. It may import only those files, by relative
|
|
17
|
+
* path, and nothing from Node.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import {
|
|
21
|
+
AiRemediationCommandPolicyVerdict,
|
|
22
|
+
MAX_COMMAND_LENGTH_CHARS,
|
|
23
|
+
} from "../../../Types/AutoRemediation/AiRemediationCommandPolicyVerdict";
|
|
24
|
+
import { ResourceCommandTier } from "../../../Types/ResourceAiAgent/ResourceAiAccess";
|
|
25
|
+
|
|
26
|
+
// The most words (program included) one command may have.
|
|
27
|
+
export const MAX_RESOURCE_COMMAND_TOKENS: number = 64;
|
|
28
|
+
|
|
29
|
+
export interface ResourceTokenizeResult {
|
|
30
|
+
// The words, the program included as argv[0]; set when the command parsed.
|
|
31
|
+
argv?: Array<string> | undefined;
|
|
32
|
+
// Why the command could not be read as one argv; set when it did not.
|
|
33
|
+
errorMessage?: string | undefined;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/*
|
|
37
|
+
* The one-line phrase every shell-syntax refusal carries, so the model (and
|
|
38
|
+
* a person reading an approval card) learns the rule, not just the symptom.
|
|
39
|
+
*/
|
|
40
|
+
export const RESOURCE_SHELL_SYNTAX_RULE: string =
|
|
41
|
+
"pipes and redirects are not supported; run one command";
|
|
42
|
+
|
|
43
|
+
/*
|
|
44
|
+
* Words a model writes out of shell habit that would change who runs the
|
|
45
|
+
* command. The agent runs everything with its own permissions only.
|
|
46
|
+
*/
|
|
47
|
+
const PRIVILEGE_ESCALATION_PROGRAMS: ReadonlyArray<string> = [
|
|
48
|
+
"sudo",
|
|
49
|
+
"doas",
|
|
50
|
+
"su",
|
|
51
|
+
"pkexec",
|
|
52
|
+
];
|
|
53
|
+
|
|
54
|
+
function describeShellSyntax(character: string): string {
|
|
55
|
+
switch (character) {
|
|
56
|
+
case "|":
|
|
57
|
+
return "a pipe (|)";
|
|
58
|
+
case ";":
|
|
59
|
+
return "a command separator (;)";
|
|
60
|
+
case "&":
|
|
61
|
+
return "a background or chaining operator (&)";
|
|
62
|
+
case ">":
|
|
63
|
+
return "an output redirect (>)";
|
|
64
|
+
case "<":
|
|
65
|
+
return "an input redirect (<)";
|
|
66
|
+
case "`":
|
|
67
|
+
return "command substitution (`...`)";
|
|
68
|
+
default:
|
|
69
|
+
return "command substitution ($(...))";
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function shellSyntaxError(character: string, quoted: boolean): string {
|
|
74
|
+
return `The command contains ${describeShellSyntax(character)}${
|
|
75
|
+
quoted ? " inside double quotes" : ""
|
|
76
|
+
}: ${RESOURCE_SHELL_SYNTAX_RULE}. Commands never run through a shell, so chaining, redirection and substitution are unavailable${
|
|
77
|
+
quoted
|
|
78
|
+
? ""
|
|
79
|
+
: " — quote the character (or put a backslash before it) if it is part of an argument"
|
|
80
|
+
}.`;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/*
|
|
84
|
+
* Split a command line into an argv the way a POSIX shell would split it
|
|
85
|
+
* for quoting purposes ONLY: single quotes, double quotes and backslash
|
|
86
|
+
* escapes. Nothing is expanded.
|
|
87
|
+
*
|
|
88
|
+
* Refused, because a shell would have given them a meaning the agent never
|
|
89
|
+
* will: an unquoted | ; & > < or backtick, an unquoted "$(", and — since a
|
|
90
|
+
* shell expands them even there — a backtick or "$(" inside double quotes.
|
|
91
|
+
* Inside single quotes (or after a backslash) every character is literal.
|
|
92
|
+
* The command must fit on one line (no newline, carriage return or NUL
|
|
93
|
+
* anywhere), be at most MAX_COMMAND_LENGTH_CHARS long and have at most
|
|
94
|
+
* MAX_RESOURCE_COMMAND_TOKENS words. A leading sudo (or doas, su, pkexec) is
|
|
95
|
+
* refused outright rather than stripped: the agent never runs anything with
|
|
96
|
+
* more than its own permissions.
|
|
97
|
+
*/
|
|
98
|
+
export function tokenizeResourceCommand(
|
|
99
|
+
command: string,
|
|
100
|
+
): ResourceTokenizeResult {
|
|
101
|
+
const text: string = typeof command === "string" ? command.trim() : "";
|
|
102
|
+
|
|
103
|
+
if (!text) {
|
|
104
|
+
return { errorMessage: "Empty command." };
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (text.length > MAX_COMMAND_LENGTH_CHARS) {
|
|
108
|
+
return {
|
|
109
|
+
errorMessage: `Command exceeds the ${MAX_COMMAND_LENGTH_CHARS}-character limit.`,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (text.includes("\n") || text.includes("\r") || text.includes("\0")) {
|
|
114
|
+
return {
|
|
115
|
+
errorMessage: `A command must be a single line: ${RESOURCE_SHELL_SYNTAX_RULE}.`,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const argv: Array<string> = [];
|
|
120
|
+
let current: string = "";
|
|
121
|
+
let inSingle: boolean = false;
|
|
122
|
+
let inDouble: boolean = false;
|
|
123
|
+
let hasToken: boolean = false;
|
|
124
|
+
|
|
125
|
+
for (let i: number = 0; i < text.length; i++) {
|
|
126
|
+
const ch: string = text.charAt(i);
|
|
127
|
+
const next: string = i + 1 < text.length ? text.charAt(i + 1) : "";
|
|
128
|
+
|
|
129
|
+
if (inSingle) {
|
|
130
|
+
if (ch === "'") {
|
|
131
|
+
inSingle = false;
|
|
132
|
+
} else {
|
|
133
|
+
current += ch;
|
|
134
|
+
}
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (inDouble) {
|
|
139
|
+
if (ch === '"') {
|
|
140
|
+
inDouble = false;
|
|
141
|
+
} else if (ch === "\\" && next !== "") {
|
|
142
|
+
// POSIX: inside double quotes a backslash escapes only these.
|
|
143
|
+
if (next === '"' || next === "\\" || next === "$" || next === "`") {
|
|
144
|
+
current += next;
|
|
145
|
+
i++;
|
|
146
|
+
} else {
|
|
147
|
+
current += ch;
|
|
148
|
+
}
|
|
149
|
+
} else if (ch === "`") {
|
|
150
|
+
return { errorMessage: shellSyntaxError("`", true) };
|
|
151
|
+
} else if (ch === "$" && next === "(") {
|
|
152
|
+
return { errorMessage: shellSyntaxError("$(", true) };
|
|
153
|
+
} else {
|
|
154
|
+
current += ch;
|
|
155
|
+
}
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (ch === "'") {
|
|
160
|
+
inSingle = true;
|
|
161
|
+
hasToken = true;
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (ch === '"') {
|
|
166
|
+
inDouble = true;
|
|
167
|
+
hasToken = true;
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (ch === "\\" && next !== "") {
|
|
172
|
+
current += next;
|
|
173
|
+
hasToken = true;
|
|
174
|
+
i++;
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (ch === " " || ch === "\t") {
|
|
179
|
+
if (hasToken) {
|
|
180
|
+
argv.push(current);
|
|
181
|
+
current = "";
|
|
182
|
+
hasToken = false;
|
|
183
|
+
}
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (
|
|
188
|
+
ch === "|" ||
|
|
189
|
+
ch === ";" ||
|
|
190
|
+
ch === "&" ||
|
|
191
|
+
ch === ">" ||
|
|
192
|
+
ch === "<" ||
|
|
193
|
+
ch === "`"
|
|
194
|
+
) {
|
|
195
|
+
return { errorMessage: shellSyntaxError(ch, false) };
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if (ch === "$" && next === "(") {
|
|
199
|
+
return { errorMessage: shellSyntaxError("$(", false) };
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
current += ch;
|
|
203
|
+
hasToken = true;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
if (inSingle || inDouble) {
|
|
207
|
+
return { errorMessage: "Unbalanced quotes in the command." };
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (hasToken) {
|
|
211
|
+
argv.push(current);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
if (argv.length === 0) {
|
|
215
|
+
return { errorMessage: "Empty command." };
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
if (argv.length > MAX_RESOURCE_COMMAND_TOKENS) {
|
|
219
|
+
return {
|
|
220
|
+
errorMessage: `A command may have at most ${MAX_RESOURCE_COMMAND_TOKENS} words.`,
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
const privilegeRefusal: string | null = getPrivilegeEscalationRefusal(
|
|
225
|
+
argv[0] || "",
|
|
226
|
+
);
|
|
227
|
+
|
|
228
|
+
if (privilegeRefusal) {
|
|
229
|
+
return { errorMessage: privilegeRefusal };
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
return { argv };
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/*
|
|
236
|
+
* Why argv[0] asks for more privilege than the agent has, or null. Shared by
|
|
237
|
+
* the tokenizer and the dispatcher so a string and an argv are refused with
|
|
238
|
+
* the same words.
|
|
239
|
+
*/
|
|
240
|
+
export function getPrivilegeEscalationRefusal(program: string): string | null {
|
|
241
|
+
const folded: string = program.trim().toLowerCase();
|
|
242
|
+
const base: string = folded.slice(folded.lastIndexOf("/") + 1);
|
|
243
|
+
|
|
244
|
+
if (!PRIVILEGE_ESCALATION_PROGRAMS.includes(base)) {
|
|
245
|
+
return null;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
return `"${program}" is not supported: the AI agent runs every command with its own permissions only, so drop ${base} and run the command itself.`;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/*
|
|
252
|
+
* What a tool policy says about one command. Every caller — the server
|
|
253
|
+
* tools, the enqueue chokepoint and the agent — acts on this and nothing
|
|
254
|
+
* else.
|
|
255
|
+
*/
|
|
256
|
+
export interface ResourceCommandPolicyResult {
|
|
257
|
+
tier: ResourceCommandTier;
|
|
258
|
+
// Why this tier; shown to the model and on approval cards.
|
|
259
|
+
reason: string;
|
|
260
|
+
// argv[0]: "docker", "pvesh", "govc", "ceph", "db", "systemctl", ...
|
|
261
|
+
program: string;
|
|
262
|
+
// argv WITHOUT the program, as the tool policy normalized it.
|
|
263
|
+
args: Array<string>;
|
|
264
|
+
/*
|
|
265
|
+
* An audit label for what the command does: "ps", "restart",
|
|
266
|
+
* "service update", "get", "vm.power", "osd out", "cancel_query".
|
|
267
|
+
*/
|
|
268
|
+
verb: string;
|
|
269
|
+
// The command rendered for humans; round-trips through tokenizeResourceCommand.
|
|
270
|
+
displayCommand: string;
|
|
271
|
+
/*
|
|
272
|
+
* The named objects a WRITE touches, in the canonical form the agent's
|
|
273
|
+
* protectedTargets and ONEUPTIME_AI_WRITE_TARGETS globs are compared with
|
|
274
|
+
* (container names/ids, service names, "node/vmid", VM paths, osd ids,
|
|
275
|
+
* pids, full unit names). [] for reads, and for a write that names no
|
|
276
|
+
* object (a cluster-wide flag).
|
|
277
|
+
*/
|
|
278
|
+
targets: Array<string>;
|
|
279
|
+
/*
|
|
280
|
+
* A write nothing an operator configures may run unattended — a node
|
|
281
|
+
* drain, host maintenance, killing a pid. Always asks a human, in every
|
|
282
|
+
* mode, Bypass approval and the allowlist included.
|
|
283
|
+
*/
|
|
284
|
+
requiresHuman?: boolean | undefined;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/*
|
|
288
|
+
* One tool's policy: docker (engine or swarm), pvesh, govc, ceph, the db
|
|
289
|
+
* catalog, the host CLIs. Implemented once per tool module; the dispatcher
|
|
290
|
+
* (ResourceCommandPolicy) picks the module from the resource type and has
|
|
291
|
+
* already checked argv[0] against the type's programs.
|
|
292
|
+
*/
|
|
293
|
+
export interface ResourceToolPolicy {
|
|
294
|
+
// "docker-engine", "docker-swarm", "pvesh", "govc", "ceph", "db", "host".
|
|
295
|
+
readonly name: string;
|
|
296
|
+
readonly programs: ReadonlyArray<string>;
|
|
297
|
+
/*
|
|
298
|
+
* Compact markdown bullets naming the read commands this tool allows, for
|
|
299
|
+
* the investigation tool's description (what the model may run to look).
|
|
300
|
+
*/
|
|
301
|
+
readonly readCommandGuide: string;
|
|
302
|
+
/*
|
|
303
|
+
* Compact markdown bullets naming the changes this tool allows and their
|
|
304
|
+
* tiers, for the remediation tools' descriptions.
|
|
305
|
+
*/
|
|
306
|
+
readonly writeCommandGuide: string;
|
|
307
|
+
/*
|
|
308
|
+
* Words this tool's grammar accepts where an allowlist entry has a `*`
|
|
309
|
+
* (an OSD id, a daemon name, a VMID, a weight, ...), tried besides the
|
|
310
|
+
* generic stand-ins when deciding whether an entry could ever pre-approve
|
|
311
|
+
* a change. Give at least two values of each kind, so a `*` that names
|
|
312
|
+
* the target can be seen to change it. Optional: a tool whose arguments
|
|
313
|
+
* the generic stand-ins already satisfy needs none.
|
|
314
|
+
*/
|
|
315
|
+
readonly allowlistStandIns?: ReadonlyArray<string> | undefined;
|
|
316
|
+
/*
|
|
317
|
+
* Optional: whether a protected entry names this target in a way the
|
|
318
|
+
* dispatcher's own comparison (the whole word, a glob, a hex id prefix)
|
|
319
|
+
* cannot see — for a tool whose objects go by several spellings (govc:
|
|
320
|
+
* "vcsa" and "/DC/vm/infra/vcsa" are the same VM). Asked on top of that
|
|
321
|
+
* comparison, never instead of it, so it can only protect more. MUST
|
|
322
|
+
* NOT throw (a throw is read as "protected").
|
|
323
|
+
*/
|
|
324
|
+
readonly isProtectedTarget?:
|
|
325
|
+
| ((target: string, protectedTarget: string) => boolean)
|
|
326
|
+
| undefined;
|
|
327
|
+
/*
|
|
328
|
+
* argv includes the program. MUST be total — never throw, whatever the
|
|
329
|
+
* argv holds — and fail closed: anything the tool does not recognise is
|
|
330
|
+
* Denied.
|
|
331
|
+
*/
|
|
332
|
+
evaluateArgv(argv: Array<string>): ResourceCommandPolicyResult;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// Only the string words of an argv; anything else is not a word.
|
|
336
|
+
function stringWords(argv: unknown): Array<string> {
|
|
337
|
+
if (!Array.isArray(argv)) {
|
|
338
|
+
return [];
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
return argv.filter((word: unknown): word is string => {
|
|
342
|
+
return typeof word === "string";
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
// A Denied result for this argv, with the reason shown to the model.
|
|
347
|
+
export function deniedResult(
|
|
348
|
+
argv: Array<string>,
|
|
349
|
+
reason: string,
|
|
350
|
+
): ResourceCommandPolicyResult {
|
|
351
|
+
const words: Array<string> = stringWords(argv);
|
|
352
|
+
|
|
353
|
+
return {
|
|
354
|
+
tier: ResourceCommandTier.Denied,
|
|
355
|
+
reason,
|
|
356
|
+
program: words[0] || "",
|
|
357
|
+
args: words.slice(1),
|
|
358
|
+
verb: "",
|
|
359
|
+
displayCommand: renderResourceDisplayCommand(words),
|
|
360
|
+
targets: [],
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
// Words a shell would read back unchanged, so they need no quotes.
|
|
365
|
+
const SHELL_SAFE_TOKEN: RegExp = /^[A-Za-z0-9_@%+=:,./-]+$/;
|
|
366
|
+
|
|
367
|
+
/*
|
|
368
|
+
* Render an argv back to the one-line form humans read on approval cards
|
|
369
|
+
* and in the activity feed. Words that would not survive a shell split are
|
|
370
|
+
* single-quoted, so the rendering round-trips through
|
|
371
|
+
* tokenizeResourceCommand.
|
|
372
|
+
*/
|
|
373
|
+
export function renderResourceDisplayCommand(argv: Array<string>): string {
|
|
374
|
+
return stringWords(argv)
|
|
375
|
+
.map((word: string): string => {
|
|
376
|
+
if (word === "") {
|
|
377
|
+
return "''";
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
if (SHELL_SAFE_TOKEN.test(word)) {
|
|
381
|
+
return word;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
return `'${word.replace(/'/g, `'\\''`)}'`;
|
|
385
|
+
})
|
|
386
|
+
.join(" ");
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/*
|
|
390
|
+
* Does a target glob name this target? `*` matches any run of characters
|
|
391
|
+
* (none included) within the one target; everything else is compared
|
|
392
|
+
* exactly, case-sensitively, and the pattern is anchored at both ends.
|
|
393
|
+
*
|
|
394
|
+
* A linear two-pointer scan, deliberately NOT a compiled regex: a pattern
|
|
395
|
+
* like "*a*a*a*a*b" against a long non-matching target would backtrack
|
|
396
|
+
* catastrophically in a regex (see CommandPolicy.globMatches, which this
|
|
397
|
+
* mirrors — copied, not imported, because this directory is import-closed).
|
|
398
|
+
*/
|
|
399
|
+
export function globMatchesTarget(pattern: string, target: string): boolean {
|
|
400
|
+
if (typeof pattern !== "string" || typeof target !== "string") {
|
|
401
|
+
return false;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
let patternIndex: number = 0;
|
|
405
|
+
let targetIndex: number = 0;
|
|
406
|
+
let lastWildcardIndex: number = -1;
|
|
407
|
+
let matchAfterWildcard: number = 0;
|
|
408
|
+
|
|
409
|
+
while (targetIndex < target.length) {
|
|
410
|
+
// The wildcard branch first: a target may hold a literal "*" too.
|
|
411
|
+
if (patternIndex < pattern.length && pattern.charAt(patternIndex) === "*") {
|
|
412
|
+
lastWildcardIndex = patternIndex;
|
|
413
|
+
matchAfterWildcard = targetIndex;
|
|
414
|
+
patternIndex++;
|
|
415
|
+
continue;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
if (
|
|
419
|
+
patternIndex < pattern.length &&
|
|
420
|
+
pattern.charAt(patternIndex) === target.charAt(targetIndex)
|
|
421
|
+
) {
|
|
422
|
+
patternIndex++;
|
|
423
|
+
targetIndex++;
|
|
424
|
+
continue;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
if (lastWildcardIndex >= 0) {
|
|
428
|
+
// Give the last wildcard one more character and retry from there.
|
|
429
|
+
patternIndex = lastWildcardIndex + 1;
|
|
430
|
+
matchAfterWildcard++;
|
|
431
|
+
targetIndex = matchAfterWildcard;
|
|
432
|
+
continue;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
return false;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
// Trailing wildcards may absorb the empty remainder.
|
|
439
|
+
while (
|
|
440
|
+
patternIndex < pattern.length &&
|
|
441
|
+
pattern.charAt(patternIndex) === "*"
|
|
442
|
+
) {
|
|
443
|
+
patternIndex++;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
return patternIndex === pattern.length;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
// A pattern word that stands for exactly one word of the command.
|
|
450
|
+
export const ALLOWLIST_WILDCARD_TOKEN: string = "*";
|
|
451
|
+
|
|
452
|
+
/*
|
|
453
|
+
* Does an allowlist entry (tokenized, program included) name this argv
|
|
454
|
+
* (program included)? Token by token: both must have the same number of
|
|
455
|
+
* words, a pattern word that is exactly "*" matches any one word, and every
|
|
456
|
+
* other word must be equal — case-sensitively, with no globbing inside a
|
|
457
|
+
* word. Tier-blind on purpose: the ladder decides which tiers the allowlist
|
|
458
|
+
* may promote.
|
|
459
|
+
*/
|
|
460
|
+
export function allowlistPatternMatches(
|
|
461
|
+
patternArgv: Array<string>,
|
|
462
|
+
argv: Array<string>,
|
|
463
|
+
): boolean {
|
|
464
|
+
if (!Array.isArray(patternArgv) || !Array.isArray(argv)) {
|
|
465
|
+
return false;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
if (patternArgv.length === 0 || patternArgv.length !== argv.length) {
|
|
469
|
+
return false;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
for (let i: number = 0; i < patternArgv.length; i++) {
|
|
473
|
+
const patternWord: unknown = patternArgv[i];
|
|
474
|
+
const word: unknown = argv[i];
|
|
475
|
+
|
|
476
|
+
if (typeof patternWord !== "string" || typeof word !== "string") {
|
|
477
|
+
return false;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
if (patternWord === ALLOWLIST_WILDCARD_TOKEN) {
|
|
481
|
+
continue;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
if (patternWord !== word) {
|
|
485
|
+
return false;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
return true;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
// The remediation verdict for one command under a resource's settings.
|
|
493
|
+
export interface ResourceAutoExecutionVerdict {
|
|
494
|
+
verdict: AiRemediationCommandPolicyVerdict;
|
|
495
|
+
tier: ResourceCommandTier;
|
|
496
|
+
reason: string;
|
|
497
|
+
requiresHuman?: boolean | undefined;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
/*
|
|
501
|
+
* The auto-execution ladder, identical in spirit to
|
|
502
|
+
* KubectlPolicy.evaluateForAutoExecution:
|
|
503
|
+
*
|
|
504
|
+
* Denied -> Denied (never runs, whoever approves it)
|
|
505
|
+
* Read -> AutoApproved (it changes nothing; callers route
|
|
506
|
+
* reads to the read tool)
|
|
507
|
+
* requiresHuman -> RequiresApproval, requiresHuman (beats Bypass
|
|
508
|
+
* approval and the allowlist)
|
|
509
|
+
* SafeWrite -> AutoApproved
|
|
510
|
+
* bypassApproval -> AutoApproved
|
|
511
|
+
* allowlistMatched -> AutoApproved
|
|
512
|
+
* otherwise -> RequiresApproval
|
|
513
|
+
*
|
|
514
|
+
* Callers apply the mode gate first: Disabled and RequireApproval never
|
|
515
|
+
* reach this. `allowlistMatched` is computed by the caller (the dispatcher
|
|
516
|
+
* matches the resource's allowlist), so this stays a pure function of its
|
|
517
|
+
* inputs.
|
|
518
|
+
*/
|
|
519
|
+
export function applyAutoExecutionLadder(
|
|
520
|
+
result: ResourceCommandPolicyResult,
|
|
521
|
+
options: { allowlistMatched: boolean; bypassApproval: boolean },
|
|
522
|
+
): ResourceAutoExecutionVerdict {
|
|
523
|
+
if (!result || typeof result !== "object") {
|
|
524
|
+
return {
|
|
525
|
+
verdict: AiRemediationCommandPolicyVerdict.Denied,
|
|
526
|
+
tier: ResourceCommandTier.Denied,
|
|
527
|
+
reason:
|
|
528
|
+
"Denied by the resource command policy: the command could not be evaluated. This command cannot run even with human approval.",
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
const reason: string = result.reason || "no reason given";
|
|
533
|
+
|
|
534
|
+
switch (result.tier) {
|
|
535
|
+
case ResourceCommandTier.Read:
|
|
536
|
+
return {
|
|
537
|
+
verdict: AiRemediationCommandPolicyVerdict.AutoApproved,
|
|
538
|
+
tier: result.tier,
|
|
539
|
+
reason,
|
|
540
|
+
};
|
|
541
|
+
|
|
542
|
+
case ResourceCommandTier.SafeWrite:
|
|
543
|
+
case ResourceCommandTier.RiskyWrite:
|
|
544
|
+
break;
|
|
545
|
+
|
|
546
|
+
default:
|
|
547
|
+
return {
|
|
548
|
+
verdict: AiRemediationCommandPolicyVerdict.Denied,
|
|
549
|
+
tier: ResourceCommandTier.Denied,
|
|
550
|
+
reason: `Denied by the resource command policy: ${reason}. This command cannot run even with human approval.`,
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
// Before SafeWrite, bypass and the allowlist: nothing an operator sets applies.
|
|
555
|
+
if (result.requiresHuman === true) {
|
|
556
|
+
return {
|
|
557
|
+
verdict: AiRemediationCommandPolicyVerdict.RequiresApproval,
|
|
558
|
+
tier: result.tier,
|
|
559
|
+
reason: `Requires human approval: ${reason}. Neither bypassing approvals nor the resource's allowlist applies to this command.`,
|
|
560
|
+
requiresHuman: true,
|
|
561
|
+
};
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
if (result.tier === ResourceCommandTier.SafeWrite) {
|
|
565
|
+
return {
|
|
566
|
+
verdict: AiRemediationCommandPolicyVerdict.AutoApproved,
|
|
567
|
+
tier: result.tier,
|
|
568
|
+
reason,
|
|
569
|
+
};
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
if (options && options.bypassApproval === true) {
|
|
573
|
+
return {
|
|
574
|
+
verdict: AiRemediationCommandPolicyVerdict.AutoApproved,
|
|
575
|
+
tier: result.tier,
|
|
576
|
+
reason: `Riskier change (${reason}) allowed without approval: the resource bypasses approvals.`,
|
|
577
|
+
};
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
if (options && options.allowlistMatched === true) {
|
|
581
|
+
return {
|
|
582
|
+
verdict: AiRemediationCommandPolicyVerdict.AutoApproved,
|
|
583
|
+
tier: result.tier,
|
|
584
|
+
reason: "Matched the resource's command allowlist.",
|
|
585
|
+
};
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
return {
|
|
589
|
+
verdict: AiRemediationCommandPolicyVerdict.RequiresApproval,
|
|
590
|
+
tier: result.tier,
|
|
591
|
+
reason: `Requires human approval: ${reason}.`,
|
|
592
|
+
};
|
|
593
|
+
}
|