Documentation
¶
Index ¶
- func Run(ctx context.Context, ag *adk.ChatModelAgent, messages []adk.Message, ...) string
- type ApprovalState
- func (s *ApprovalState) GetMode() handler.ApprovalMode
- func (s *ApprovalState) NewTeammateApprovalFunc(workerName, workerColor string) func(ctx context.Context, toolName, toolArgs string) (bool, error)
- func (s *ApprovalState) RequestApproval(ctx context.Context, toolName, toolArgs string) (bool, error)
- func (s *ApprovalState) SetHandler(h handler.AgentEventHandler)
- func (s *ApprovalState) SetMode(mode handler.ApprovalMode)
- func (s *ApprovalState) SetSessionApproval(enabled bool)
- func (s *ApprovalState) SetWorkpath(path string)
- type Event
- type EventBus
- type EventType
- type ToolCallEvent
- type ToolResultEvent
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Run ¶
func Run( ctx context.Context, ag *adk.ChatModelAgent, messages []adk.Message, h handler.AgentEventHandler, rec *session.Recorder, todoStore *tools.TodoStore, tracer *telemetry.LangfuseTracer, tokenUsage *internalmodel.TokenUsage, ) string
Run executes the agent for a single turn, wrapping the response with a Langfuse trace when a tracer is present, enforcing todo-completion guards, and sending token-usage updates to the handler when done.
Types ¶
type ApprovalState ¶
type ApprovalState struct {
// contains filtered or unexported fields
}
ApprovalState manages whether tool calls require interactive user approval.
func NewApprovalState ¶
func NewApprovalState(workpath string, autoApprove bool) *ApprovalState
NewApprovalState creates a new ApprovalState with the given workpath.
func (*ApprovalState) GetMode ¶
func (s *ApprovalState) GetMode() handler.ApprovalMode
GetMode returns the current approval mode.
func (*ApprovalState) NewTeammateApprovalFunc ¶
func (s *ApprovalState) NewTeammateApprovalFunc(workerName, workerColor string) func(ctx context.Context, toolName, toolArgs string) (bool, error)
NewTeammateApprovalFunc creates an approval function for a teammate that includes the worker identity in the TUI approval prompt.
func (*ApprovalState) RequestApproval ¶
func (s *ApprovalState) RequestApproval(ctx context.Context, toolName, toolArgs string) (bool, error)
RequestApproval is the agent.ApprovalFunc implementation. It returns true immediately for read-only or obviously safe commands. For everything else it sends a TUI prompt and waits for the user's answer.
func (*ApprovalState) SetHandler ¶
func (s *ApprovalState) SetHandler(h handler.AgentEventHandler)
SetHandler stores the handler used to send approval-request messages.
func (*ApprovalState) SetMode ¶
func (s *ApprovalState) SetMode(mode handler.ApprovalMode)
SetMode sets the approval mode (used for external mode changes).
func (*ApprovalState) SetSessionApproval ¶
func (s *ApprovalState) SetSessionApproval(enabled bool)
SetSessionApproval sets the approval mode based on the boolean value. This is kept for backward compatibility with the channel-based mode sync.
func (*ApprovalState) SetWorkpath ¶
func (s *ApprovalState) SetWorkpath(path string)
SetWorkpath sets the current working directory (called on environment switch).
type Event ¶
type Event struct {
Type EventType
Text string
ToolCall *ToolCallEvent
ToolResult *ToolResultEvent
Error error
Meta map[string]any
}
Event is the unit of data emitted by the agent loop.
type EventBus ¶
type EventBus struct {
// contains filtered or unexported fields
}
EventBus is a channel-based event bus for streaming agent loop events to the TUI and other consumers.
func NewEventBus ¶
NewEventBus creates an event bus with the given channel buffer size.
func (*EventBus) Close ¶
func (eb *EventBus) Close()
Close shuts down the event bus. Safe to call multiple times.
func (*EventBus) Done ¶
func (eb *EventBus) Done() <-chan struct{}
Done returns a channel that is closed when the event bus is shut down.
type ToolCallEvent ¶
ToolCallEvent describes a tool invocation.
type ToolResultEvent ¶
ToolResultEvent describes a tool's result.