executor

package
v5.0.3 Latest Latest
Warning

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

Go to latest
Published: May 29, 2026 License: MIT Imports: 47 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildBuiltinVariables added in v5.0.1

func BuildBuiltinVariables(cfg *config.Config, params map[string]string) map[string]interface{}

func BuildPrompt added in v5.0.1

func BuildPrompt(step *core.Step) string

BuildPrompt builds the prompt string from step messages. It joins all message Content fields (string only) with newlines.

func DetectCloudProvider added in v5.0.1

func DetectCloudProvider() string

DetectCloudProvider detects cloud providers via DMI information. Returns the provider name (e.g. "aws", "gcp"), "on-prem" if no provider is detected, or "unknown" if DMI information cannot be read at all.

func DetectDocker added in v5.0.1

func DetectDocker() bool

DetectDocker checks if running inside a Docker container

func DetectKubernetes added in v5.0.1

func DetectKubernetes() bool

DetectKubernetes checks if running inside a Kubernetes pod

func ExportModuleWorkflowState

func ExportModuleWorkflowState(folder string, moduleName string, workflow *core.Workflow) error

ExportModuleWorkflowState writes a module workflow YAML to the modules folder

func ExportRunCompleted

func ExportRunCompleted(path string, result *core.WorkflowResult, execCtx *core.ExecutionContext) error

ExportRunCompleted writes run completion state to a JSON file Uses the same format as run-state.json (StateExport) for consistency

func ExportState

func ExportState(stateFile string, result *core.WorkflowResult, execCtx *core.ExecutionContext) error

ExportState exports the current run state to a JSON file It uses database data if available, otherwise falls back to in-memory data from result and execCtx

func ExportWorkflowState

func ExportWorkflowState(stateFile string, workflow *core.Workflow) error

ExportWorkflowState writes the workflow YAML to the state file

func IsBuiltinAgent added in v5.0.2

func IsBuiltinAgent(name string) bool

IsBuiltinAgent returns true if the given name is a built-in ACP agent.

func ListAgentNames added in v5.0.1

func ListAgentNames() []string

ListAgentNames returns the names of all built-in ACP agents.

func ListSDKAgentNames added in v5.0.2

func ListSDKAgentNames() []string

ListSDKAgentNames returns the names of all supported SDK agents.

func RegisterArtifacts

func RegisterArtifacts(workflow *core.Workflow, execCtx *core.ExecutionContext, runID int64, logger *zap.Logger) ([]string, error)

RegisterArtifacts registers workflow reports and state files as artifacts in the database and returns the collected artifact file paths. runID is the integer Run.ID used as a foreign key for artifacts. Path collection happens regardless of whether the database is available, so callers can always populate WorkflowResult.Artifacts.

func RemoveRunCompleted

func RemoveRunCompleted(path string)

RemoveRunCompleted removes the run-completed.json file if it exists

func ResolveAgent added in v5.0.1

func ResolveAgent(step *core.Step) (command string, args []string, err error)

ResolveAgent resolves the agent command and args from step configuration. It checks step.Agent against the built-in registry first, then falls back to step.ACPConfig.Command/Args for custom agents.

func RunAgentACP added in v5.0.1

func RunAgentACP(ctx context.Context, prompt, agentName string, cfg *RunAgentACPConfig) (string, string, error)

RunAgentACP spawns an ACP agent subprocess and returns its output. agentName can be a built-in name ("claude-code", "codex", etc.) or empty to use the default ("claude-code"). Returns (stdout, stderr, error).

Types

type ACPExecutor added in v5.0.1

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

ACPExecutor implements StepExecutorPlugin for agent-acp steps. It spawns an AI coding agent as a subprocess, communicates over stdin/stdout using the Agent Communication Protocol (ACP), and collects the output.

func NewACPExecutor added in v5.0.1

func NewACPExecutor(engine template.TemplateEngine) *ACPExecutor

NewACPExecutor creates a new ACP executor.

func (*ACPExecutor) Execute added in v5.0.1

func (e *ACPExecutor) Execute(ctx context.Context, step *core.Step, execCtx *core.ExecutionContext) (*core.StepResult, error)

Execute runs an agent-acp step.

func (*ACPExecutor) Name added in v5.0.1

func (e *ACPExecutor) Name() string

Name returns the executor name for logging/debugging.

func (*ACPExecutor) StepTypes added in v5.0.1

func (e *ACPExecutor) StepTypes() []core.StepType

StepTypes returns the step types this executor handles.

type ActiveRun added in v5.0.1

type ActiveRun struct {
	RunUUID      string
	Ctx          context.Context // cancellable context bound to this run
	Cancel       context.CancelFunc
	PIDs         *sync.Map // map[int]struct{} - currently running PIDs
	TmuxSessions *sync.Map // map[string]struct{} - tmux sessions spawned by tmux_run
	StartedAt    time.Time
}

ActiveRun represents a currently executing workflow run

func (*ActiveRun) AddPID added in v5.0.1

func (a *ActiveRun) AddPID(pid int)

AddPID adds a process ID to this run's tracked PIDs

func (*ActiveRun) AddTmuxSession added in v5.0.3

func (a *ActiveRun) AddTmuxSession(name string)

AddTmuxSession records a tmux session name spawned during this run.

func (*ActiveRun) KillAllPIDs added in v5.0.1

func (a *ActiveRun) KillAllPIDs() []int

KillAllPIDs sends SIGKILL to all tracked PIDs and returns the list of killed PIDs

func (*ActiveRun) KillAllTmuxSessions added in v5.0.3

func (a *ActiveRun) KillAllTmuxSessions() []string

KillAllTmuxSessions issues `tmux kill-session` for every tracked session and returns the list of session names it attempted to kill. Errors are swallowed because best-effort cleanup is preferred over aborting cancellation.

func (*ActiveRun) RemovePID added in v5.0.1

func (a *ActiveRun) RemovePID(pid int)

RemovePID removes a process ID from this run's tracked PIDs

func (*ActiveRun) RemoveTmuxSession added in v5.0.3

func (a *ActiveRun) RemoveTmuxSession(name string)

RemoveTmuxSession drops a tmux session name from tracking (e.g. on tmux_kill).

type AgentExecutor added in v5.0.1

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

AgentExecutor implements the agentic loop for type: agent steps. It queries the LLM, handles tool calls by executing them via the ToolExecutorRegistry, feeds results back, and repeats until the LLM responds without tool calls or the max_iterations limit is reached.

func NewAgentExecutor added in v5.0.1

func NewAgentExecutor(engine template.TemplateEngine, funcRegistry *functions.Registry) *AgentExecutor

NewAgentExecutor creates a new agent executor

func (*AgentExecutor) Execute added in v5.0.1

func (e *AgentExecutor) Execute(ctx context.Context, step *core.Step, execCtx *core.ExecutionContext) (*core.StepResult, error)

Execute runs the agent loop

func (*AgentExecutor) Name added in v5.0.1

func (e *AgentExecutor) Name() string

Name returns the executor name

func (*AgentExecutor) SetConfig added in v5.0.1

func (e *AgentExecutor) SetConfig(cfg *config.Config)

SetConfig sets the application config

func (*AgentExecutor) SetDepthContext added in v5.0.1

func (e *AgentExecutor) SetDepthContext(depth, maxDepth int)

SetDepthContext sets the current nesting depth and maximum allowed depth.

func (*AgentExecutor) SetSilent added in v5.0.1

func (e *AgentExecutor) SetSilent(s bool)

SetSilent enables or disables silent mode

func (*AgentExecutor) StepTypes added in v5.0.1

func (e *AgentExecutor) StepTypes() []core.StepType

StepTypes returns the step types this executor handles

type BashExecutor

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

BashExecutor executes bash steps

func NewBashExecutor

func NewBashExecutor(engine template.TemplateEngine) *BashExecutor

NewBashExecutor creates a new bash executor

func (*BashExecutor) CanHandle

func (e *BashExecutor) CanHandle(stepType core.StepType) bool

CanHandle returns true if this executor can handle the given step type

func (*BashExecutor) Execute

func (e *BashExecutor) Execute(ctx context.Context, step *core.Step, execCtx *core.ExecutionContext) (*core.StepResult, error)

Execute executes a bash step

func (*BashExecutor) Name

func (e *BashExecutor) Name() string

Name returns the executor name for logging/debugging

func (*BashExecutor) SetRunner

func (e *BashExecutor) SetRunner(r runner.Runner)

SetRunner sets the runner for command execution

func (*BashExecutor) StepTypes

func (e *BashExecutor) StepTypes() []core.StepType

StepTypes returns the step types this executor handles

type ChatChoice

type ChatChoice struct {
	Index        int         `json:"index"`
	Message      ChatMessage `json:"message"`
	FinishReason string      `json:"finish_reason"`
}

ChatChoice represents a single choice in the response

type ChatCompletionRequest

type ChatCompletionRequest struct {
	Model          string                  `json:"model"`
	Messages       []ChatMessage           `json:"messages"`
	MaxTokens      int                     `json:"max_tokens,omitempty"`
	Temperature    float64                 `json:"temperature,omitempty"`
	TopP           float64                 `json:"top_p,omitempty"`
	TopK           int                     `json:"top_k,omitempty"`
	N              int                     `json:"n,omitempty"`
	Stream         bool                    `json:"stream,omitempty"`
	Tools          []core.LLMTool          `json:"tools,omitempty"`
	ToolChoice     interface{}             `json:"tool_choice,omitempty"`
	ResponseFormat *core.LLMResponseFormat `json:"response_format,omitempty"`
}

ChatCompletionRequest is the OpenAI-compatible request format

type ChatCompletionResponse

type ChatCompletionResponse struct {
	ID      string       `json:"id"`
	Object  string       `json:"object"`
	Created int64        `json:"created"`
	Model   string       `json:"model"`
	Choices []ChatChoice `json:"choices"`
	Usage   ChatUsage    `json:"usage"`
	Error   *ChatError   `json:"error,omitempty"`
}

ChatCompletionResponse is the OpenAI-compatible response format

type ChatCompletionStreamChunk added in v5.0.1

type ChatCompletionStreamChunk struct {
	ID      string              `json:"id"`
	Object  string              `json:"object"`
	Created int64               `json:"created"`
	Model   string              `json:"model"`
	Choices []StreamChunkChoice `json:"choices"`
	Usage   *ChatUsage          `json:"usage,omitempty"`
	Error   *ChatError          `json:"error,omitempty"`
}

ChatCompletionStreamChunk is a single SSE event in a streaming response

type ChatDelta added in v5.0.1

type ChatDelta struct {
	Role      string           `json:"role,omitempty"`
	Content   string           `json:"content,omitempty"`
	ToolCalls []StreamToolCall `json:"tool_calls,omitempty"`
}

ChatDelta contains incremental content from streaming

type ChatError

type ChatError struct {
	Message string `json:"message"`
	Type    string `json:"type"`
	Code    string `json:"code"`
}

ChatError represents an error in the API response

type ChatMessage

type ChatMessage struct {
	Role       string             `json:"role"`
	Content    interface{}        `json:"content"` // string or []ContentPart
	Name       string             `json:"name,omitempty"`
	ToolCallID string             `json:"tool_call_id,omitempty"`
	ToolCalls  []core.LLMToolCall `json:"tool_calls,omitempty"`
}

ChatMessage is the wire format for messages

type ChatUsage

type ChatUsage struct {
	PromptTokens     int `json:"prompt_tokens"`
	CompletionTokens int `json:"completion_tokens"`
	TotalTokens      int `json:"total_tokens"`
}

ChatUsage represents token usage in the response

type CustomToolExecutor added in v5.0.1

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

CustomToolExecutor wraps a custom tool with a JS handler expression

func NewCustomToolExecutor added in v5.0.1

func NewCustomToolExecutor(name, handler string, registry *functions.Registry) *CustomToolExecutor

NewCustomToolExecutor creates a custom tool executor

func (*CustomToolExecutor) Execute added in v5.0.1

func (e *CustomToolExecutor) Execute(_ context.Context, args map[string]interface{}, execCtx *core.ExecutionContext) (string, error)

Execute runs the custom tool handler JS expression

func (*CustomToolExecutor) Name added in v5.0.1

func (e *CustomToolExecutor) Name() string

Name returns the tool name

type EmbeddingData

type EmbeddingData struct {
	Object    string    `json:"object"`
	Embedding []float64 `json:"embedding"`
	Index     int       `json:"index"`
}

EmbeddingData represents a single embedding in the response

type EmbeddingRequest

type EmbeddingRequest struct {
	Model          string   `json:"model"`
	Input          []string `json:"input"`
	EncodingFormat string   `json:"encoding_format,omitempty"`
}

EmbeddingRequest represents a request for embeddings

type EmbeddingResponse

type EmbeddingResponse struct {
	Object string          `json:"object"`
	Data   []EmbeddingData `json:"data"`
	Model  string          `json:"model"`
	Usage  struct {
		PromptTokens int `json:"prompt_tokens"`
		TotalTokens  int `json:"total_tokens"`
	} `json:"usage"`
	Error *ChatError `json:"error,omitempty"`
}

EmbeddingResponse represents the response from embeddings API

type Executor

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

Executor is the main workflow executor

func NewExecutor

func NewExecutor() *Executor

NewExecutor creates a new workflow executor

func (*Executor) ExecuteFlow

func (e *Executor) ExecuteFlow(ctx context.Context, flow *core.Workflow, params map[string]string, cfg *config.Config) (*core.WorkflowResult, error)

ExecuteFlow executes a flow workflow

func (*Executor) ExecuteModule

func (e *Executor) ExecuteModule(ctx context.Context, module *core.Workflow, params map[string]string, cfg *config.Config) (*core.WorkflowResult, error)

ExecuteModule executes a module workflow

func (*Executor) SetDBRunID

func (e *Executor) SetDBRunID(runID int64)

SetDBRunID sets the database run ID for step result foreign keys

func (*Executor) SetDBRunUUID

func (e *Executor) SetDBRunUUID(runUUID string)

SetDBRunUUID sets the database run UUID for progress tracking

func (*Executor) SetDisableWorkflowState

func (e *Executor) SetDisableWorkflowState(disable bool)

SetDisableWorkflowState enables or disables workflow state file export

func (*Executor) SetDryRun

func (e *Executor) SetDryRun(dryRun bool)

SetDryRun enables or disables dry-run mode

func (*Executor) SetLoader

func (e *Executor) SetLoader(l *parser.Loader)

SetLoader sets the workflow loader for loading nested modules in flows

func (*Executor) SetOnStepCompleted

func (e *Executor) SetOnStepCompleted(callback StepCompletedCallback)

SetOnStepCompleted sets the callback for step completion

func (*Executor) SetProgressBar

func (e *Executor) SetProgressBar(pb *terminal.ProgressBar)

SetProgressBar sets the progress bar for execution display

func (*Executor) SetSchedulerInvocation

func (e *Executor) SetSchedulerInvocation(v bool)

SetSchedulerInvocation marks this execution as triggered by the scheduler When true, the manual trigger check is bypassed

func (*Executor) SetServerMode

func (e *Executor) SetServerMode(enabled bool)

SetServerMode enables server mode which adds file logging to the workspace

func (*Executor) SetSilent

func (e *Executor) SetSilent(s bool)

SetSilent enables or disables silent mode (hides step output)

func (*Executor) SetSkipValidation

func (e *Executor) SetSkipValidation(skip bool)

SetSkipValidation enables or disables target type validation

func (*Executor) SetSkipWorkspace added in v5.0.1

func (e *Executor) SetSkipWorkspace(skip bool)

SetSkipWorkspace enables or disables workspace folder creation

func (*Executor) SetSpinner

func (e *Executor) SetSpinner(show bool)

SetSpinner enables or disables spinner display

func (*Executor) SetSudoAware added in v5.0.1

func (e *Executor) SetSudoAware(aware bool)

SetSudoAware enables or disables sudo-aware mode

func (*Executor) SetVerbose

func (e *Executor) SetVerbose(v bool)

SetVerbose enables or disables verbose output (shows step stdout)

type ForeachExecutor

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

ForeachExecutor executes foreach steps

func NewForeachExecutor

func NewForeachExecutor(dispatcher *StepDispatcher, engine template.TemplateEngine, registry *functions.Registry) *ForeachExecutor

NewForeachExecutor creates a new foreach executor

func (*ForeachExecutor) CanHandle

func (e *ForeachExecutor) CanHandle(stepType core.StepType) bool

CanHandle returns true if this executor can handle the given step type

func (*ForeachExecutor) Execute

func (e *ForeachExecutor) Execute(ctx context.Context, step *core.Step, execCtx *core.ExecutionContext) (*core.StepResult, error)

Execute executes a foreach step

func (*ForeachExecutor) Name

func (e *ForeachExecutor) Name() string

Name returns the executor name for logging/debugging

func (*ForeachExecutor) StepTypes

func (e *ForeachExecutor) StepTypes() []core.StepType

StepTypes returns the step types this executor handles

type ForeachIterationError added in v5.0.1

type ForeachIterationError struct {
	Inner           error
	InputValue      string // Loop variable value that failed
	RenderedCommand string // Fully rendered command
	Output          string // stdout+stderr from failed step
}

ForeachIterationError wraps a step execution error with context about the failing foreach iteration (input value, rendered command, captured output).

func (*ForeachIterationError) Error added in v5.0.1

func (e *ForeachIterationError) Error() string

func (*ForeachIterationError) Unwrap added in v5.0.1

func (e *ForeachIterationError) Unwrap() error

type FunctionExecutor

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

FunctionExecutor executes function steps

func NewFunctionExecutor

func NewFunctionExecutor(engine template.TemplateEngine, registry *functions.Registry) *FunctionExecutor

NewFunctionExecutor creates a new function executor

func (*FunctionExecutor) CanHandle

func (e *FunctionExecutor) CanHandle(stepType core.StepType) bool

CanHandle returns true if this executor can handle the given step type

func (*FunctionExecutor) Execute

func (e *FunctionExecutor) Execute(ctx context.Context, step *core.Step, execCtx *core.ExecutionContext) (*core.StepResult, error)

Execute executes a function step

func (*FunctionExecutor) Name

func (e *FunctionExecutor) Name() string

Name returns the executor name for logging/debugging

func (*FunctionExecutor) StepTypes

func (e *FunctionExecutor) StepTypes() []core.StepType

StepTypes returns the step types this executor handles

type HTTPExecutor

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

HTTPExecutor executes HTTP steps

func NewHTTPExecutor

func NewHTTPExecutor(engine template.TemplateEngine) *HTTPExecutor

NewHTTPExecutor creates a new HTTP executor with pooled connections

func (*HTTPExecutor) CanHandle

func (e *HTTPExecutor) CanHandle(stepType core.StepType) bool

CanHandle returns true if this executor can handle the given step type

func (*HTTPExecutor) Execute

func (e *HTTPExecutor) Execute(ctx context.Context, step *core.Step, execCtx *core.ExecutionContext) (*core.StepResult, error)

Execute executes an HTTP step

func (*HTTPExecutor) Name

func (e *HTTPExecutor) Name() string

Name returns the executor name for logging/debugging

func (*HTTPExecutor) StepTypes

func (e *HTTPExecutor) StepTypes() []core.StepType

StepTypes returns the step types this executor handles

type LLMExecutor

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

LLMExecutor executes LLM steps

func NewLLMExecutor

func NewLLMExecutor(engine template.TemplateEngine) *LLMExecutor

NewLLMExecutor creates a new LLM executor

func (*LLMExecutor) CanHandle

func (e *LLMExecutor) CanHandle(stepType core.StepType) bool

CanHandle returns true if this executor can handle the given step type

func (*LLMExecutor) Execute

func (e *LLMExecutor) Execute(ctx context.Context, step *core.Step, execCtx *core.ExecutionContext) (*core.StepResult, error)

Execute executes an LLM step

func (*LLMExecutor) Name

func (e *LLMExecutor) Name() string

Name returns the executor name for logging/debugging

func (*LLMExecutor) SetConfig

func (e *LLMExecutor) SetConfig(cfg *config.Config)

SetConfig sets the application config for LLM settings

func (*LLMExecutor) SetSilent

func (e *LLMExecutor) SetSilent(s bool)

SetSilent enables or disables silent mode (suppresses output)

func (*LLMExecutor) StepTypes

func (e *LLMExecutor) StepTypes() []core.StepType

StepTypes returns the step types this executor handles

type LineIterator

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

LineIterator provides streaming access to lines in a file

func NewLineIterator

func NewLineIterator(path string) (*LineIterator, error)

NewLineIterator creates an iterator for reading lines from a file

func (*LineIterator) Close

func (it *LineIterator) Close() error

Close closes the underlying file

func (*LineIterator) Err

func (it *LineIterator) Err() error

Err returns any error encountered during iteration

func (*LineIterator) Next

func (it *LineIterator) Next() bool

Next advances to the next non-empty line, returns false when done

func (*LineIterator) Value

func (it *LineIterator) Value() string

Value returns the current line

type MergedLLMConfig

type MergedLLMConfig struct {
	Model          string
	MaxTokens      int
	Temperature    float64
	TopK           int
	TopP           float64
	N              int
	Timeout        string
	MaxRetries     int
	Stream         bool
	ResponseFormat *core.LLMResponseFormat
	CustomHeaders  map[string]string
	SystemPrompt   string
}

MergedLLMConfig holds the final merged configuration

type OrderedResultCollector added in v5.0.1

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

OrderedResultCollector preserves insertion order using step name mapping. Useful when result order must match step execution order.

func NewOrderedResultCollector added in v5.0.1

func NewOrderedResultCollector(stepNames []string) *OrderedResultCollector

NewOrderedResultCollector creates a collector that preserves step ordering

func (*OrderedResultCollector) Add added in v5.0.1

func (c *OrderedResultCollector) Add(stepName string, result *core.StepResult)

Add adds a result for a specific step

func (*OrderedResultCollector) Results added in v5.0.1

func (c *OrderedResultCollector) Results() []*core.StepResult

Results returns results in the original step order

type ParallelExecutor

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

ParallelExecutor executes parallel steps

func NewParallelExecutor

func NewParallelExecutor(dispatcher *StepDispatcher) *ParallelExecutor

NewParallelExecutor creates a new parallel executor

func (*ParallelExecutor) CanHandle

func (e *ParallelExecutor) CanHandle(stepType core.StepType) bool

CanHandle returns true if this executor can handle the given step type

func (*ParallelExecutor) Execute

func (e *ParallelExecutor) Execute(ctx context.Context, step *core.Step, execCtx *core.ExecutionContext) (*core.StepResult, error)

Execute executes a parallel step using a bounded worker pool to prevent resource exhaustion when executing many parallel steps

func (*ParallelExecutor) Name

func (e *ParallelExecutor) Name() string

Name returns the executor name for logging/debugging

func (*ParallelExecutor) StepTypes

func (e *ParallelExecutor) StepTypes() []core.StepType

StepTypes returns the step types this executor handles

type PluginRegistry

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

PluginRegistry manages registered step executor plugins. It maps step types to their corresponding plugin implementations.

func NewPluginRegistry

func NewPluginRegistry() *PluginRegistry

NewPluginRegistry creates a new plugin registry

func (*PluginRegistry) Get

func (r *PluginRegistry) Get(stepType core.StepType) (StepExecutorPlugin, bool)

Get returns the plugin for a step type, or nil if not found

func (*PluginRegistry) Has

func (r *PluginRegistry) Has(stepType core.StepType) bool

Has checks if a step type is registered

func (*PluginRegistry) ListStepTypes

func (r *PluginRegistry) ListStepTypes() []core.StepType

ListStepTypes returns all registered step types

func (*PluginRegistry) Register

func (r *PluginRegistry) Register(plugin StepExecutorPlugin)

Register adds a plugin to the registry. The plugin will be registered for all step types it reports via StepTypes().

type PresetToolExecutor added in v5.0.1

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

PresetToolExecutor wraps a preset tool and executes it via the function registry

func NewPresetToolExecutor added in v5.0.1

func NewPresetToolExecutor(name string, registry *functions.Registry) *PresetToolExecutor

NewPresetToolExecutor creates a preset tool executor

func (*PresetToolExecutor) Execute added in v5.0.1

func (e *PresetToolExecutor) Execute(_ context.Context, args map[string]interface{}, execCtx *core.ExecutionContext) (string, error)

Execute runs the preset tool by building a function call expression

func (*PresetToolExecutor) Name added in v5.0.1

func (e *PresetToolExecutor) Name() string

Name returns the tool name

type RemoteBashExecutor

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

RemoteBashExecutor executes remote-bash steps on Docker/SSH runners

func NewRemoteBashExecutor

func NewRemoteBashExecutor(engine template.TemplateEngine) *RemoteBashExecutor

NewRemoteBashExecutor creates a new remote bash executor

func (*RemoteBashExecutor) CanHandle

func (e *RemoteBashExecutor) CanHandle(stepType core.StepType) bool

CanHandle returns true if this executor can handle the given step type

func (*RemoteBashExecutor) Execute

func (e *RemoteBashExecutor) Execute(ctx context.Context, step *core.Step, execCtx *core.ExecutionContext) (*core.StepResult, error)

Execute executes a remote-bash step

func (*RemoteBashExecutor) Name

func (e *RemoteBashExecutor) Name() string

Name returns the executor name for logging/debugging

func (*RemoteBashExecutor) StepTypes

func (e *RemoteBashExecutor) StepTypes() []core.StepType

StepTypes returns the step types this executor handles

type ResultCollector added in v5.0.1

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

ResultCollector provides lock-free collection of step results for parallel execution. Uses pre-allocated slice with atomic index for O(1) appends without mutex contention.

func NewResultCollector added in v5.0.1

func NewResultCollector(stepCount int) *ResultCollector

NewResultCollector creates a collector pre-allocated for the expected number of steps

func (*ResultCollector) Add added in v5.0.1

func (c *ResultCollector) Add(result *core.StepResult) int

Add atomically adds a step result to the collector. Thread-safe without mutex - uses atomic operations. Returns the index where the result was stored.

func (*ResultCollector) Count added in v5.0.1

func (c *ResultCollector) Count() int

Count returns the number of results added

func (*ResultCollector) Results added in v5.0.1

func (c *ResultCollector) Results() []*core.StepResult

Results returns all collected results, filtering nil entries. Call this only after all goroutines have completed.

type RunAgentACPConfig added in v5.0.1

type RunAgentACPConfig struct {
	Cwd          string            // Working directory (default: ".")
	AllowedPaths []string          // Restrict file reads to these directories
	Env          map[string]string // Extra environment variables for agent process
	WriteEnabled bool              // Allow file writes (default: false)
	StreamWriter io.Writer         // Optional writer for real-time output streaming
}

RunAgentACPConfig holds options for standalone RunAgentACP calls.

type RunControlPlane added in v5.0.1

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

RunControlPlane tracks active workflow runs for cancellation support

func GetRunControlPlane added in v5.0.1

func GetRunControlPlane() *RunControlPlane

GetRunControlPlane returns the singleton run control plane

func (*RunControlPlane) AddPID added in v5.0.1

func (r *RunControlPlane) AddPID(runUUID string, pid int)

AddPID adds a PID to a run's tracked processes

func (*RunControlPlane) AddTmuxSession added in v5.0.3

func (r *RunControlPlane) AddTmuxSession(runUUID, name string)

AddTmuxSession registers a tmux session name against a run so the session can be torn down when the run is cancelled.

func (*RunControlPlane) Cancel added in v5.0.1

func (r *RunControlPlane) Cancel(runUUID string) ([]int, []string, error)

Cancel cancels a run by calling its cancel function and killing all tracked PIDs and tmux sessions. Returns the list of killed PIDs, killed tmux sessions, and any error.

func (*RunControlPlane) Count added in v5.0.1

func (r *RunControlPlane) Count() int

Count returns the number of active runs

func (*RunControlPlane) Get added in v5.0.1

func (r *RunControlPlane) Get(runUUID string) *ActiveRun

Get retrieves an active run by its UUID

func (*RunControlPlane) ListActive added in v5.0.1

func (r *RunControlPlane) ListActive() []string

ListActive returns a list of all active run UUIDs

func (*RunControlPlane) Register added in v5.0.1

func (r *RunControlPlane) Register(runUUID string, cancel context.CancelFunc) *ActiveRun

Register adds a new run to the control plane. The provided context must be the cancellable context whose CancelFunc is `cancel`; storing it lets background helpers (e.g. ssh_exec) derive their own deadlines from the run's lifetime so cancellation propagates.

func (*RunControlPlane) RegisterWithContext added in v5.0.3

func (r *RunControlPlane) RegisterWithContext(runUUID string, ctx context.Context, cancel context.CancelFunc) *ActiveRun

RegisterWithContext is like Register but also records the parent context. New callers should prefer this over Register so the stored Ctx is non-nil.

func (*RunControlPlane) RemovePID added in v5.0.1

func (r *RunControlPlane) RemovePID(runUUID string, pid int)

RemovePID removes a PID from a run's tracked processes

func (*RunControlPlane) RemoveTmuxSession added in v5.0.3

func (r *RunControlPlane) RemoveTmuxSession(runUUID, name string)

RemoveTmuxSession unregisters a tmux session name (e.g. after tmux_kill).

func (*RunControlPlane) Unregister added in v5.0.1

func (r *RunControlPlane) Unregister(runUUID string)

Unregister removes a run from the control plane

type SDKExecutor added in v5.0.2

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

SDKExecutor implements StepExecutorPlugin for agent-sdk steps. It uses the go-agent-agnostic library to run coding agents.

func NewSDKExecutor added in v5.0.2

func NewSDKExecutor(engine template.TemplateEngine) *SDKExecutor

NewSDKExecutor creates a new SDK executor.

func (*SDKExecutor) Execute added in v5.0.2

func (e *SDKExecutor) Execute(ctx context.Context, step *core.Step, execCtx *core.ExecutionContext) (*core.StepResult, error)

Execute runs an agent-sdk step.

func (*SDKExecutor) Name added in v5.0.2

func (e *SDKExecutor) Name() string

Name returns the executor name for logging/debugging.

func (*SDKExecutor) StepTypes added in v5.0.2

func (e *SDKExecutor) StepTypes() []core.StepType

StepTypes returns the step types this executor handles.

type StepCompletedCallback

type StepCompletedCallback func(ctx context.Context, runID string)

StepCompletedCallback is called after each step completes

type StepDispatcher

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

StepDispatcher dispatches steps to appropriate executors

func NewStepDispatcher

func NewStepDispatcher() *StepDispatcher

NewStepDispatcher creates a new step dispatcher with default configuration

func NewStepDispatcherWithConfig

func NewStepDispatcherWithConfig(cfg StepDispatcherConfig) *StepDispatcher

NewStepDispatcherWithConfig creates a new step dispatcher with custom configuration

func (*StepDispatcher) Dispatch

func (d *StepDispatcher) Dispatch(ctx context.Context, step *core.Step, execCtx *core.ExecutionContext) (*core.StepResult, error)

Dispatch dispatches a step to the appropriate executor

func (*StepDispatcher) GetFunctionRegistry

func (d *StepDispatcher) GetFunctionRegistry() *functions.Registry

GetFunctionRegistry returns the function registry

func (*StepDispatcher) GetTemplateEngine

func (d *StepDispatcher) GetTemplateEngine() template.TemplateEngine

GetTemplateEngine returns the template engine

func (*StepDispatcher) RegisterPlugin

func (d *StepDispatcher) RegisterPlugin(plugin StepExecutorPlugin)

RegisterPlugin allows external plugin registration

func (*StepDispatcher) SetConfig

func (d *StepDispatcher) SetConfig(cfg *config.Config)

SetConfig passes config to executors that need it

func (*StepDispatcher) SetDryRun

func (d *StepDispatcher) SetDryRun(dryRun bool)

SetDryRun enables or disables dry-run mode for the dispatcher

func (*StepDispatcher) SetPrinter added in v5.0.1

func (d *StepDispatcher) SetPrinter(p *terminal.Printer)

SetPrinter sets the terminal printer for user-facing messages

func (*StepDispatcher) SetRunner

func (d *StepDispatcher) SetRunner(r runner.Runner)

SetRunner sets the runner for command execution

func (*StepDispatcher) SetSilent

func (d *StepDispatcher) SetSilent(silent bool)

SetSilent enables or disables silent mode for executors that support it

type StepDispatcherConfig

type StepDispatcherConfig struct {
	UseShardedEngine bool // Use sharded template engine for better concurrency
	EnableBatch      bool // Enable batch template rendering
	ShardCount       int  // Number of shards (default: 16)
	ShardCacheSize   int  // Cache size per shard (default: 64)
}

StepDispatcherConfig holds configuration for the step dispatcher

func DefaultStepDispatcherConfig

func DefaultStepDispatcherConfig() StepDispatcherConfig

DefaultStepDispatcherConfig returns the default configuration

type StepExecutorPlugin

type StepExecutorPlugin interface {
	// Name returns the plugin name for logging/debugging
	Name() string

	// StepTypes returns the step types this plugin handles
	StepTypes() []core.StepType

	// Execute runs the step and returns the result
	Execute(ctx context.Context, step *core.Step, execCtx *core.ExecutionContext) (*core.StepResult, error)
}

StepExecutorPlugin defines the interface for step type plugins. Any executor that handles step types should implement this interface.

type StreamChunkChoice added in v5.0.1

type StreamChunkChoice struct {
	Index        int       `json:"index"`
	Delta        ChatDelta `json:"delta"`
	FinishReason string    `json:"finish_reason,omitempty"`
}

StreamChunkChoice is a single choice in a streaming chunk

type StreamToolCall added in v5.0.1

type StreamToolCall struct {
	Index    int                    `json:"index"`
	ID       string                 `json:"id,omitempty"`
	Type     string                 `json:"type,omitempty"`
	Function StreamToolCallFunction `json:"function,omitempty"`
}

StreamToolCall is a partial tool call from streaming (index-based accumulation)

type StreamToolCallFunction added in v5.0.1

type StreamToolCallFunction struct {
	Name      string `json:"name,omitempty"`
	Arguments string `json:"arguments,omitempty"`
}

StreamToolCallFunction contains partial function data from streaming

type SubAgentToolExecutor added in v5.0.1

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

SubAgentToolExecutor handles spawn_agent tool calls by creating a child AgentExecutor and running the specified sub-agent.

func (*SubAgentToolExecutor) Execute added in v5.0.1

func (e *SubAgentToolExecutor) Execute(ctx context.Context, args map[string]interface{}, execCtx *core.ExecutionContext) (string, error)

Execute spawns a child agent and returns its output as the tool result.

func (*SubAgentToolExecutor) Name added in v5.0.1

func (e *SubAgentToolExecutor) Name() string

Name returns the tool name

type TargetTypeMismatchError

type TargetTypeMismatchError struct {
	Supplied     string
	DetectedType string
	ExpectedType string
}

TargetTypeMismatchError represents a target type validation error. This error is used to provide a single, nicely formatted error message when target type validation fails.

func (*TargetTypeMismatchError) Error

func (e *TargetTypeMismatchError) Error() string

type ToolExecutor added in v5.0.1

type ToolExecutor interface {
	// Name returns the tool name (matches the function name in LLM tool calls)
	Name() string
	// Execute runs the tool with the given arguments and returns the result string
	Execute(ctx context.Context, args map[string]interface{}, execCtx *core.ExecutionContext) (string, error)
}

ToolExecutor defines the interface for executing agent tool calls. Each implementation handles a specific tool (preset or custom).

type ToolExecutorRegistry added in v5.0.1

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

ToolExecutorRegistry manages a collection of ToolExecutor instances

func BuildToolRegistry added in v5.0.1

func BuildToolRegistry(toolDefs []core.AgentToolDef, funcRegistry *functions.Registry) *ToolExecutorRegistry

BuildToolRegistry constructs a ToolExecutorRegistry from the resolved agent tool definitions

func BuildToolRegistryWithSubAgents added in v5.0.1

func BuildToolRegistryWithSubAgents(
	toolDefs []core.AgentToolDef,
	funcRegistry *functions.Registry,
	engine template.TemplateEngine,
	cfg *config.Config,
	silent bool,
	currentDepth int,
	maxDepth int,
	parentState *agentState,
	subAgents []core.SubAgentDef,
) *ToolExecutorRegistry

BuildToolRegistryWithSubAgents constructs a ToolExecutorRegistry that includes both standard tools and the spawn_agent tool for sub-agent delegation.

func NewToolExecutorRegistry added in v5.0.1

func NewToolExecutorRegistry() *ToolExecutorRegistry

NewToolExecutorRegistry creates an empty registry

func (*ToolExecutorRegistry) Execute added in v5.0.1

func (r *ToolExecutorRegistry) Execute(ctx context.Context, name string, args map[string]interface{}, execCtx *core.ExecutionContext) (string, error)

Execute dispatches a tool call to the appropriate executor

func (*ToolExecutorRegistry) Get added in v5.0.1

func (r *ToolExecutorRegistry) Get(name string) (ToolExecutor, bool)

Get returns the ToolExecutor for the given name

func (*ToolExecutorRegistry) Register added in v5.0.1

func (r *ToolExecutorRegistry) Register(te ToolExecutor)

Register adds a ToolExecutor to the registry

Jump to

Keyboard shortcuts

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