agents

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2025 License: MIT Imports: 16 Imported by: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateSuccessRate

func CalculateSuccessRate(metrics []*EvaluationMetrics) float64

CalculateSuccessRate calculates success rate from historical metrics

func ClassifyFileType

func ClassifyFileType(filename string) string

ClassifyFileType classifies a file based on its extension

func FormatDuration

func FormatDuration(d time.Duration) string

FormatDuration formats a duration for display

func GetAverageLatency

func GetAverageLatency(metrics []*EvaluationMetrics) time.Duration

GetAverageLatency calculates average latency from historical metrics

func GetCostEstimate

func GetCostEstimate(plan *ExecutionPlan, model string) float64

GetCostEstimate estimates the cost of a query before execution

func ParseFileList

func ParseFileList(output string) []string

ParseFileList parses output from ls command into file list

func ParseJSONResponse

func ParseJSONResponse(response string, target interface{}) error

ParseJSONResponse is a helper to parse JSON responses

Types

type Agent

type Agent interface {
	// Name returns the agent's name
	Name() string

	// Execute processes input and returns output
	Execute(ctx context.Context, input interface{}) (interface{}, error)
}

Agent is the base interface for all agents

type BashAgent

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

BashAgent executes bash commands safely

func NewBashAgent

func NewBashAgent() *BashAgent

NewBashAgent creates a new BashAgent

func (*BashAgent) CheckToolInstalled

func (a *BashAgent) CheckToolInstalled(ctx context.Context, tool string) (bool, error)

CheckToolInstalled checks if a tool is installed

func (*BashAgent) Execute

func (a *BashAgent) Execute(ctx context.Context, input interface{}) (interface{}, error)

Execute executes a bash command

func (*BashAgent) Name

func (a *BashAgent) Name() string

Name returns the agent's name

func (*BashAgent) SetOutputAgent

func (a *BashAgent) SetOutputAgent(outputAgent *OutputAgent)

SetOutputAgent sets the output agent for user interaction

func (*BashAgent) SuggestInstallation

func (a *BashAgent) SuggestInstallation(tool string) string

SuggestInstallation suggests how to install a missing tool

type BashCommand

type BashCommand struct {
	Command     string            `json:"command"`
	Args        []string          `json:"args"`
	WorkingDir  string            `json:"working_dir,omitempty"`
	Timeout     time.Duration     `json:"timeout,omitempty"`
	Environment map[string]string `json:"environment,omitempty"`
}

BashCommand represents a bash command to execute

type BashResult

type BashResult struct {
	Success  bool          `json:"success"`
	Stdout   string        `json:"stdout"`
	Stderr   string        `json:"stderr"`
	ExitCode int           `json:"exit_code"`
	Duration time.Duration `json:"duration"`
}

BashResult represents result of bash command execution

type CommandReport

type CommandReport struct {
	Type     string        `json:"type"` // "bash", "weave"
	Command  string        `json:"command"`
	Success  bool          `json:"success"`
	Output   string        `json:"output"`
	Error    string        `json:"error,omitempty"`
	Duration time.Duration `json:"duration"`
}

CommandReport represents a single command execution report

type EvalAgent

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

EvalAgent evaluates query execution and tracks metrics

func NewEvalAgent

func NewEvalAgent(llmClient llm.Client) *EvalAgent

NewEvalAgent creates a new EvalAgent

func (*EvalAgent) Execute

func (a *EvalAgent) Execute(ctx context.Context, input interface{}) (interface{}, error)

Execute evaluates the operation report and generates metrics

func (*EvalAgent) Name

func (a *EvalAgent) Name() string

Name returns the agent's name

func (*EvalAgent) TrackMetrics

func (a *EvalAgent) TrackMetrics(metrics *EvaluationMetrics) error

TrackMetrics tracks metrics (placeholder for Opik integration)

type EvaluationMetrics

type EvaluationMetrics struct {
	QueryID          string        `json:"query_id"`
	Success          bool          `json:"success"`
	IntentMatched    bool          `json:"intent_matched"`
	LLMInvocations   int           `json:"llm_invocations"`
	TotalTokens      int           `json:"total_tokens"`
	PromptTokens     int           `json:"prompt_tokens"`
	CompletionTokens int           `json:"completion_tokens"`
	TotalCost        float64       `json:"total_cost"`
	Latency          time.Duration `json:"latency"`
	ErrorRate        float64       `json:"error_rate"`
	UserSatisfaction *float64      `json:"user_satisfaction,omitempty"`
}

EvaluationMetrics represents evaluation metrics for a query

type ExecutionPlan

type ExecutionPlan struct {
	Steps       []ExecutionStep `json:"steps"`
	Summary     string          `json:"summary"`
	Warnings    []string        `json:"warnings,omitempty"`
	Estimations struct {
		Duration string `json:"duration"`
		Risk     string `json:"risk"` // "low", "medium", "high"
	} `json:"estimations"`
}

ExecutionPlan represents a complete execution plan

type ExecutionStep

type ExecutionStep struct {
	Type        string                 `json:"type"` // "bash", "weave", "confirm"
	Command     string                 `json:"command"`
	Description string                 `json:"description"`
	Args        []string               `json:"args,omitempty"`
	Params      map[string]interface{} `json:"params,omitempty"`
	DependsOn   []int                  `json:"depends_on,omitempty"` // Step indices
	Optional    bool                   `json:"optional"`
	Destructive bool                   `json:"destructive"`
}

ExecutionStep represents a single step in an execution plan

type OperationReport

type OperationReport struct {
	QueryIntent     string          `json:"query_intent"`
	ExecutedSteps   int             `json:"executed_steps"`
	SuccessfulSteps int             `json:"successful_steps"`
	FailedSteps     int             `json:"failed_steps"`
	StartTime       time.Time       `json:"start_time"`
	EndTime         time.Time       `json:"end_time"`
	Duration        time.Duration   `json:"duration"`
	Commands        []CommandReport `json:"commands"`
	Summary         string          `json:"summary"`
	Recommendations []string        `json:"recommendations,omitempty"`
	NextSteps       []string        `json:"next_steps,omitempty"`
}

OperationReport represents a complete operation report

func CreateReport

func CreateReport(intent string, startTime time.Time, commands []CommandReport) *OperationReport

CreateReport creates an operation report from execution results

type OutputAgent

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

OutputAgent formats and displays information to users

func NewOutputAgent

func NewOutputAgent(config OutputConfig) *OutputAgent

NewOutputAgent creates a new OutputAgent

func (*OutputAgent) AskConfirmation

func (a *OutputAgent) AskConfirmation(message string) (bool, error)

AskConfirmation asks the user for confirmation

func (*OutputAgent) CreateProgressBar

func (a *OutputAgent) CreateProgressBar(max int, description string) *progressbar.ProgressBar

CreateProgressBar creates a progress bar for tracking operations

func (*OutputAgent) Execute

func (a *OutputAgent) Execute(ctx context.Context, input interface{}) (interface{}, error)

Execute formats and displays output (not typically used directly)

func (*OutputAgent) Name

func (a *OutputAgent) Name() string

Name returns the agent's name

func (*OutputAgent) PrintCommandOutput

func (a *OutputAgent) PrintCommandOutput(output string)

PrintCommandOutput prints the output from a command execution

func (*OutputAgent) PrintCommandResult

func (a *OutputAgent) PrintCommandResult(report *CommandReport)

PrintCommandResult prints the result of a command execution

func (*OutputAgent) PrintError

func (a *OutputAgent) PrintError(message string)

PrintError prints an error message

func (*OutputAgent) PrintInfo

func (a *OutputAgent) PrintInfo(message string)

PrintInfo prints an info message

func (*OutputAgent) PrintMetrics

func (a *OutputAgent) PrintMetrics(metrics *EvaluationMetrics)

PrintMetrics prints evaluation metrics

func (*OutputAgent) PrintPlan

func (a *OutputAgent) PrintPlan(plan *ExecutionPlan)

PrintPlan displays the execution plan to the user

func (*OutputAgent) PrintRejectionMessage

func (a *OutputAgent) PrintRejectionMessage(reason string)

PrintRejectionMessage prints a message when query is rejected

func (*OutputAgent) PrintStepCompletion

func (a *OutputAgent) PrintStepCompletion(stepNum int, duration time.Duration)

PrintStepCompletion prints step completion with duration

func (*OutputAgent) PrintStepError

func (a *OutputAgent) PrintStepError(stepNum int, errMsg string)

PrintStepError prints step error

func (*OutputAgent) PrintStepProgress

func (a *OutputAgent) PrintStepProgress(stepNum int, step *ExecutionStep, status string)

PrintStepProgress prints progress for a step

func (*OutputAgent) PrintSuccess

func (a *OutputAgent) PrintSuccess(message string)

PrintSuccess prints a success message

func (*OutputAgent) PrintWarning

func (a *OutputAgent) PrintWarning(message string)

PrintWarning prints a warning message

type OutputConfig

type OutputConfig struct {
	NoColor      bool
	Verbose      bool
	Quiet        bool
	OutputFormat string // "text", "json", "yaml"
}

OutputConfig configures the OutputAgent

type PlanningAgent

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

PlanningAgent creates execution plans for queries

func NewPlanningAgent

func NewPlanningAgent(llmClient llm.Client, mcpTools []string) *PlanningAgent

NewPlanningAgent creates a new PlanningAgent with tool names only

func NewPlanningAgentWithTools

func NewPlanningAgentWithTools(llmClient llm.Client, tools []mcp.Tool) *PlanningAgent

NewPlanningAgentWithTools creates a new PlanningAgent with full tool information

func (*PlanningAgent) Execute

func (a *PlanningAgent) Execute(ctx context.Context, input interface{}) (interface{}, error)

Execute creates an execution plan for the query

func (*PlanningAgent) Name

func (a *PlanningAgent) Name() string

Name returns the agent's name

type PlanningAgentInput

type PlanningAgentInput struct {
	FixedQuery string `json:"fixed_query"`
	Intent     string `json:"intent"`
}

PlanningAgentInput is input for PlanningAgent

type QueryAgent

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

QueryAgent validates and normalizes user queries

func NewQueryAgent

func NewQueryAgent(llmClient llm.Client) *QueryAgent

NewQueryAgent creates a new QueryAgent

func (*QueryAgent) Execute

func (a *QueryAgent) Execute(ctx context.Context, input interface{}) (interface{}, error)

Execute processes the query and determines if it's weave-related

func (*QueryAgent) Name

func (a *QueryAgent) Name() string

Name returns the agent's name

func (*QueryAgent) SetMCPTools

func (a *QueryAgent) SetMCPTools(tools []string)

SetMCPTools sets the available MCP tools for validation

type QueryAgentInput

type QueryAgentInput struct {
	Query string `json:"query"`
}

QueryAgentInput is input for QueryAgent

type QueryAgentOutput

type QueryAgentOutput struct {
	IsWeaveQuery bool    `json:"is_weave_query"`
	FixedQuery   string  `json:"fixed_query"`
	Intent       string  `json:"intent"` // "list", "create", "query", "delete", etc.
	Confidence   float64 `json:"confidence"`
	Reason       string  `json:"reason"`
}

QueryAgentOutput is output from QueryAgent

type ReportAgent

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

ReportAgent creates comprehensive operation reports

func NewReportAgent

func NewReportAgent(outputAgent *OutputAgent, llmClient llm.Client) *ReportAgent

NewReportAgent creates a new ReportAgent

func (*ReportAgent) Execute

func (a *ReportAgent) Execute(ctx context.Context, input interface{}) (interface{}, error)

Execute generates a report from the operation results

func (*ReportAgent) Name

func (a *ReportAgent) Name() string

Name returns the agent's name

func (*ReportAgent) PrintReport

func (a *ReportAgent) PrintReport(report *OperationReport)

PrintReport displays the operation report

type WeaveAgent

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

WeaveAgent executes weave-cli commands via MCP

func NewWeaveAgent

func NewWeaveAgent(mcpClient *mcp.Client) *WeaveAgent

NewWeaveAgent creates a new WeaveAgent

func (*WeaveAgent) Execute

func (a *WeaveAgent) Execute(ctx context.Context, input interface{}) (interface{}, error)

Execute executes a weave command via MCP

func (*WeaveAgent) InferMissingArguments

func (a *WeaveAgent) InferMissingArguments(tool string, args map[string]interface{}, context map[string]interface{}) map[string]interface{}

InferMissingArguments attempts to infer missing arguments from context

func (*WeaveAgent) Name

func (a *WeaveAgent) Name() string

Name returns the agent's name

func (*WeaveAgent) SetVerbose added in v0.3.1

func (a *WeaveAgent) SetVerbose(verbose bool)

SetVerbose sets verbose mode for debug logging

func (*WeaveAgent) ValidateArguments

func (a *WeaveAgent) ValidateArguments(tool string, args map[string]interface{}) error

ValidateArguments validates that required arguments are present

type WeaveAgentCommand

type WeaveAgentCommand struct {
	Tool      string                 `json:"tool"`
	Arguments map[string]interface{} `json:"arguments"`
	Timeout   time.Duration          `json:"timeout,omitempty"`
}

WeaveAgentCommand represents a weave-cli command to execute

type WeaveAgentResult

type WeaveAgentResult struct {
	Success  bool          `json:"success"`
	Output   interface{}   `json:"output"`
	Error    string        `json:"error,omitempty"`
	Duration time.Duration `json:"duration"`
	Retries  int           `json:"retries"`
}

WeaveAgentResult represents result of weave command execution

Jump to

Keyboard shortcuts

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