Documentation
¶
Index ¶
- func CalculateSuccessRate(metrics []*EvaluationMetrics) float64
- func ClassifyFileType(filename string) string
- func FormatDuration(d time.Duration) string
- func GetAverageLatency(metrics []*EvaluationMetrics) time.Duration
- func GetCostEstimate(plan *ExecutionPlan, model string) float64
- func ParseFileList(output string) []string
- func ParseJSONResponse(response string, target interface{}) error
- type Agent
- type BashAgent
- func (a *BashAgent) CheckToolInstalled(ctx context.Context, tool string) (bool, error)
- func (a *BashAgent) Execute(ctx context.Context, input interface{}) (interface{}, error)
- func (a *BashAgent) Name() string
- func (a *BashAgent) SetOutputAgent(outputAgent *OutputAgent)
- func (a *BashAgent) SuggestInstallation(tool string) string
- type BashCommand
- type BashResult
- type CommandReport
- type EvalAgent
- type EvaluationMetrics
- type ExecutionPlan
- type ExecutionStep
- type OperationReport
- type OutputAgent
- func (a *OutputAgent) AskConfirmation(message string) (bool, error)
- func (a *OutputAgent) CreateProgressBar(max int, description string) *progressbar.ProgressBar
- func (a *OutputAgent) Execute(ctx context.Context, input interface{}) (interface{}, error)
- func (a *OutputAgent) Name() string
- func (a *OutputAgent) PrintCommandOutput(output string)
- func (a *OutputAgent) PrintCommandResult(report *CommandReport)
- func (a *OutputAgent) PrintError(message string)
- func (a *OutputAgent) PrintInfo(message string)
- func (a *OutputAgent) PrintMetrics(metrics *EvaluationMetrics)
- func (a *OutputAgent) PrintPlan(plan *ExecutionPlan)
- func (a *OutputAgent) PrintRejectionMessage(reason string)
- func (a *OutputAgent) PrintStepCompletion(stepNum int, duration time.Duration)
- func (a *OutputAgent) PrintStepError(stepNum int, errMsg string)
- func (a *OutputAgent) PrintStepProgress(stepNum int, step *ExecutionStep, status string)
- func (a *OutputAgent) PrintSuccess(message string)
- func (a *OutputAgent) PrintWarning(message string)
- type OutputConfig
- type PlanningAgent
- type PlanningAgentInput
- type QueryAgent
- type QueryAgentInput
- type QueryAgentOutput
- type ReportAgent
- type WeaveAgent
- func (a *WeaveAgent) Execute(ctx context.Context, input interface{}) (interface{}, error)
- func (a *WeaveAgent) InferMissingArguments(tool string, args map[string]interface{}, context map[string]interface{}) map[string]interface{}
- func (a *WeaveAgent) Name() string
- func (a *WeaveAgent) SetVerbose(verbose bool)
- func (a *WeaveAgent) ValidateArguments(tool string, args map[string]interface{}) error
- type WeaveAgentCommand
- type WeaveAgentResult
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 ¶
ClassifyFileType classifies a file based on its extension
func FormatDuration ¶
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 ¶
ParseFileList parses output from ls command into file list
func ParseJSONResponse ¶
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 (*BashAgent) CheckToolInstalled ¶
CheckToolInstalled checks if a tool is installed
func (*BashAgent) SetOutputAgent ¶
func (a *BashAgent) SetOutputAgent(outputAgent *OutputAgent)
SetOutputAgent sets the output agent for user interaction
func (*BashAgent) SuggestInstallation ¶
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 ¶
NewEvalAgent creates a new EvalAgent
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) 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
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) 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) 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) 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