agent

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 18, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package agent provides the core Copilot agent functionality for Kubernetes cluster operations. It implements an interactive agent using the GitHub Copilot SDK that can monitor, query, and manage Kubernetes clusters through natural language interactions.

Package agent provides the core Copilot agent functionality for Kubernetes cluster operations. This file contains tool definitions and related helpers.

Package agent provides enhanced kubectl command validation. This file contains security and safety checks for kubectl command execution.

Index

Constants

This section is empty.

Variables

View Source
var AppVersion = "dev"

Version information for display

Functions

func DefaultMCPConfigPath added in v0.4.0

func DefaultMCPConfigPath() string

DefaultMCPConfigPath returns the default path for the MCP config file: $HOME/.kopilot/mcp.json, falling back to ".kopilot/mcp.json" on error.

func Run

func Run(k8sProvider *k8s.Provider, mode ExecutionMode, outputFormat OutputFormat, agentType AgentType, mcpConfigPath string) error

Run starts the Copilot agent with Kubernetes cluster tools. mcpConfigPath is the path to the JSON file storing MCP server configurations; pass an empty string to use the default (~/.kopilot/mcp.json).

Types

type AgentType added in v0.3.0

type AgentType string

AgentType defines the specialized agent persona

const (
	// AgentDefault uses the standard Kopilot persona
	AgentDefault AgentType = "default"
	// AgentDebugger specializes in root cause analysis and failure diagnosis
	AgentDebugger AgentType = "debugger"
	// AgentSecurity specializes in RBAC auditing, privilege escalation, and CVE detection
	AgentSecurity AgentType = "security"
	// AgentOptimizer specializes in resource right-sizing and cost optimization
	AgentOptimizer AgentType = "optimizer"
	// AgentGitOps specializes in Flux/ArgoCD sync status and drift detection
	AgentGitOps AgentType = "gitops"
	// AgentSanitizer specializes in cluster linting, best-practice scoring, and compliance grading
	AgentSanitizer AgentType = "sanitizer"
)

func ParseAgentType added in v0.3.0

func ParseAgentType(s string) (AgentType, error)

ParseAgentType converts a string to an AgentType, returning an error for unknown values

type CheckAllClustersParams

type CheckAllClustersParams struct{}

CheckAllClustersParams defines no parameters for check_all_clusters

type CheckAllClustersResult

type CheckAllClustersResult struct {
	Summary  CheckAllClustersSummary `json:"summary"`
	Issues   []string                `json:"issues"`
	Clusters []*k8s.ClusterStatus    `json:"clusters"`
}

CheckAllClustersResult defines JSON output for check_all_clusters

type CheckAllClustersSummary

type CheckAllClustersSummary struct {
	TotalClusters int `json:"total_clusters"`
	Reachable     int `json:"reachable"`
	FullyHealthy  int `json:"fully_healthy"`
	UnhealthyPods int `json:"unhealthy_pods"`
}

CheckAllClustersSummary defines JSON output summary for check_all_clusters

type CompareClusterParams

type CompareClusterParams struct {
	Contexts []string `json:"contexts" jsonschema:"Array of context names to compare (from list_clusters), minimum 2 required"`
}

CompareClusterParams defines parameters for compare_clusters

type CompareClustersResult

type CompareClustersResult struct {
	Summary  CompareClustersSummary `json:"summary"`
	Clusters []ComparisonData       `json:"clusters"`
}

CompareClustersResult defines JSON output for compare_clusters

type CompareClustersSummary

type CompareClustersSummary struct {
	Total     int `json:"total"`
	Reachable int `json:"reachable"`
}

CompareClustersSummary defines summary JSON output for compare_clusters

type ComparisonData

type ComparisonData struct {
	Context      string
	Name         string
	Status       string
	Version      string
	Nodes        string
	HealthyNodes string
	APIServer    string
	Error        string
}

ComparisonData holds comparison information for a cluster

type ExecutionMode

type ExecutionMode int

ExecutionMode defines how kubectl commands are executed

const (
	// ModeReadOnly blocks all write operations
	ModeReadOnly ExecutionMode = iota
	// ModeInteractive asks for confirmation before write operations
	ModeInteractive
)

func (ExecutionMode) String

func (m ExecutionMode) String() string

String returns a human-readable name for the execution mode

type GetClusterStatusParams

type GetClusterStatusParams struct {
	Context string `json:"context" jsonschema:"The context name of the cluster to query (from list_clusters)"`
}

GetClusterStatusParams defines parameters for get_cluster_status

type KubectlExecParams

type KubectlExecParams struct {
	Context string   `json:"context" jsonschema:"The cluster context name to execute against (required)"`
	Args    []string `json:"args" jsonschema:"The kubectl command arguments (e.g., ['get', 'pods', '-n', 'default'])"`
}

KubectlExecParams defines parameters for kubectl_exec

type KubectlExecResult

type KubectlExecResult struct {
	Cluster  string `json:"cluster"`
	Context  string `json:"context"`
	Command  string `json:"command"`
	Output   string `json:"output"`
	ExitCode *int   `json:"exit_code,omitempty"`
	Error    string `json:"error,omitempty"`
}

KubectlExecResult defines JSON output for kubectl_exec

type ListClustersParams

type ListClustersParams struct{}

ListClustersParams defines no parameters for list_clusters

type ListClustersResult

type ListClustersResult struct {
	CurrentContext string             `json:"current_context"`
	Clusters       []*k8s.ClusterInfo `json:"clusters"`
}

ListClustersResult defines JSON output for list_clusters

type MCPAddServerParams added in v0.4.0

type MCPAddServerParams struct {
	Name string `json:"name" jsonschema:"Unique identifier for the MCP server (alphanumeric, hyphens, underscores)"`
	URL  string `json:"url"  jsonschema:"HTTP(S) endpoint URL of the MCP server"`
}

MCPAddServerParams defines parameters for mcp_add_server

type MCPDeleteServerParams added in v0.4.0

type MCPDeleteServerParams struct {
	Name string `json:"name" jsonschema:"Name of the MCP server to remove"`
}

MCPDeleteServerParams defines parameters for mcp_delete_server

type MCPListServersParams added in v0.4.0

type MCPListServersParams struct{}

MCPListServersParams defines no parameters for mcp_list_servers

type MCPListServersResult added in v0.4.0

type MCPListServersResult struct {
	Servers []MCPServerConfig `json:"servers"`
}

MCPListServersResult defines the output for mcp_list_servers

type MCPServerConfig added in v0.4.0

type MCPServerConfig struct {
	// Name is the unique identifier used to reference this server.
	Name string `json:"name"`
	// Type is the transport type, currently only "http" is supported.
	Type string `json:"type"`
	// URL is the HTTP(S) endpoint of the MCP server.
	URL string `json:"url"`
}

MCPServerConfig holds the configuration for a single MCP server.

type OutputFormat

type OutputFormat string

OutputFormat defines the output format for tool responses

const (
	// OutputText returns human-readable output
	OutputText OutputFormat = "text"
	// OutputJSON returns JSON output
	OutputJSON OutputFormat = "json"
)

type SanitizeClusterParams added in v0.4.0

type SanitizeClusterParams struct {
	Context       string `json:"context" jsonschema:"The context name of the cluster to sanitize (from list_clusters)"`
	Namespace     string `` /* 138-byte string literal not displayed */
	IncludeSystem bool   `` /* 135-byte string literal not displayed */
}

SanitizeClusterParams defines parameters for sanitize_cluster

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL