Help us shape the future of Go! Take the 2026 Go Developer Survey

runner

package
v0.13.11 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatRunError added in v0.12.4

func FormatRunError(err error, provider, modelName string) string

FormatRunError returns the already-classified run error text when runner.Run handled it, and applies the model formatter only to a raw error from a legacy caller. ACP uses this instead of unconditionally labelling every turn error as an API/model failure.

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 NewApprovalStateWithMode added in v0.5.0

func NewApprovalStateWithMode(workpath string, m mode.SessionMode) *ApprovalState

NewApprovalStateWithMode creates a new ApprovalState seeded with a unified session mode (the preferred constructor; NewApprovalState wraps it for the legacy autoApprove-bool callers).

func (*ApprovalState) GetMode

func (s *ApprovalState) GetMode() handler.ApprovalMode

GetMode returns the current approval mode.

func (*ApprovalState) GetSessionMode added in v0.5.0

func (s *ApprovalState) GetSessionMode() mode.SessionMode

GetSessionMode returns the current unified session 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. It shares the same decision logic as RequestApproval (via decide) so the two paths cannot drift apart.

func (*ApprovalState) OnTurnStart added in v0.9.6

func (s *ApprovalState) OnTurnStart()

OnTurnStart resets per-turn reviewer state (the denial circuit breaker). A frontend calls this once at the start of each user prompt turn.

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) SetBrowserOriginFunc added in v0.8.1

func (s *ApprovalState) SetBrowserOriginFunc(fn func() string)

SetBrowserOriginFunc installs the active-tab origin provider used to scope per-site permissions for browser_act (whose args carry no URL).

func (*ApprovalState) SetBrowserPermFunc added in v0.8.1

func (s *ApprovalState) SetBrowserPermFunc(fn func(origin, class string) bool)

SetBrowserPermFunc installs the site-permission lookup for browser tools.

func (*ApprovalState) SetComputerPermFunc added in v0.10.1

func (s *ApprovalState) SetComputerPermFunc(fn func(bundleID, class string) bool)

SetComputerPermFunc installs the per-app permission lookup for computer tools.

func (*ApprovalState) SetComputerTargetsFunc added in v0.13.10

func (s *ApprovalState) SetComputerTargetsFunc(fn func(toolArgs string) []string)

SetComputerTargetsFunc installs the target-app resolver used to scope per-app permissions for computer_act.

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(m handler.ApprovalMode)

SetMode sets the approval mode (used for external mode changes).

func (*ApprovalState) SetReviewer added in v0.9.6

func (s *ApprovalState) SetReviewer(r review.Reviewer)

SetReviewer installs the optional LLM approval reviewer. A nil reviewer (the default) disables auto-review entirely, so behavior is unchanged.

func (*ApprovalState) SetReviewerConfig added in v0.9.6

func (s *ApprovalState) SetReviewerConfig(cfg *config.Config, platform string)

SetReviewerConfig stores the config and platform needed to lazily build the reviewer when the session enters Auto mode.

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) SetSessionMode added in v0.5.0

func (s *ApprovalState) SetSessionMode(m mode.SessionMode)

SetSessionMode sets the unified session mode and derives the approval axis from it under the same lock. This is the single entry point a frontend uses to change the approval behavior; the tool/prompt axis is applied separately by each frontend's agent-rebuild path.

func (*ApprovalState) SetTranscriptFunc added in v0.9.6

func (s *ApprovalState) SetTranscriptFunc(fn func() []review.Msg)

SetTranscriptFunc installs a provider of recent conversation context handed to the reviewer as evidence. nil means the reviewer judges the action alone.

func (*ApprovalState) SetWorkpath

func (s *ApprovalState) SetWorkpath(path string)

SetWorkpath sets the current working directory (called on environment switch).

type RunResult added in v0.12.2

type RunResult struct {
	Response string
	Messages []adk.Message
	Err      error
}

RunResult is the agent-generated, persistable output of one user turn. Response preserves the flattened assistant text used by UI-only consumers, while Messages carries the structured assistant/tool transcript that must be appended to live conversation history for the next turn. Err reports an interrupted or failed turn so callers do not treat a partial response as a completed artifact such as an approval-ready plan. Internal continuation prompts are deliberately excluded from Messages, matching the session transcript reconstructed after a restart.

func Run

func Run(
	ctx context.Context,
	ag *adk.ChatModelAgent,
	messages []adk.Message,
	h handler.AgentEventHandler,
	rec *session.Recorder,
	todoStore *tools.TodoStore,
	goalStore *tools.GoalStore,
	tracer *telemetry.LangfuseTracer,
	tokenUsage *internalmodel.TokenUsage,
) (result RunResult)

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.

Jump to

Keyboard shortcuts

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