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

agent

package
v0.0.0-...-85c6a05 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2026 License: GPL-2.0 Imports: 50 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LLM_OPENAI    = "openai"
	LLM_ANTHROPIC = "anthropic"
	LLM_OLLAMA    = "ollama"
)
View Source
const (
	ToolStateDisabled = "disabled"
	ToolStateApproval = "approval"
	ToolStatePrompt   = "prompt"
	ToolStateSession  = "session"
	ToolStateDenied   = "denied"
	ToolStateAlways   = "always"
)
View Source
const (
	TOOL_DELEGATE = "delegate"
	TOOL_REPORT   = "report"
	TOOL_ASK_USER = "askUser"
)

Variables

View Source
var ErrToolPermissionRefused = errors.New("tool call refused")

ErrToolPermissionRefused marks a refusal the LLM should be told about rather than one that should abort the agent run.

Functions

func Close

func Close(tileId string)

func EmitAIStreamBlock

func EmitAIStreamBlock(ctx context.Context, kind sessiondb.StreamBlockKind, content string)

func EmitAIStreamToolProgress

func EmitAIStreamToolProgress(ctx context.Context) func(string)

EmitAIStreamToolProgress returns the current run's panel and log emitter.

func New

func New(renderer types.Renderer, tile types.Tile)

func RequestUserQuestion

func RequestUserQuestion(ctx context.Context, question string, choices []string) (string, error)

func ResolveUserQuestionRequest

func ResolveUserQuestionRequest(id, answer string) error

func ResolveWritePermissionRequest

func ResolveWritePermissionRequest(id, decision string) error

ResolveWritePermissionRequest is called by the frontend when the user clicks one of the access-request options rendered in the AI panel output.

func ToolsAdd

func ToolsAdd(t aitypes.Tool)

Types

type AIStreamBlockEmitter

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

func OpenAIStreamBlock

func OpenAIStreamBlock(ctx context.Context, kind sessiondb.StreamBlockKind, parentID string) *AIStreamBlockEmitter

func OpenAITypedStreamBlock

func OpenAITypedStreamBlock(ctx context.Context, kind sessiondb.StreamBlockKind, label string) *AIStreamBlockEmitter

OpenAITypedStreamBlock streams only on the addressable block transport.

func (*AIStreamBlockEmitter) ChildContext

func (e *AIStreamBlockEmitter) ChildContext(ctx context.Context) context.Context

ChildContext scopes blocks emitted from ctx beneath this block.

func (*AIStreamBlockEmitter) Close

func (e *AIStreamBlockEmitter) Close()

func (*AIStreamBlockEmitter) Emit

func (e *AIStreamBlockEmitter) Emit(text string)

type Agent

type Agent struct {
	Meta *aitypes.Meta
	// contains filtered or unexported fields
}

func Get

func Get(tileId string) *Agent

func TryGet

func TryGet(tileId string) (*Agent, bool)

func (*Agent) ChooseTools

func (agent *Agent) ChooseTools(cancel types.MenuCallbackT)

func (*Agent) CurrentModelLabel

func (agt *Agent) CurrentModelLabel() string

func (*Agent) EnvironmentValue

func (agt *Agent) EnvironmentValue(name string) string

func (*Agent) GetMeta

func (agt *Agent) GetMeta() *aitypes.Meta

func (*Agent) ImageGenerationEnvironmentValue

func (agt *Agent) ImageGenerationEnvironmentValue(name string) string

func (*Agent) IsWorkspaceActive

func (agt *Agent) IsWorkspaceActive() bool

func (*Agent) ListMcpServers

func (agent *Agent) ListMcpServers() []map[string]interface{}

func (*Agent) ListModels

func (agt *Agent) ListModels() ([]ServiceModelIndexT, []string)

func (*Agent) ListModelsInputVariable

func (agt *Agent) ListModelsInputVariable() types.InputBoxWTVariables

ListModelsInputVariable returns a pre-configured InputBox variable definition that can be used directly in InputBoxWT options.

func (*Agent) ListTools

func (agent *Agent) ListTools() []map[string]interface{}

func (*Agent) MaxIterations

func (agt *Agent) MaxIterations() int

func (*Agent) McpMenu

func (agent *Agent) McpMenu(cancel types.MenuCallbackT)

func (*Agent) McpServerAdd

func (agt *Agent) McpServerAdd(server, source string, client client)

func (*Agent) McpServerExists

func (agt *Agent) McpServerExists(server string) bool

func (*Agent) McpServerRemove

func (agt *Agent) McpServerRemove(server string)

func (*Agent) McpServerSource

func (agt *Agent) McpServerSource(server string) string

func (*Agent) ModelName

func (agt *Agent) ModelName() string

func (*Agent) ProjectRoot

func (agt *Agent) ProjectRoot() string

func (*Agent) ProviderName

func (agt *Agent) ProviderName() string

func (*Agent) Reload

func (agt *Agent) Reload()

func (*Agent) Renderer

func (agt *Agent) Renderer() types.Renderer

func (*Agent) RequestToolPermission

func (agt *Agent) RequestToolPermission(ctx context.Context, toolName string) error

func (*Agent) ResetToolPermissions

func (agt *Agent) ResetToolPermissions()

Permissions are scoped to a single user prompt, so this must only be called when a new prompt starts — not per continuation.

func (*Agent) RunLLMWithMessageStream

func (agent *Agent) RunLLMWithMessageStream(ctx context.Context, messages []*schema.Message, streamCallback func(string)) (result string, err error)

RunLLMWithMessageStream calls the configured runtime with structured messages and streams text chunks.

func (*Agent) RunLLMWithStream

func (agent *Agent) RunLLMWithStream(ctx context.Context, prompt string, streamCallback func(string)) (result string, err error)

RunLLMWithStream calls the configured runtime and streams text chunks. Use ai package helpers to construct provider-appropriate prompts.

func (*Agent) RunSubagentWithTools

func (agent *Agent) RunSubagentWithTools(ctx context.Context, systemPrompt, prompt string, emit func(string)) (string, error)

RunSubagentWithTools runs a sub-agent prompt through its own react agent, restricted to the tools delegable to sub-agents.

The run is deliberately isolated: no session history is loaded, so a sub-agent only ever sees its own system prompt and task.

func (*Agent) SelectServiceModel

func (agt *Agent) SelectServiceModel(returnFn func())

func (*Agent) ServiceName

func (agt *Agent) ServiceName() string

func (*Agent) SetMcpServerEnabled

func (agent *Agent) SetMcpServerEnabled(serverKey string, enabled bool) error

func (*Agent) SetModelFromInputVariable

func (agt *Agent) SetModelFromInputVariable(variables map[string]any)

func (*Agent) SetServiceModelFromSelection

func (agt *Agent) SetServiceModelFromSelection(selection string) error

SetServiceModelFromSelection sets the active service/model from a list label formatted as "<Service>: <Model>".

func (*Agent) SetToolAllowedInSubagent

func (agent *Agent) SetToolAllowedInSubagent(toolName string, allowed bool) error

func (*Agent) SetToolEnabled

func (agent *Agent) SetToolEnabled(toolName string, enabled bool) error

func (*Agent) SetToolState

func (agent *Agent) SetToolState(toolName, state string) error

func (*Agent) ShowToolStateMenu

func (agent *Agent) ShowToolStateMenu(toolName string, x, y int, changed func(string))

func (*Agent) ShowToolSubagentMenu

func (agent *Agent) ShowToolSubagentMenu(toolName string, x, y int, changed func(bool))

func (*Agent) StartServerFromConfigServer

func (agent *Agent) StartServerFromConfigServer(config *mcp_config.ConfigT, server string) error

func (*Agent) StartServersFromConfig

func (agent *Agent) StartServersFromConfig(config *mcp_config.ConfigT) error

func (*Agent) StartServersFromJson

func (agent *Agent) StartServersFromJson(filename string) error

func (*Agent) StartTools

func (agent *Agent) StartTools(tools []*skills.ToolsT) error

func (*Agent) SubagentToolNames

func (agent *Agent) SubagentToolNames() []string

func (*Agent) SummariseModelName

func (agt *Agent) SummariseModelName() string

func (*Agent) SwitchServiceModel

func (agt *Agent) SwitchServiceModel(modelXRef []ServiceModelIndexT, i int)

func (*Agent) Term

func (agt *Agent) Term() types.Term

func (*Agent) ToolAllowedInSubagent

func (agent *Agent) ToolAllowedInSubagent(toolName string) bool

func (*Agent) ToolState

func (agent *Agent) ToolState(toolName string) string

func (*Agent) ToolsAdd

func (agent *Agent) ToolsAdd(t aitypes.Tool) error

func (*Agent) Workspace

func (agt *Agent) Workspace() string

type ServiceModelIndexT

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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