toolcoordinator

package
v0.182.1 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package toolcoordinator owns the UI side of the tool round-trip - the streaming-status events emitted while the model is producing a tool call, the approval handshake that forwards the user's accept/reject back to the agent, and the execution-progress events while the tool runs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Coordinator

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

Coordinator handles the tool round-trip UI flow.

func NewCoordinator

func NewCoordinator(opts Options) *Coordinator

NewCoordinator creates a new tool execution coordinator.

func (*Coordinator) GetActiveToolCallID

func (c *Coordinator) GetActiveToolCallID() string

GetActiveToolCallID returns the currently active tool call id (thread-safe).

func (*Coordinator) HandleToolApprovalRequested

func (c *Coordinator) HandleToolApprovalRequested(msg agentdomain.ToolApprovalRequestedEvent) tea.Cmd

HandleToolApprovalRequested records the pending tool call in the repo, sets up the approval UI state, broadcasts a notification, and keeps the chat listener pumping while the user decides.

func (*Coordinator) HandleToolApprovalResponse

func (c *Coordinator) HandleToolApprovalResponse(msg agentdomain.ToolApprovalResponseEvent) tea.Cmd

HandleToolApprovalResponse processes the user's accept/reject decision and forwards it to the waiting agent through the response channel.

func (*Coordinator) HandleToolCallReady

func (c *Coordinator) HandleToolCallReady(_ agentdomain.ToolCallReadyEvent) tea.Cmd

HandleToolCallReady refreshes history when a tool call has finished streaming and is ready for the next step.

func (*Coordinator) HandleToolCallUpdate

func (c *Coordinator) HandleToolCallUpdate(msg agentdomain.ToolCallUpdateEvent) tea.Cmd

HandleToolCallUpdate emits a per-tool-call status update during streaming (e.g. "Streaming Read..." → "Completed Read") and keeps the chat listener pumping.

func (*Coordinator) HandleToolCancelled

func (c *Coordinator) HandleToolCancelled(_ agentdomain.ToolCancelledEvent) tea.Cmd

HandleToolCancelled refreshes the conversation view so the synthetic [cancelled] tool entry that the integrity validator persisted becomes visible. No status-bar message - the cancel that triggered this already drove its own status ("User interrupted").

func (*Coordinator) HandleToolExecutionCompleted

func (c *Coordinator) HandleToolExecutionCompleted(msg agentdomain.ToolExecutionCompletedEvent) tea.Cmd

HandleToolExecutionCompleted finalizes the tool round-trip: clears the active-tool indicator, refreshes history, optionally fires a todo-update command, and emits a "Tools completed" status. The "preparing response" spinner only makes sense when an agent turn will follow; without an active chat session (extension-initiated tool calls) the status resets to idle, since no response will ever arrive to clear it.

func (*Coordinator) HandleToolExecutionProgress

func (c *Coordinator) HandleToolExecutionProgress(msg agentdomain.ToolExecutionProgressEvent) tea.Cmd

HandleToolExecutionProgress translates a tool-execution progress event into the appropriate UI status updates and keeps the right event channel pumping (bash, tool, or chat).

func (*Coordinator) HandleToolExecutionStarted

func (c *Coordinator) HandleToolExecutionStarted(msg tui.ToolExecutionStartedEvent) tea.Cmd

HandleToolExecutionStarted emits the initial "Starting tool execution" status.

func (*Coordinator) SetActiveToolCallID

func (c *Coordinator) SetActiveToolCallID(id string)

SetActiveToolCallID sets the currently active tool call id (thread-safe).

type Options

type Options struct {
	ConversationRepo convdomain.ConversationRepository
	StateManager     stateManager
	DirectExec       tui.DirectExecutionService
	Listener         tui.ChatEventListener
}

Options bundles the dependencies needed to construct a Coordinator.

Jump to

Keyboard shortcuts

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