Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
refactor: clean up AI tools and remove deprecated code
rcourtmanc93b54ce9fa2
diff --git a/internal/ai/tools/control_helpers_test.go b/internal/ai/tools/control_helpers_test.goindex b0e0777042..1691697382 100644--- a/internal/ai/tools/control_helpers_test.go+++ b/internal/ai/tools/control_helpers_test.go@@ -91,12 +91,6 @@ func TestFormattingHelpers(t *testing.T) {assert.Contains(t, msg, "(+1 more)")})- t.Run("formatCommandSuggestion", func(t *testing.T) {- msg := formatCommandSuggestion("ls", true, "host-1")- assert.Contains(t, msg, "Suggested command for host host-1")- assert.Contains(t, msg, "ls")- })-t.Run("formatControlApprovalNeeded", func(t *testing.T) {payload := decodePayload(t, formatControlApprovalNeeded("vm1", 101, "start", "qm start 101", "id-2"), "APPROVAL_REQUIRED: ")assert.Equal(t, "approval_required", payload["type"])@@ -116,19 +110,6 @@ func TestFormattingHelpers(t *testing.T) {assert.Equal(t, "docker restart web", payload["command"])assert.Equal(t, "id-3", payload["approval_id"])})-- t.Run("formatControlSuggestion", func(t *testing.T) {- msg := formatControlSuggestion("vm1", 101, "start", "qm start 101", "node-1")- assert.Contains(t, msg, "To start vm1 (VMID 101)")- assert.Contains(t, msg, "node node-1")- assert.Contains(t, msg, "qm start 101")- })-- t.Run("formatDockerSuggestion", func(t *testing.T) {- msg := formatDockerSuggestion("web", "node-1", "restart", "docker restart web")- assert.Contains(t, msg, "To restart container 'web' on host node-1")- assert.Contains(t, msg, "docker restart web")- })}func decodePayload(t *testing.T, value, prefix string) map[string]interface{} {diff --git a/internal/ai/tools/control_run_command_test.go b/internal/ai/tools/control_run_command_test.goindex 058478aafd..fa8713ddce 100644--- a/internal/ai/tools/control_run_command_test.go+++ b/internal/ai/tools/control_run_command_test.go@@ -49,17 +49,6 @@ func TestPulseToolExecutor_ExecuteRunCommand(t *testing.T) {assert.Contains(t, result.Content[0].Text, "Multiple agents are connected")})- t.Run("SuggestMode", func(t *testing.T) {- exec := NewPulseToolExecutor(ExecutorConfig{ControlLevel: ControlLevelSuggest})- result, err := exec.executeRunCommand(ctx, map[string]interface{}{- "command": "ls",- "run_on_host": true,- "target_host": "node1",- })- assert.NoError(t, err)- assert.Contains(t, result.Content[0].Text, "Suggested command for host node1")- })-t.Run("ControlledRequiresApproval", func(t *testing.T) {approval.SetStore(nil)exec := NewPulseToolExecutor(ExecutorConfig{ControlLevel: ControlLevelControlled})diff --git a/internal/ai/tools/docker_updates_test.go b/internal/ai/tools/docker_updates_test.goindex faa02f6c31..fe385d1028 100644--- a/internal/ai/tools/docker_updates_test.go+++ b/internal/ai/tools/docker_updates_test.go@@ -32,17 +32,6 @@ func TestExecuteCheckDockerUpdates(t *testing.T) {},}- exec = NewPulseToolExecutor(ExecutorConfig{- UpdatesProvider: updatesProvider,- StateProvider: &mockStateProvider{state: state},- ControlLevel: ControlLevelSuggest,- })- result, err = exec.executeCheckDockerUpdates(ctx, map[string]interface{}{- "host": "dock1",- })- require.NoError(t, err)- assert.Contains(t, result.Content[0].Text, "POST /api/agents/docker/hosts/host1/check-updates")-updatesProvider.On("TriggerUpdateCheck", "host1").Return(DockerCommandStatus{ID: "cmd1",Type: "check",diff --git a/internal/ai/tools/executor.go b/internal/ai/tools/executor.goindex 3648305670..9c230ebd10 100644--- a/internal/ai/tools/executor.go+++ b/internal/ai/tools/executor.go@@ -99,8 +99,6 @@ type ControlLevel stringconst (// ControlLevelReadOnly - AI can only query, no control tools availableControlLevelReadOnly ControlLevel = "read_only"- // ControlLevelSuggest - AI suggests commands, user must copy/paste to execute- ControlLevelSuggest ControlLevel = "suggest"// ControlLevelControlled - AI can execute with per-command approvalControlLevelControlled ControlLevel = "controlled"// ControlLevelAutonomous - AI executes without approval (requires Pro license)diff --git a/internal/ai/tools/tools_control.go b/internal/ai/tools/tools_control.goindex 88517a12bf..71362c96db 100644--- a/internal/ai/tools/tools_control.go+++ b/internal/ai/tools/tools_control.go@@ -167,10 +167,6 @@ func (e *PulseToolExecutor) executeRunCommand(ctx context.Context, args map[stri}}- if e.controlLevel == ControlLevelSuggest {- return NewTextResult(formatCommandSuggestion(command, runOnHost, targetHost)), nil- }-// Skip approval checks if pre-approvedif !preApproved && e.controlLevel == ControlLevelControlled {targetType := "container"@@ -305,10 +301,6 @@ func (e *PulseToolExecutor) executeControlGuest(ctx context.Context, args map[streturn NewTextResult(formatControlApprovalNeeded(guest.Name, guest.VMID, action, command, approvalID)), nil}- if e.controlLevel == ControlLevelSuggest {- return NewTextResult(formatControlSuggestion(guest.Name, guest.VMID, action, command, guest.Node)), nil- }-if e.agentServer == nil {return NewErrorResult(fmt.Errorf("no agent server available")), nil}@@ -389,10 +381,6 @@ func (e *PulseToolExecutor) executeControlDocker(ctx context.Context, args map[sreturn NewTextResult(formatDockerApprovalNeeded(container.Name, dockerHost.Hostname, action, command, approvalID)), nil}- if e.controlLevel == ControlLevelSuggest {- return NewTextResult(formatDockerSuggestion(container.Name, dockerHost.Hostname, action, command)), nil- }-if e.agentServer == nil {return NewErrorResult(fmt.Errorf("no agent server available")), nil}@@ -738,17 +726,6 @@ func formatTargetHostRequired(agents []agentexec.ConnectedAgent) string {return message}-func formatCommandSuggestion(command string, runOnHost bool, targetHost string) string {- target := "current target"- if runOnHost {- target = "host"- }- if strings.TrimSpace(targetHost) != "" {- target = fmt.Sprintf("host %s", targetHost)- }- return fmt.Sprintf("Suggested command for %s:\n%s", target, command)-}-func formatControlApprovalNeeded(name string, vmid int, action, command, approvalID string) string {payload := map[string]interface{}{"type": "approval_required",@@ -778,19 +755,3 @@ func formatDockerApprovalNeeded(name, host, action, command, approvalID string)b, _ := json.Marshal(payload)return "APPROVAL_REQUIRED: " + string(b)}--func formatControlSuggestion(name string, vmid int, action, command, node string) string {- return fmt.Sprintf(`To %s %s (VMID %d), run this command on node %s:--%s--Copy and paste this command to execute it manually.`, action, name, vmid, node, command)-}--func formatDockerSuggestion(name, host, action, command string) string {- return fmt.Sprintf(`To %s container '%s' on host %s, run:--%s--Copy and paste this command to execute it manually.`, action, name, host, command)-}diff --git a/internal/ai/tools/tools_infrastructure.go b/internal/ai/tools/tools_infrastructure.goindex 7a56631cdd..5ea089b75c 100644--- a/internal/ai/tools/tools_infrastructure.go+++ b/internal/ai/tools/tools_infrastructure.go@@ -983,11 +983,6 @@ func (e *PulseToolExecutor) executeCheckDockerUpdates(_ context.Context, args mahostName := e.getDockerHostName(hostID)- // Control level check - suggest mode just returns the suggestion- if e.controlLevel == ControlLevelSuggest {- return NewTextResult(fmt.Sprintf("To check for Docker updates on host '%s', use the UI or API:\n\nPOST /api/agents/docker/hosts/%s/check-updates", hostName, hostID)), nil- }-// Trigger the update checkcmdStatus, err := e.updatesProvider.TriggerUpdateCheck(hostID)if err != nil {@@ -1034,18 +1029,6 @@ func (e *PulseToolExecutor) executeUpdateDockerContainer(ctx context.Context, arcontainerName := trimContainerName(container.Name)- // Control level handling- if e.controlLevel == ControlLevelSuggest {- return NewTextResult(fmt.Sprintf(`To update container '%s' on host '%s', use the UI or run:--POST /api/agents/docker/containers/update-{- "hostId": "%s",- "containerId": "%s",- "containerName": "%s"-}`, containerName, dockerHost.Hostname, dockerHost.ID, container.ID, containerName)), nil- }-// Controlled mode - require approvalif e.controlLevel == ControlLevelControlled {command := fmt.Sprintf("docker update %s", containerName)diff --git a/internal/ai/tools/tools_infrastructure_test.go b/internal/ai/tools/tools_infrastructure_test.goindex a7ccd2f371..e487712542 100644--- a/internal/ai/tools/tools_infrastructure_test.go+++ b/internal/ai/tools/tools_infrastructure_test.go@@ -221,7 +221,7 @@ func TestDockerUpdateTools(t *testing.T) {stateProv.On("GetState").Return(state)executor := NewPulseToolExecutor(ExecutorConfig{StateProvider: stateProv,- ControlLevel: ControlLevelSuggest,+ ControlLevel: ControlLevelControlled,})updates := &stubUpdatesProvider{pending: []ContainerUpdateInfo{@@ -251,8 +251,12 @@ func TestDockerUpdateTools(t *testing.T) {}result, _ = executor.executeCheckDockerUpdates(context.Background(), map[string]interface{}{"host": "Docker One"})- if !strings.Contains(result.Content[0].Text, "check-updates") {- t.Fatalf("unexpected suggest response: %s", result.Content[0].Text)+ var checkResp DockerCheckUpdatesResponse+ if err := json.Unmarshal([]byte(result.Content[0].Text), &checkResp); err != nil {+ t.Fatalf("decode docker check response: %v", err)+ }+ if checkResp.CommandID != "cmd1" || checkResp.HostID != "host1" {+ t.Fatalf("unexpected check response: %+v", checkResp)}executor.controlLevel = ControlLevelAutonomousdiff --git a/internal/ai/tools/tools_profiles.go b/internal/ai/tools/tools_profiles.goindex 3fa097c0b9..44a482d73f 100644--- a/internal/ai/tools/tools_profiles.go+++ b/internal/ai/tools/tools_profiles.go@@ -188,30 +188,6 @@ func (e *PulseToolExecutor) executeSetAgentScope(ctx context.Context, args map[sreturn NewErrorResult(fmt.Errorf("use either profile_id or settings, not both")), nil}- if e.controlLevel == ControlLevelSuggest {- if profileID != "" {- return NewJSONResult(map[string]interface{}{- "type": "suggestion",- "action": "assign_profile",- "agent_id": agentID,- "agent_label": agentLabel,- "profile_id": profileID,- "message": fmt.Sprintf("Suggestion: assign profile %s to agent %s.", profileID, agentLabel),- }), nil- }- if len(settings) == 0 {- return NewErrorResult(fmt.Errorf("settings are required when profile_id is not provided")), nil- }- return NewJSONResult(map[string]interface{}{- "type": "suggestion",- "action": "apply_settings",- "agent_id": agentID,- "agent_label": agentLabel,- "settings": settings,- "message": fmt.Sprintf("Suggestion: apply agent scope to %s with settings: %s", agentLabel, formatSettingsSummary(settings)),- }), nil- }-if profileID != "" {profileName, err := e.agentProfileManager.AssignProfile(ctx, agentID, profileID)if err != nil {diff --git a/internal/ai/tools/tools_profiles_test.go b/internal/ai/tools/tools_profiles_test.goindex 650fa65b34..45f0b569b6 100644--- a/internal/ai/tools/tools_profiles_test.go+++ b/internal/ai/tools/tools_profiles_test.go@@ -322,65 +322,6 @@ func TestExecuteSetAgentScopeErrors(t *testing.T) {}}-func TestExecuteSetAgentScopeSuggestProfile(t *testing.T) {- executor := NewPulseToolExecutor(ExecutorConfig{- ControlLevel: ControlLevelSuggest,- AgentProfileManager: &mockProfileManager{},- })-- result, err := executor.executeSetAgentScope(context.Background(), map[string]interface{}{- "agent_id": "agent-1",- "profile_id": "profile-1",- })- if err != nil {- t.Fatalf("unexpected error: %v", err)- }- if result.IsError {- t.Fatal("expected suggestion response")- }-- var payload map[string]interface{}- if err := json.Unmarshal([]byte(result.Content[0].Text), &payload); err != nil {- t.Fatalf("unmarshal: %v", err)- }- if payload["type"] != "suggestion" || payload["action"] != "assign_profile" {- t.Fatalf("unexpected suggestion payload: %v", payload)- }-}--func TestExecuteSetAgentScopeSuggestSettings(t *testing.T) {- executor := NewPulseToolExecutor(ExecutorConfig{- ControlLevel: ControlLevelSuggest,- AgentProfileManager: &mockProfileManager{},- })-- result, err := executor.executeSetAgentScope(context.Background(), map[string]interface{}{- "agent_id": "agent-1",- "settings": map[string]interface{}{- "alpha": 1,- "beta": true,- },- })- if err != nil {- t.Fatalf("unexpected error: %v", err)- }- if result.IsError {- t.Fatal("expected suggestion response")- }-- var payload map[string]interface{}- if err := json.Unmarshal([]byte(result.Content[0].Text), &payload); err != nil {- t.Fatalf("unmarshal: %v", err)- }- if payload["type"] != "suggestion" || payload["action"] != "apply_settings" {- t.Fatalf("unexpected suggestion payload: %v", payload)- }- message, _ := payload["message"].(string)- if !strings.Contains(message, "alpha=1, beta=true") {- t.Fatalf("expected settings summary, got %q", message)- }-}-func TestExecuteSetAgentScopeAssignProfile(t *testing.T) {manager := &mockProfileManager{assignName: "Gold",