directexec

package
v0.171.2 Latest Latest
Warning

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

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

Documentation

Overview

Package directexec owns the UI side of user-typed direct-execution commands: `!command` (bash) and `!!Tool(...)` (tool). It synthesizes the conversation entries that wrap each invocation, spawns the goroutine that runs the tool, owns the per-invocation event channel that pipes progress/output back to the Bubble Tea loop, and acts as the BashDetachChannelHolder the agent core looks up via context.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	ConversationRepo       domain.ConversationRepository
	ToolService            domain.ToolService
	StateManager           stateManager
	BackgroundShellService domain.BackgroundShellService
	Listener               domain.ChatEventListener
}

Options bundles the dependencies needed to construct a Service.

type Service

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

Service is the concrete DirectExecutionService.

func NewService

func NewService(opts Options) *Service

NewService creates a new DirectExecutionService.

func (*Service) ClearBashDetachChan

func (s *Service) ClearBashDetachChan()

ClearBashDetachChan satisfies domain.BashDetachChannelHolder.

func (*Service) GetBashDetachChan

func (s *Service) GetBashDetachChan() chan<- struct{}

GetBashDetachChan satisfies domain.BashDetachChannelHolder.

func (*Service) HandleBackgroundShellRequest

func (s *Service) HandleBackgroundShellRequest() tea.Cmd

HandleBackgroundShellRequest signals the currently-running bash command to detach to the background.

func (*Service) HandleBashCommand

func (s *Service) HandleBashCommand(commandText string) tea.Cmd

HandleBashCommand processes bash commands starting with `!`. A trailing `&` hands the command off to the background-shell service; otherwise it executes in the foreground with progress events piped over the bash event channel.

func (*Service) HandleBashCommandCompleted

func (s *Service) HandleBashCommandCompleted(msg domain.BashCommandCompletedEvent) tea.Cmd

HandleBashCommandCompleted handles the terminal event for a foreground bash run: refreshes history, surfaces an error message if the run failed, and (for user-initiated `!command` runs) emits a UserInputEvent to trigger auto-fix.

func (*Service) HandleBashOutputChunk

func (s *Service) HandleBashOutputChunk(_ domain.BashOutputChunkEvent) tea.Cmd

HandleBashOutputChunk is invoked after a bash output chunk reaches the UI. It keeps the bash event channel pumping until the command completes; if no bash channel is active, it falls back to the chat event channel.

func (*Service) HandleToolCommand

func (s *Service) HandleToolCommand(commandText string) tea.Cmd

HandleToolCommand processes user-typed `!!ToolName(arg="value")` commands. Parses the syntax, validates the tool is enabled, and dispatches to an async executor.

func (*Service) ParseArguments

func (s *Service) ParseArguments(argsStr string) (map[string]any, error)

ParseArguments parses function arguments in the format key="value", key2="value2". Numeric values are stored as float64; everything else as string.

func (*Service) ParseToolCall

func (s *Service) ParseToolCall(input string) (string, map[string]any, error)

ParseToolCall parses a tool call in the format ToolName(arg="value", arg2="value2"). Exposed for testing and for use by the orchestrator that satisfies the legacy domain.ChatHandler interface.

func (*Service) PendingBashChannel

func (s *Service) PendingBashChannel() <-chan tea.Msg

PendingBashChannel returns the in-flight bash event channel (or nil if no bash command is currently executing). The ToolExecutionCoordinator reads this to know which channel to keep pumping in handleBashOutputChunk / handleToolExecutionProgress.

func (*Service) PendingToolChannel

func (s *Service) PendingToolChannel() <-chan tea.Msg

PendingToolChannel returns the in-flight tool event channel (or nil if no !!tool command is currently executing).

func (*Service) SetBashDetachChan

func (s *Service) SetBashDetachChan(ch chan<- struct{})

SetBashDetachChan satisfies domain.BashDetachChannelHolder.

Jump to

Keyboard shortcuts

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