agent

package
v0.0.20 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2025 License: Apache-2.0 Imports: 18 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	Name             string `json:"name"`
	Reason           string `json:"reason"`
	Command          string `json:"command"`
	ModifiesResource string `json:"modifies_resource"`
}

type Agent

type Agent struct {
	// Input is the channel to receive user input.
	Input chan any

	// Output is the channel to send messages to the UI.
	Output chan any

	// RunOnce indicates if the agent should run only once.
	// If true, the agent will run only once and then exit.
	// If false, the agent will run in a loop until the context is done.
	RunOnce bool

	// InitialQuery is the initial query to the agent.
	// If provided, the agent will run only once and then exit.
	InitialQuery string

	LLM gollm.Client

	// PromptTemplateFile allows specifying a custom template file
	PromptTemplateFile string
	// ExtraPromptPaths allows specifying additional prompt templates
	// to be combined with PromptTemplateFile
	ExtraPromptPaths []string
	Model            string

	RemoveWorkDir bool

	MaxIterations int

	// Kubeconfig is the path to the kubeconfig file.
	Kubeconfig string

	SkipPermissions bool

	Tools tools.Tools

	EnableToolUseShim bool

	// MCPClientEnabled indicates whether MCP client mode is enabled
	MCPClientEnabled bool

	// Recorder captures events for diagnostics
	Recorder journal.Recorder
	// contains filtered or unexported fields
}

func (*Agent) AgentState added in v0.0.16

func (c *Agent) AgentState() api.AgentState

func (*Agent) Close added in v0.0.16

func (c *Agent) Close() error

func (*Agent) CloseMCPClient added in v0.0.16

func (a *Agent) CloseMCPClient() error

CloseMCPClient closes the MCP client connections

func (*Agent) DispatchToolCalls added in v0.0.16

func (c *Agent) DispatchToolCalls(ctx context.Context) error

func (*Agent) GetMCPStatusText added in v0.0.16

func (a *Agent) GetMCPStatusText() string

GetMCPStatusText returns a formatted text representation of the MCP status This can be used by UIs that want to display the status as text

func (*Agent) Init added in v0.0.16

func (s *Agent) Init(ctx context.Context) error

func (*Agent) InitializeMCPClient added in v0.0.16

func (a *Agent) InitializeMCPClient(ctx context.Context) error

InitializeMCPClient initializes MCP client functionality for the agent. It connects to servers and registers discovered tools with the kubectl-ai tool system.

func (*Agent) Run added in v0.0.16

func (c *Agent) Run(ctx context.Context, initialQuery string) error

func (*Agent) Session added in v0.0.16

func (s *Agent) Session() *api.Session

func (*Agent) UpdateMCPStatus added in v0.0.16

func (a *Agent) UpdateMCPStatus(ctx context.Context, mcpClientEnabled bool) error

UpdateMCPStatus updates the MCP status in the agent's session

type PromptData

type PromptData struct {
	Query string
	Tools tools.Tools

	EnableToolUseShim bool
}

PromptData represents the structure of the data to be filled into the template.

func (*PromptData) ToolNames

func (a *PromptData) ToolNames() string

func (*PromptData) ToolsAsJSON

func (a *PromptData) ToolsAsJSON() string

type ReActResponse

type ReActResponse struct {
	Thought string  `json:"thought"`
	Answer  string  `json:"answer,omitempty"`
	Action  *Action `json:"action,omitempty"`
}

type ShimCandidate

type ShimCandidate struct {
	// contains filtered or unexported fields
}

func (*ShimCandidate) Parts

func (c *ShimCandidate) Parts() []gollm.Part

func (*ShimCandidate) String

func (c *ShimCandidate) String() string

type ShimPart

type ShimPart struct {
	// contains filtered or unexported fields
}

func (*ShimPart) AsFunctionCalls

func (p *ShimPart) AsFunctionCalls() ([]gollm.FunctionCall, bool)

func (*ShimPart) AsText

func (p *ShimPart) AsText() (string, bool)

type ShimResponse added in v0.0.2

type ShimResponse struct {
	// contains filtered or unexported fields
}

func (*ShimResponse) Candidates added in v0.0.2

func (r *ShimResponse) Candidates() []gollm.Candidate

func (*ShimResponse) UsageMetadata added in v0.0.2

func (r *ShimResponse) UsageMetadata() any

type ToolCallAnalysis added in v0.0.16

type ToolCallAnalysis struct {
	FunctionCall        gollm.FunctionCall
	ParsedToolCall      *tools.ToolCall
	IsInteractive       bool
	IsInteractiveError  error
	ModifiesResourceStr string
}

Jump to

Keyboard shortcuts

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