agent

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package agent provides tool definitions and handlers for wetwire-core-go integration. These tools are used by the RunnerAgent to execute CLI commands for AI-assisted pipeline design and persona-based testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Timestamp time.Time      `json:"timestamp"`
	Type      string         `json:"type"` // "tool_call", "tool_result", "message", "error"
	Tool      string         `json:"tool,omitempty"`
	Args      map[string]any `json:"args,omitempty"`
	Result    *ToolResult    `json:"result,omitempty"`
	Message   string         `json:"message,omitempty"`
}

Event represents an event in a session.

type Metrics

type Metrics struct {
	TotalToolCalls int            `json:"total_tool_calls"`
	ToolCallCounts map[string]int `json:"tool_call_counts,omitempty"`
	LintCycles     int            `json:"lint_cycles"`
	BuildAttempts  int            `json:"build_attempts"`
	Duration       time.Duration  `json:"duration"`
}

Metrics holds session metrics.

type Param

type Param struct {
	Type        string   `json:"type"`
	Description string   `json:"description"`
	Enum        []string `json:"enum,omitempty"`
	Default     any      `json:"default,omitempty"`
}

Param represents a tool parameter.

type Score

type Score struct {
	Overall    float64            `json:"overall"`
	Categories map[string]float64 `json:"categories,omitempty"`
	Feedback   []string           `json:"feedback,omitempty"`
}

Score holds evaluation scores for a session.

type Session

type Session struct {
	ID        string         `json:"id"`
	Type      string         `json:"type"` // "design" or "test"
	StartTime time.Time      `json:"start_time"`
	EndTime   time.Time      `json:"end_time,omitempty"`
	Persona   string         `json:"persona,omitempty"`
	Config    map[string]any `json:"config,omitempty"`
	Events    []Event        `json:"events,omitempty"`
	Result    *SessionResult `json:"result,omitempty"`
}

Session represents an agent session for design or testing.

func LoadSession

func LoadSession(path string) (*Session, error)

LoadSession loads a session from a file.

func NewSession

func NewSession(id, sessionType string) *Session

NewSession creates a new session.

func (*Session) AddError

func (s *Session) AddError(err string)

AddError adds an error event.

func (*Session) AddEvent

func (s *Session) AddEvent(event Event)

AddEvent adds an event to the session.

func (*Session) AddMessage

func (s *Session) AddMessage(message string)

AddMessage adds a message event.

func (*Session) AddToolCall

func (s *Session) AddToolCall(tool string, args map[string]any)

AddToolCall adds a tool call event.

func (*Session) AddToolResult

func (s *Session) AddToolResult(tool string, result ToolResult)

AddToolResult adds a tool result event.

func (*Session) End

func (s *Session) End(result *SessionResult)

End marks the session as complete.

func (*Session) SaveTo

func (s *Session) SaveTo(path string) error

SaveTo writes the session to a file.

type SessionResult

type SessionResult struct {
	Success      bool     `json:"success"`
	Message      string   `json:"message,omitempty"`
	FilesCreated []string `json:"files_created,omitempty"`
	Score        *Score   `json:"score,omitempty"`
	Metrics      *Metrics `json:"metrics,omitempty"`
}

SessionResult holds the final result of a session.

type Tool

type Tool struct {
	Name        string           `json:"name"`
	Description string           `json:"description"`
	Parameters  map[string]Param `json:"parameters"`
	Required    []string         `json:"required,omitempty"`
}

Tool represents a tool that can be executed by the RunnerAgent.

func GetTools

func GetTools() []Tool

GetTools returns all available tools for the RunnerAgent.

type ToolHandler

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

ToolHandler handles tool execution.

func NewToolHandler

func NewToolHandler(wetwireBin string) *ToolHandler

NewToolHandler creates a new tool handler. If wetwireBin is empty, it attempts to find the binary in PATH.

func (*ToolHandler) Execute

func (h *ToolHandler) Execute(toolName string, args map[string]any) ToolResult

Execute runs a tool with the given arguments.

type ToolResult

type ToolResult struct {
	Success bool   `json:"success"`
	Output  string `json:"output,omitempty"`
	Error   string `json:"error,omitempty"`
}

ToolResult holds the result of executing a tool.

Jump to

Keyboard shortcuts

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