worker

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentState

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

AgentState holds the current state of an agent

func NewAgentState

func NewAgentState() *AgentState

NewAgentState creates a new agent state

func (*AgentState) CompleteTask

func (s *AgentState) CompleteTask()

CompleteTask transitions to available state

func (*AgentState) Get

func (s *AgentState) Get() State

Get returns the current state

func (*AgentState) GetCurrentTask

func (s *AgentState) GetCurrentTask() string

GetCurrentTask returns the current task description

func (*AgentState) GetStatus

func (s *AgentState) GetStatus() string

GetStatus returns a human-readable status message

func (*AgentState) GetTaskDuration

func (s *AgentState) GetTaskDuration() time.Duration

GetTaskDuration returns how long the current task has been running

func (*AgentState) IsAvailable

func (s *AgentState) IsAvailable() bool

IsAvailable returns true if the agent is available

func (*AgentState) IsWorking

func (s *AgentState) IsWorking() bool

IsWorking returns true if the agent is currently working

func (*AgentState) StartTask

func (s *AgentState) StartTask(description string)

StartTask transitions to working state

type ChatRequest

type ChatRequest struct {
	Input    string
	Response chan<- ChatResponse
}

ChatRequest represents a chat/conversation request

type ChatResponse

type ChatResponse struct {
	Content string
	Elapsed time.Duration
	Err     error
}

ChatResponse is the response to a chat request

type Pool

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

Pool manages multiple workers

func NewPool

func NewPool() *Pool

NewPool creates a new worker pool

func (*Pool) Add

func (p *Pool) Add(w *Worker)

Add adds a worker to the pool

func (*Pool) All

func (p *Pool) All() []string

All returns all worker names

func (*Pool) Get

func (p *Pool) Get(name string) (*Worker, bool)

Get returns a worker by name

func (*Pool) GetStatus

func (p *Pool) GetStatus() map[string]string

GetStatus returns the status of all workers

func (*Pool) StartAll

func (p *Pool) StartAll()

StartAll starts all workers

func (*Pool) StopAll

func (p *Pool) StopAll()

StopAll stops all workers

type State

type State int

State represents the current state of an agent

const (
	// StateAvailable means the agent can accept new tasks
	StateAvailable State = iota
	// StateWorking means the agent is currently executing a task
	StateWorking
)

func (State) String

func (s State) String() string

type TaskRequest

type TaskRequest struct {
	Description string
	Prompt      string
	Response    chan<- TaskResponse
}

TaskRequest represents a work task request

type TaskResponse

type TaskResponse struct {
	Content string
	Elapsed time.Duration
	Err     error
}

TaskResponse is the response to a task request

type Worker

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

Worker manages an agent's chat and task goroutines

func NewWorker

func NewWorker(name string, runner *agent.Runner) *Worker

NewWorker creates a new worker for an agent

func (*Worker) Name

func (w *Worker) Name() string

Name returns the worker's name

func (*Worker) SendChat

func (w *Worker) SendChat(input string, response chan<- ChatResponse)

SendChat sends a chat request and returns immediately The response will be sent to the provided channel

func (*Worker) SendTask

func (w *Worker) SendTask(description, prompt string, response chan<- TaskResponse)

SendTask sends a task request and returns immediately

func (*Worker) SetPromptBuilder

func (w *Worker) SetPromptBuilder(fn func(agentName, input string) string)

SetPromptBuilder sets the callback for building prompts

func (*Worker) Start

func (w *Worker) Start()

Start begins the chat and task goroutines

func (*Worker) State

func (w *Worker) State() *AgentState

State returns the agent's current state

func (*Worker) Stop

func (w *Worker) Stop()

Stop gracefully shuts down the worker

Jump to

Keyboard shortcuts

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