Documentation
¶
Index ¶
- Constants
- Variables
- func AnnotationText(a *ImageAnnotation) string
- func DecodeToolManifest(data []byte, out any, manifest *ToolManifest) error
- func GetBashDetachChannel(ctx context.Context) <-chan struct{}
- func GetModel(ctx context.Context) string
- func GetSessionID(ctx context.Context) string
- func GetToolCallID(ctx context.Context) string
- func GetTraceEnv(ctx context.Context) []string
- func HasBashDetachChannel(ctx context.Context) bool
- func HasBashOutputCallback(ctx context.Context) bool
- func ImageFileRef(path string, supportsVision bool) string
- func ImagePathNote(img ImageAttachment) string
- func IsDirectExecution(ctx context.Context) bool
- func IsToolApproved(ctx context.Context) bool
- func PropertySchema(def sdk.ChatCompletionTool, property string) map[string]any
- func SandboxApprovalAvailable(ctx context.Context) bool
- func UserQuestionsAvailable(ctx context.Context) bool
- func ValidateArguments(schema map[string]any, args map[string]any) error
- func WithAgentMode(ctx context.Context, mode AgentMode) context.Context
- func WithApprovalEscalation(ctx context.Context, gate ApprovalEscalation) context.Context
- func WithBashDetachChannel(ctx context.Context, ch <-chan struct{}) context.Context
- func WithBashOutputCallback(ctx context.Context, callback BashOutputCallback) context.Context
- func WithChatHandler(ctx context.Context, handler BashDetachChannelHolder) context.Context
- func WithDirectExecution(ctx context.Context) context.Context
- func WithModel(ctx context.Context, model string) context.Context
- func WithSandboxApprovalAvailable(ctx context.Context, available bool) context.Context
- func WithSessionID(ctx context.Context, sessionID string) context.Context
- func WithToolApproved(ctx context.Context) context.Context
- func WithToolCallID(ctx context.Context, id string) context.Context
- func WithToolProgressCallback(ctx context.Context, callback ToolProgressCallback) context.Context
- func WithTraceEnv(ctx context.Context, env []string) context.Context
- func WithUserQuestionBroker(ctx context.Context, broker UserQuestionBroker) context.Context
- func WithUserQuestionsAvailable(ctx context.Context, available bool) context.Context
- type AgentMode
- type AgentModeState
- type AgentRequest
- type AgentService
- type AnnotateOptions
- type AnnotatedElement
- type ApprovalAction
- type ApprovalEscalation
- type ApprovalEscalationRequest
- type ApprovalEscalationResult
- type ApprovalPolicy
- type BackgroundTasksChangedEvent
- type BaseChatEvent
- type BashDetachChannelHolder
- type BashOutputCallback
- type BashOutputChunkEvent
- type BashToolResult
- type BrowserExtensionStatusEvent
- type CallApprover
- type ChatChunkEvent
- type ChatCompleteEvent
- type ChatErrorEvent
- type ChatEvent
- type ChatMetrics
- type ChatStartEvent
- type ChatSyncResponse
- type ComputerUsePause
- type ComputerUsePausedEvent
- type ComputerUseResumedEvent
- type DeleteToolResult
- type DrainQueueEvent
- type EditOperationResult
- type EditToolResult
- type EventBridge
- type FetchResult
- type FileReadToolResult
- type FileService
- type FileWriteToolResult
- type FormatterType
- type Frame
- type FrameSource
- type FrameToolResult
- type GitHubIssue
- type GitHubIssueComment
- type GitHubIssueService
- type GitHubSetupService
- type HookCommand
- type HookCommandProvider
- type HookPoint
- type ImageAnnotation
- type ImageAnnotator
- type ImageAttachment
- type ImageService
- type InstallWorkflowOptions
- type JudgeDecision
- type JudgeVerdictChatEvent
- type MCPToolResult
- type ManifestTool
- type MessageQueuedEvent
- type ModelSelectedEvent
- type MultiEditToolResult
- type MusicService
- type NoopUINotifier
- type OptimizationStatusEvent
- type PlanApprovalAction
- type PlanApprovalRequestedEvent
- type ReminderQuery
- type RetryStatus
- type RetryStatusSink
- type ScreenRecordingStatusEvent
- type ScreenRegion
- type SelfGatedTool
- type SessionTool
- type ShellDetachedEvent
- type Skill
- type SkillLoadError
- type SkillScope
- type SkillSummary
- type SkillsService
- type SoundEffectService
- type SpeechService
- type SubagentInfo
- type SystemReminder
- type SystemReminderProvider
- type TodoItem
- type TodoList
- type TodoUpdateChatEvent
- type TodoWriteToolResult
- type Tool
- type ToolApprovalRequestedEvent
- type ToolApprovalResolvedEvent
- type ToolApprovalResponseEvent
- type ToolCancelledEvent
- type ToolExecutionCompletedEvent
- type ToolExecutionProgressEvent
- type ToolExecutionResult
- type ToolManifest
- type ToolManifestLookup
- type ToolManifests
- type ToolProgressCallback
- type ToolService
- type TreeToolResult
- type UINotifier
- type UserInputEvent
- type UserMessageChatEvent
- type UserQuestion
- type UserQuestionAnswer
- type UserQuestionBroker
- type UserQuestionOption
- type UserQuestionRequestedEvent
- type VideoRequest
- type VideoService
- type WebSearchResponse
- type WebSearchResult
Constants ¶
const ( EscalationApproved = "approved" EscalationDenied = "denied" EscalationNotRejected = "not_rejected" EscalationAlreadyAsked = "already_asked" EscalationNoApprover = "no_approver" )
Escalation statuses returned by ApprovalEscalation.Escalate. They map onto distinguishable RequestApproval tool results so the driver knows why an escalation did not proceed: the call was not judge-rejected, it was already escalated once, or no interactive approver is reachable (headless/no-TTY).
Variables ¶
var ErrMaxTurnsReached = errors.New("max_turns_reached")
ErrMaxTurnsReached is returned when the agent reaches its maximum turn limit without completing the task. Callers should use errors.Is to check for it.
var HookPoints = []HookPoint{ HookPreSession, HookPreStream, HookPostStream, HookPreTool, HookPostTool, HookPreQueueDrain, HookPostQueueDrain, HookPostSession, }
HookPoints is the canonical catalog, used for config validation. Order is the loop order (a run flows top to bottom, looping the middle phases).
Functions ¶
func AnnotationText ¶
func AnnotationText(a *ImageAnnotation) string
AnnotationText renders an ImageAnnotation as the canonical LLM-facing text: a one-line summary followed by the numbered element list with centers and bounding boxes. Every consumer (tools, chat, headless) uses this one shape.
func DecodeToolManifest ¶ added in v0.216.0
func DecodeToolManifest(data []byte, out any, manifest *ToolManifest) error
DecodeToolManifest strictly decodes data into out, then normalizes and validates manifest, which out holds. out may embed the manifest inline and add fields of its own, as a custom tool's manifest does.
func GetBashDetachChannel ¶
GetBashDetachChannel retrieves the bash detach channel from context Returns nil if the key is not set or if the value is not a channel
func GetSessionID ¶
GetSessionID retrieves the session ID from context Returns empty string if the key is not set or if the value is not a string
func GetToolCallID ¶
GetToolCallID retrieves the tool call id from context
func GetTraceEnv ¶
GetTraceEnv retrieves the subprocess trace environment from context
func HasBashDetachChannel ¶
HasBashDetachChannel checks if a bash detach channel is set in the context
func HasBashOutputCallback ¶
HasBashOutputCallback checks if a bash output callback is set in the context
func ImageFileRef ¶
ImageFileRef returns the inline text substituted for an image file reference (chat "@path" or headless --files): images are never sent as raw base64 — the model reaches them through ImageDecode, which returns the image itself to vision models and a text description to the others.
func ImagePathNote ¶
func ImagePathNote(img ImageAttachment) string
ImagePathNote returns a text note pointing at an attached image's on-disk source, so models without vision can inspect it via ImageDecode. Returns "" when the image has no source path.
func IsDirectExecution ¶
IsDirectExecution checks if the tool was invoked directly by the user Returns false if the key is not set or if the value is not a bool
func IsToolApproved ¶
IsToolApproved checks if the tool was explicitly approved by the user Returns false if the key is not set or if the value is not a bool
func PropertySchema ¶ added in v0.216.0
func PropertySchema(def sdk.ChatCompletionTool, property string) map[string]any
PropertySchema returns the schema of one parameter of def so a tool can fill in values only known at runtime, such as options from its configuration.
func SandboxApprovalAvailable ¶ added in v0.180.0
SandboxApprovalAvailable reports whether a sandbox-extension prompt can be answered by a user in this run. Defaults to false when unset.
func UserQuestionsAvailable ¶ added in v0.191.0
UserQuestionsAvailable reports whether an AskUserQuestion form can be answered by a user in this run. Defaults to false when unset.
func ValidateArguments ¶ added in v0.216.0
ValidateArguments checks a call's arguments against a tool's JSON Schema: every required property is present and each top-level property has its declared type. Nested schemas are not checked.
func WithAgentMode ¶
WithAgentMode returns a new context carrying the agent mode in effect for a tool execution. The Bash tool reads it (AgentModeFromContext) and hands it to config.IsBashCommandAllowed, which picks the per-mode allow-list. The zero value is AgentModeStandard, so a missing mode defaults to standard.
func WithApprovalEscalation ¶ added in v0.188.0
func WithApprovalEscalation(ctx context.Context, gate ApprovalEscalation) context.Context
WithApprovalEscalation returns a new context carrying the judge-rejection escalation gate used by the RequestApproval tool. Injected only on the chat path so headless/no-TTY runs see a nil gate and the tool degrades with a distinguishable "no approver reachable" result.
func WithBashDetachChannel ¶
WithBashDetachChannel returns a new context with a bash detach signal channel
func WithBashOutputCallback ¶
func WithBashOutputCallback(ctx context.Context, callback BashOutputCallback) context.Context
WithBashOutputCallback returns a new context with a bash output streaming callback
func WithChatHandler ¶
func WithChatHandler(ctx context.Context, handler BashDetachChannelHolder) context.Context
WithChatHandler returns a new context with a ChatHandler reference
func WithDirectExecution ¶
WithDirectExecution returns a new context with directExecutionKey set to true
func WithModel ¶
WithModel returns a new context carrying the model in effect for the current agent turn. The Agent tool reads it so subagents inherit the parent's model.
func WithSandboxApprovalAvailable ¶ added in v0.180.0
WithSandboxApprovalAvailable marks whether a user can answer a sandbox-extension prompt in this run.
func WithSessionID ¶
WithSessionID returns a new context with a session ID
func WithToolApproved ¶
WithToolApproved returns a new context with toolApprovedKey set to true
func WithToolCallID ¶
WithToolCallID returns a new context with the LLM tool call id
func WithToolProgressCallback ¶ added in v0.184.0
func WithToolProgressCallback(ctx context.Context, callback ToolProgressCallback) context.Context
WithToolProgressCallback returns a new context carrying a tool progress callback
func WithTraceEnv ¶
WithTraceEnv returns a new context with the subprocess trace environment
func WithUserQuestionBroker ¶
func WithUserQuestionBroker(ctx context.Context, broker UserQuestionBroker) context.Context
WithUserQuestionBroker returns a new context carrying the interactive question broker used by the AskUserQuestion tool. Injected only on the chat path so headless/no-TTY runs see a nil broker and degrade gracefully.
Types ¶
type AgentMode ¶
type AgentMode int
AgentMode represents the operational mode of the agent
const ( // AgentModeStandard is the default mode with all configured tools and approval checks AgentModeStandard AgentMode = iota // AgentModePlan is a read-only mode for planning without execution AgentModePlan // AgentModeAutoAccept bypasses all approval checks (YOLO mode) AgentModeAutoAccept // AgentModeAutoWithJudge keeps the standard approval rules but hands every // gated call to an LLM judge (see judge.yaml) instead of a human: allow-listed // commands still pass for free, anything off-list is decided by one judge // call. The no-human approver for headless/CI runs. AgentModeAutoWithJudge // AgentModeReadOnly is an Explore-like capability for subagents: only // read/search tools are offered and approval is bypassed (the toolset is // read-only by construction). It is a subagent capability selected by the // Agent tool's `type` parameter, not a human shift+tab mode. AgentModeReadOnly )
func AgentModeFromContext ¶
AgentModeFromContext returns the agent mode stored in ctx and whether it was present. When absent, callers should default to AgentModeStandard.
func ParseAgentMode ¶
ParseAgentMode is the inverse of ModeKey: it maps a mode key ("standard"/"plan"/"auto"/"auto-with-judge"/"readonly") back to an AgentMode. Matching is case-insensitive and tolerant of surrounding whitespace. ok is false for an empty or unrecognized key, in which case callers should keep AgentModeStandard.
func (AgentMode) DisplayName ¶
DisplayName returns a user-friendly display name for the mode
func (AgentMode) ModeKey ¶ added in v0.188.0
ModeKey returns the canonical mode key - the inverse of ParseAgentMode: "standard", "plan", "auto", "auto-with-judge", "readonly". It identifies the mode itself (reminder guidance, telemetry, subagent env, extension bridge); the bash allow-list bucket is resolved from the AgentMode inside config.
type AgentModeState ¶ added in v0.207.0
type AgentModeState interface {
GetAgentMode() AgentMode
SetAgentMode(mode AgentMode)
CycleAgentMode() AgentMode
}
AgentModeState handles agent mode switching
type AgentRequest ¶
type AgentRequest struct {
RequestID string `json:"request_id"`
Model string `json:"model"`
Messages []sdk.Message `json:"messages"`
IsChatMode bool `json:"is_chat_mode"`
ApprovalBrokerAttached bool `json:"approval_broker_attached"`
UserQuestionBrokerAttached bool `json:"user_question_broker_attached"`
GroupKey string `json:"group_key,omitempty"`
}
AgentRequest represents a request to the agent service
type AgentService ¶
type AgentService interface {
// Run executes an agent task synchronously (for background/batch processing)
Run(ctx context.Context, req *AgentRequest) (*ChatSyncResponse, error)
// RunWithStream executes an agent task with streaming (for interactive chat)
RunWithStream(ctx context.Context, req *AgentRequest) (<-chan ChatEvent, error)
// RunStreaming executes a single model turn with streaming, invoking onDelta
// for each content/reasoning/tool-call delta, and returns the assembled
// response like Run. For callers that own their own agentic loop (the
// headless AG-UI agent) but want token-level output. onDelta may be nil.
RunStreaming(ctx context.Context, req *AgentRequest, onDelta func(content, reasoning string, toolCalls []sdk.ChatCompletionMessageToolCallChunk)) (*ChatSyncResponse, error)
// CancelRequest cancels an active request
CancelRequest(requestID string) error
// GetMetrics returns metrics for a completed request
GetMetrics(requestID string) *ChatMetrics
// BuildSystemPrompt returns the static system prompt sent as message[0],
// byte-stable across turns; volatile context travels separately as a hidden
// per-request message (see `infer debug agent system_prompt`).
BuildSystemPrompt() string
// SetReasoningEffort updates the reasoning effort applied to subsequent
// requests. An empty string resets to the provider default.
SetReasoningEffort(effort string) error
// GetReasoningEffort returns the effort level currently applied to
// requests ("" = provider default).
GetReasoningEffort() string
}
AgentService handles agent operations with both sync and streaming modes
type AnnotateOptions ¶
type AnnotateOptions struct {
Prompt string // task instruction (UI-element detection, scene description, or a user question); "" -> annotator default
Width int // image width in pixels, stated in the prompt and used to rescale normalized coordinates
Height int // image height in pixels
}
AnnotateOptions carries per-call annotation parameters.
type AnnotatedElement ¶
type AnnotatedElement struct {
Index int `json:"index"`
Label string `json:"label"`
Text string `json:"text,omitempty"`
BBox [4]int `json:"bbox"` // [x1, y1, x2, y2] in the image's pixel space
}
AnnotatedElement is one detected element of an annotated image.
type ApprovalAction ¶
type ApprovalAction int
ApprovalAction represents the user's choice for tool approval
const ( ApprovalApprove ApprovalAction = iota ApprovalReject ApprovalAutoAccept )
func (ApprovalAction) String ¶
func (a ApprovalAction) String() string
type ApprovalEscalation ¶ added in v0.188.0
type ApprovalEscalation interface {
// Escalate validates eligibility (the call must be judge-rejected and not
// yet escalated), prompts the user, and returns the decision.
Escalate(ctx context.Context, req ApprovalEscalationRequest) (ApprovalEscalationResult, error)
}
ApprovalEscalation lets the RequestApproval tool ask the user to override a judge rejection. It is implemented by the agent service, which owns the judge-rejection registry and prompts through the regular tool approval box; it is injected into the tool's execution context on the chat path only, so headless runs degrade to a distinguishable "no approver reachable" result.
func GetApprovalEscalation ¶ added in v0.188.0
func GetApprovalEscalation(ctx context.Context) ApprovalEscalation
GetApprovalEscalation retrieves the escalation gate from context. Returns nil if the key is not set or the value is not an ApprovalEscalation.
type ApprovalEscalationRequest ¶ added in v0.188.0
type ApprovalEscalationRequest struct {
ToolCall sdk.ChatCompletionMessageToolCall
What string
Why string
}
ApprovalEscalationRequest is one ask-the-user-to-override-a-judge-rejection request: the rejected tool call to run, what the permission is needed for, and the agent's justification in its own words.
type ApprovalEscalationResult ¶ added in v0.188.0
ApprovalEscalationResult is the user's decision. JudgeReason echoes the judge's rejection reason so the tool result can show the user and the judge both sides of the disagreement.
type ApprovalPolicy ¶
type ApprovalPolicy interface {
// ShouldRequireApproval returns true if the tool execution requires user approval
// ctx: context for the approval decision
// toolCall: the tool being invoked with its arguments
// isChatMode: whether execution is in interactive chat mode
ShouldRequireApproval(ctx context.Context, toolCall *sdk.ChatCompletionMessageToolCall, isChatMode bool) bool
}
ApprovalPolicy determines whether a tool execution requires user approval This interface allows for different approval strategies (standard, permissive, strict, etc.) Implementations define the business rules for when user approval is required before executing potentially dangerous or state-changing operations.
type BackgroundTasksChangedEvent ¶
type BackgroundTasksChangedEvent struct{}
BackgroundTasksChangedEvent signals that a background job's status changed (submitted, signalled, completed, or failed). The supervisor pushes it so the /tasks view and the inline conversation rows refresh on real change instead of polling at render time.
type BaseChatEvent ¶
BaseChatEvent provides common implementation for ChatEvent interface
func (BaseChatEvent) GetRequestID ¶
func (e BaseChatEvent) GetRequestID() string
func (BaseChatEvent) GetTimestamp ¶
func (e BaseChatEvent) GetTimestamp() time.Time
type BashDetachChannelHolder ¶
type BashDetachChannelHolder interface {
SetBashDetachChan(chan<- struct{})
GetBashDetachChan() chan<- struct{}
ClearBashDetachChan()
}
BashDetachChannelHolder manages the bash detach channel for background shell operations
func GetChatHandler ¶
func GetChatHandler(ctx context.Context) BashDetachChannelHolder
GetChatHandler retrieves the ChatHandler from context Returns nil if the key is not set or if the value is not a BashDetachChannelHolder
type BashOutputCallback ¶
type BashOutputCallback func(output string)
BashOutputCallback receives streaming bash output. Output is coalesced before delivery, so a single invocation may carry several newline-joined lines (the argument never has a trailing newline). This keeps the number of callbacks bounded for high-volume commands; the full command output is captured separately by the tool and is unaffected.
func GetBashOutputCallback ¶
func GetBashOutputCallback(ctx context.Context) BashOutputCallback
GetBashOutputCallback retrieves the bash output callback from context Returns nil if the key is not set or if the value is not a BashOutputCallback
type BashOutputChunkEvent ¶
type BashOutputChunkEvent struct {
BaseChatEvent
ToolCallID string
Output string
IsComplete bool
}
BashOutputChunkEvent indicates a new chunk of bash output is available
type BashToolResult ¶
type BashToolResult struct {
Command string `json:"command"`
Output string `json:"output"`
Error string `json:"error,omitempty"`
ExitCode int `json:"exit_code"`
Duration string `json:"duration"`
}
BashToolResult represents the result of a bash command execution
type BrowserExtensionStatusEvent ¶ added in v0.182.0
type BrowserExtensionStatusEvent struct {
Connected bool
}
BrowserExtensionStatusEvent is pushed through the UI notifier when the browser extension connects to or drops off the CLI bridge.
type CallApprover ¶ added in v0.216.0
CallApprover is implemented by tools that decide per call whether it needs approval, ahead of the agent mode, such as the computer-use tools.
type ChatChunkEvent ¶
type ChatChunkEvent struct {
RequestID string
Timestamp time.Time
Content string
ReasoningContent string
ToolCalls []sdk.ChatCompletionMessageToolCallChunk
Delta bool
Usage *sdk.CompletionUsage
}
ChatChunkEvent represents a streaming chunk of chat response
func (ChatChunkEvent) GetRequestID ¶
func (e ChatChunkEvent) GetRequestID() string
func (ChatChunkEvent) GetTimestamp ¶
func (e ChatChunkEvent) GetTimestamp() time.Time
type ChatCompleteEvent ¶
type ChatCompleteEvent struct {
RequestID string
Timestamp time.Time
Message string
ReasoningContent string
ToolCalls []sdk.ChatCompletionMessageToolCall
Metrics *ChatMetrics
Cancelled bool
// MaxTurnsReached marks a completion forced by the turn limit rather than
// the task finishing; headless renderers map it to ErrMaxTurnsReached.
MaxTurnsReached bool
}
ChatCompleteEvent indicates chat completion. Cancelled is set when the completion is the result of a user-initiated cancel (Esc) rather than the model finishing on its own - the UI uses this to show "User interrupted" rather than "Response complete".
func (ChatCompleteEvent) GetRequestID ¶
func (e ChatCompleteEvent) GetRequestID() string
func (ChatCompleteEvent) GetTimestamp ¶
func (e ChatCompleteEvent) GetTimestamp() time.Time
type ChatErrorEvent ¶
ChatErrorEvent represents an error during chat
func (ChatErrorEvent) GetRequestID ¶
func (e ChatErrorEvent) GetRequestID() string
func (ChatErrorEvent) GetTimestamp ¶
func (e ChatErrorEvent) GetTimestamp() time.Time
type ChatMetrics ¶
type ChatMetrics struct {
Duration time.Duration
Usage *sdk.CompletionUsage
}
ChatMetrics holds performance and usage metrics
type ChatStartEvent ¶
ChatStartEvent indicates a chat request has started
func (ChatStartEvent) GetRequestID ¶
func (e ChatStartEvent) GetRequestID() string
func (ChatStartEvent) GetTimestamp ¶
func (e ChatStartEvent) GetTimestamp() time.Time
type ChatSyncResponse ¶
type ChatSyncResponse struct {
RequestID string `json:"request_id"`
Content string `json:"content"`
ReasoningContent string `json:"reasoning_content,omitempty"`
ToolCalls []sdk.ChatCompletionMessageToolCall `json:"tool_calls,omitempty"`
Usage *sdk.CompletionUsage `json:"usage,omitempty"`
Duration time.Duration `json:"duration"`
FinishReason string `json:"finish_reason,omitempty"`
}
ChatSyncResponse represents a synchronous chat completion response
type ComputerUsePause ¶ added in v0.207.0
type ComputerUsePause interface {
SetComputerUsePaused(paused bool, requestID string)
IsComputerUsePaused() bool
GetPausedRequestID() string
ClearComputerUsePauseState()
}
ComputerUsePause handles computer use pause state
type ComputerUsePausedEvent ¶
ComputerUsePausedEvent indicates computer-use execution has been paused
func (ComputerUsePausedEvent) GetRequestID ¶
func (e ComputerUsePausedEvent) GetRequestID() string
func (ComputerUsePausedEvent) GetTimestamp ¶
func (e ComputerUsePausedEvent) GetTimestamp() time.Time
type ComputerUseResumedEvent ¶
ComputerUseResumedEvent indicates computer-use execution has resumed
func (ComputerUseResumedEvent) GetRequestID ¶
func (e ComputerUseResumedEvent) GetRequestID() string
func (ComputerUseResumedEvent) GetTimestamp ¶
func (e ComputerUseResumedEvent) GetTimestamp() time.Time
type DeleteToolResult ¶
type DeleteToolResult struct {
Path string `json:"path"`
DeletedFiles []string `json:"deleted_files"`
DeletedDirs []string `json:"deleted_dirs"`
TotalFilesDeleted int `json:"total_files_deleted"`
TotalDirsDeleted int `json:"total_dirs_deleted"`
WildcardExpanded bool `json:"wildcard_expanded"`
Errors []string `json:"errors,omitempty"`
}
DeleteToolResult represents the result of a delete operation
type DrainQueueEvent ¶
type DrainQueueEvent struct{}
DrainQueueEvent asks the orchestrator to start a fresh agent turn when the agent is idle on the chat view and the shared message queue has content (background-job completion notes or user messages typed while busy). Unlike the old queue-drain tick it is not a clock: it is pushed exactly once per real trigger (a background job landing work, a turn completing with a non-empty queue, or re-entering the chat view), and HandleDrainQueueEvent is a pure gate that starts a turn (Idle -> CheckingQueue -> ... -> Completing -> Idle) or returns nil. There is no self-reschedule.
type EditOperationResult ¶
type EditOperationResult struct {
OldString string `json:"old_string"`
NewString string `json:"new_string"`
ReplaceAll bool `json:"replace_all"`
ReplacedCount int `json:"replaced_count"`
Success bool `json:"success"`
Error string `json:"error,omitempty"`
// WhitespaceNormalized is true when this edit matched via the indentation-tolerant fallback.
WhitespaceNormalized bool `json:"whitespace_normalized,omitempty"`
}
EditOperationResult represents the result of a single edit operation within MultiEdit
type EditToolResult ¶
type EditToolResult struct {
FilePath string `json:"file_path"`
OldString string `json:"old_string"`
NewString string `json:"new_string"`
ReplacedCount int `json:"replaced_count"`
ReplaceAll bool `json:"replace_all"`
FileModified bool `json:"file_modified"`
OriginalSize int64 `json:"original_size"`
NewSize int64 `json:"new_size"`
BytesDifference int64 `json:"bytes_difference"`
OriginalLines int `json:"original_lines"`
NewLines int `json:"new_lines"`
LinesDifference int `json:"lines_difference"`
Diff string `json:"diff,omitempty"`
WhitespaceNormalized bool `json:"whitespace_normalized,omitempty"`
StartLine int `json:"start_line,omitempty"`
}
EditToolResult represents the result of an edit operation
type EventBridge ¶
type EventBridge interface {
// Tap intercepts an event stream and multicasts it to all subscribers
// Returns a new channel that mirrors the input channel
Tap(input <-chan ChatEvent) <-chan ChatEvent
// Publish broadcasts an event to all subscribers
Publish(event ChatEvent)
// Subscribe creates a new event channel and returns it
Subscribe() chan ChatEvent
// SubscribeFuture is Subscribe without the ring-buffer replay, for
// subscribers that backfill history another way.
SubscribeFuture() chan ChatEvent
// Unsubscribe removes a subscriber and closes its channel
Unsubscribe(ch chan ChatEvent)
}
EventBridge multicasts chat events to multiple subscribers (e.g., terminal UI and the opentask extension bridge)
type FetchResult ¶
type FetchResult struct {
Content string `json:"content"`
URL string `json:"url"`
Status int `json:"status"`
Size int64 `json:"size"`
ContentType string `json:"content_type"`
Cached bool `json:"cached"`
SavedPath string `json:"saved_path,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
Warning string `json:"warning,omitempty"`
}
FetchResult represents the result of a fetch operation
type FileReadToolResult ¶
type FileReadToolResult struct {
FilePath string `json:"file_path"`
Content string `json:"content"`
Size int64 `json:"size"`
StartLine int `json:"start_line,omitempty"`
EndLine int `json:"end_line,omitempty"`
Error string `json:"error,omitempty"`
}
FileReadToolResult represents the result of a file read operation
type FileService ¶
type FileService interface {
ListProjectFiles() ([]string, error)
ReadFile(path string) (string, error)
ValidateFile(path string) error
}
FileService handles file operations
type FileWriteToolResult ¶
type FileWriteToolResult struct {
FilePath string `json:"file_path"`
BytesWritten int64 `json:"bytes_written"`
LinesWritten int `json:"lines_written"`
Created bool `json:"created"`
Overwritten bool `json:"overwritten"`
ChunkIndex int `json:"chunk_index,omitempty"`
TotalChunks int `json:"total_chunks,omitempty"`
IsComplete bool `json:"is_complete"`
Error string `json:"error,omitempty"`
}
FileWriteToolResult represents the result of a file write operation
type FormatterType ¶
type FormatterType string
FormatterType defines the context for formatting tool results
const ( FormatterUI FormatterType = "ui" // Compact display for UI FormatterLLM FormatterType = "llm" // Formatted for LLM consumption FormatterShort FormatterType = "short" // Brief summary format )
type Frame ¶
type Frame struct {
ID string `json:"id"`
Timestamp time.Time `json:"timestamp"`
Data string `json:"data"` // base64 encoded image
Path string `json:"-"` // on-disk path when the frame exists as a file
Width int `json:"width"` // Final image width (after scaling)
Height int `json:"height"` // Final image height (after scaling)
Format string `json:"format"` // "png" or "jpeg"
Method string `json:"method"` // capture method, e.g. "x11", "wayland", "directory"
}
Frame represents a captured image frame (screenshot, camera frame, ...) with metadata
type FrameSource ¶
FrameSource provides the most recent frame of a named frame source (the screen ring buffer, a camera directory, ...).
type FrameToolResult ¶
type FrameToolResult struct {
Source string `json:"source,omitempty"`
Display string `json:"display"`
Region *ScreenRegion `json:"region,omitempty"`
Width int `json:"width"`
Height int `json:"height"`
Format string `json:"format"`
Method string `json:"method"`
Annotated bool `json:"annotated,omitempty"`
Annotation *ImageAnnotation `json:"annotation,omitempty"`
Note string `json:"note,omitempty"` // degrade note, e.g. "annotation unavailable: ..."
}
FrameToolResult represents the result of a frame retrieval
type GitHubIssue ¶
type GitHubIssue struct {
Number int
Title string
Body string
State string
URL string
UpdatedAt time.Time
Author string
Comments []GitHubIssueComment
}
GitHubIssue is a minimal projection of a GitHub issue, big enough for both the autocomplete dropdown (Number, Title, State) and inline expansion into a chat-message block (Body, URL, Comments, UpdatedAt). Comments is nil for the list variant and populated for the view variant.
type GitHubIssueComment ¶
GitHubIssueComment is a single comment on a GitHub issue, sorted by CreatedAt ascending.
type GitHubIssueService ¶
type GitHubIssueService interface {
// ListIssues returns recent open issues for the current repo, newest first.
// Results are cached for a short TTL so repeated autocomplete keystrokes
// don't shell out per character. Returns ([], nil) on environment failures.
ListIssues(ctx context.Context) ([]GitHubIssue, error)
// GetIssue fetches an issue with body and the most-recent comments (capped
// internally). Uncached. Returns (nil, err) on failure so the expansion
// path can leave the raw token in place.
GetIssue(ctx context.Context, number int) (*GitHubIssue, error)
// IsAvailable reports whether the service can serve requests in the
// current environment. Used by the autocomplete trigger to short-circuit
// a slow first shell-out when gh / repo / auth are missing.
IsAvailable() bool
}
GitHubIssueService provides cached access to the current repository's GitHub issues via the gh CLI. Implementations gracefully degrade (return empty/nil with no error) when not in a git repo, when gh is not installed, or when the remote/auth is not configured - the chat input's "#" autocomplete and "#N" inline expansion simply become no-ops in those environments.
type GitHubSetupService ¶
type GitHubSetupService interface {
GetCurrentRepo() (string, error)
IsOrgRepo(repo string) (bool, error)
CheckOrgSecretsExist(orgName string) (bool, error)
SetOrgSecret(orgName, name, value string) error
InstallWorkflow(ctx context.Context, opts InstallWorkflowOptions) (string, error)
}
GitHubSetupService handles git/gh/CI operations for the GitHub Action CI setup flow triggered from the install-opentask wizard. Every shell invocation carries a context so a wedged subprocess cannot hang the UI.
type HookCommand ¶
HookCommand is a resolved command hook ready to run at a hook point: a named shell command with a wall-clock timeout. It is the command-action sibling of SystemReminder (the text-injection action). The agent - not the provider - runs it, through the same bash allow-list a model-proposed command faces.
type HookCommandProvider ¶
type HookCommandProvider interface {
CommandsDue(hook HookPoint) []HookCommand
}
HookCommandProvider resolves which command hooks are due at a hook point. It is the command-action sibling of SystemReminderProvider, implemented by config from the user's hooks list. The provider only resolves the commands; the agent runs them through the existing bash allow-list, so config stays free of os/exec. The agent depends on this interface so the command set can be faked in tests.
type HookPoint ¶
type HookPoint string
HookPoint is one of the pre-defined points in the agent loop where actions can attach. The catalog is fully symmetric: every loop phase exposes a pre_/post_ pair. System reminders attach a text-injection action here today; executable command hooks attach a command-execution action at the same points later, both flowing through the single dispatchHooks(point) seam.
const ( HookPreSession HookPoint = "pre_session" // run begins, before the first stream (turn 1) HookPostSession HookPoint = "post_session" // run finished ("agent finished generating") HookPreStream HookPoint = "pre_stream" // before each LLM streaming turn HookPostStream HookPoint = "post_stream" // after each LLM response, before tool evaluation HookPreTool HookPoint = "pre_tool" // before tool execution HookPostTool HookPoint = "post_tool" // after tool execution HookPreQueueDrain HookPoint = "pre_queue_drain" // before draining queued user messages HookPostQueueDrain HookPoint = "post_queue_drain" // after draining queued user messages )
type ImageAnnotation ¶
type ImageAnnotation struct {
Summary string `json:"summary"`
Elements []AnnotatedElement `json:"elements,omitempty"`
}
ImageAnnotation is the structured result of annotating an image: a short scene summary plus a numbered element list. Elements may be empty when the annotator degraded to a plain-text summary.
type ImageAnnotator ¶
type ImageAnnotator interface {
AnnotateImage(ctx context.Context, img ImageAttachment, opts AnnotateOptions) (*ImageAnnotation, error)
}
ImageAnnotator turns an image into text (summary + element list) via a vision model, so text-only session models can understand frames and images.
type ImageAttachment ¶
type ImageAttachment struct {
Data string `json:"data"`
MimeType string `json:"mime_type"`
Filename string `json:"filename,omitempty"`
DisplayName string `json:"display_name"`
SourcePath string `json:"-"`
}
ImageAttachment represents an image attachment in a message
type ImageService ¶
type ImageService interface {
// ReadImageFromFile reads an image from a file path and returns it as a base64 attachment
ReadImageFromFile(filePath string) (*ImageAttachment, error)
// ReadImageFromBinary reads an image from binary data and returns it as a base64 attachment
ReadImageFromBinary(imageData []byte, filename string) (*ImageAttachment, error)
// ReadImageFromURL fetches an image from a URL and returns it as a base64 attachment
ReadImageFromURL(imageURL string) (*ImageAttachment, error)
// IsImageFile checks if a file is a supported image format
IsImageFile(filePath string) bool
// GenerateImage generates an image from prompt using model ("provider/name")
// and returns the path of the saved file. A blank quality or size leaves the
// provider's own default
GenerateImage(ctx context.Context, model, prompt, quality, size string) (string, error)
// EditImage edits the image at imagePath using prompt and model
// ("provider/name") and returns the path of the saved file. A blank quality
// or size leaves the provider's own default. A non-empty maskPath points to
// a PNG whose transparent (alpha=0) areas mark the editable region; all
// other pixels are preserved exactly.
EditImage(ctx context.Context, model, prompt, imagePath, quality, size, maskPath string) (string, error)
// CreateImageVariation creates a variation of the image at imagePath using
// model ("provider/name") and returns the path of the saved file. A blank
// size leaves the provider's own default
CreateImageVariation(ctx context.Context, model, imagePath, size string) (string, error)
}
ImageService handles image operations including loading and encoding
type InstallWorkflowOptions ¶ added in v0.182.0
type InstallWorkflowOptions struct {
// Repo is "owner/name"; empty means the current repository.
Repo string
// Model runs the install agent and becomes the workflow's default model.
Model string
// Context is extra user-supplied guidance appended to the agent prompt.
Context string
// GitHubApp selects the GitHub App token variant of the workflow.
GitHubApp bool
}
InstallWorkflowOptions parameterizes GitHubSetupService.InstallWorkflow.
type JudgeDecision ¶ added in v0.188.0
type JudgeDecision string
JudgeDecision is the verdict value the LLM judge returns for one pending tool call.
const ( JudgeDecisionApproved JudgeDecision = "approved" JudgeDecisionRejected JudgeDecision = "rejected" )
Judge verdict decisions. The judge must answer with exactly one JSON object {"decision": "<one of these literals>", "reason": "<short text>"}.
type JudgeVerdictChatEvent ¶ added in v0.188.0
type JudgeVerdictChatEvent struct {
BaseChatEvent
Tool string
Model string // the judge model that decided
Decision JudgeDecision
Reason string
Turn int
}
JudgeVerdictChatEvent reports the LLM judge's decision for one pending tool call when the judge approval delivery is active. Emitted for both decisions; a rejection surfaces as a TUI flash status / headless stderr line.
type MCPToolResult ¶
type MCPToolResult struct {
ServerName string `json:"server_name"`
ToolName string `json:"tool_name"`
Content string `json:"content"`
Error string `json:"error,omitempty"`
}
MCPToolResult represents the result of an MCP tool execution
type ManifestTool ¶ added in v0.216.0
type ManifestTool interface {
Manifest() ToolManifest
}
ManifestTool is implemented by tools that bring their own manifest, such as the browser and computer tools, so the tool registry can answer their policy.
type MessageQueuedEvent ¶
MessageQueuedEvent indicates a message was received from the queue and stored
func (MessageQueuedEvent) GetRequestID ¶
func (e MessageQueuedEvent) GetRequestID() string
func (MessageQueuedEvent) GetTimestamp ¶
func (e MessageQueuedEvent) GetTimestamp() time.Time
type ModelSelectedEvent ¶ added in v0.182.0
type ModelSelectedEvent struct {
Model string
}
ModelSelectedEvent is pushed through the UI notifier when something other than the TUI's own selector (e.g. the browser extension) switched the model, so an open selector can close and indicators refresh.
type MultiEditToolResult ¶
type MultiEditToolResult struct {
FilePath string `json:"file_path"`
Edits []EditOperationResult `json:"edits"`
TotalEdits int `json:"total_edits"`
SuccessfulEdits int `json:"successful_edits"`
FileModified bool `json:"file_modified"`
OriginalSize int64 `json:"original_size"`
NewSize int64 `json:"new_size"`
BytesDifference int64 `json:"bytes_difference"`
NormalizedEdits int `json:"normalized_edits,omitempty"`
}
MultiEditToolResult represents the result of a MultiEdit operation
type MusicService ¶ added in v0.206.0
type MusicService interface {
Compose(ctx context.Context, prompt, outPath string, seconds *float32, instrumental *bool) error
}
MusicService composes a music clip from a text prompt through the gateway's Music API, writing the audio to outPath. A non-nil seconds caps the clip length in seconds; a non-nil instrumental requests a vocal-free clip. An omitted knob leaves the choice to the configured provider.
type NoopUINotifier ¶
type NoopUINotifier struct{}
NoopUINotifier is the useful zero value: producers can always call Notify even before the program exists or after shutdown, with no nil checks. The container defaults to it until cmd/chat.go swaps in the real (program-backed) notifier.
type OptimizationStatusEvent ¶
type OptimizationStatusEvent struct {
RequestID string
Timestamp time.Time
Message string
IsActive bool
OriginalCount int
OptimizedCount int
}
OptimizationStatusEvent indicates conversation optimization status
func (OptimizationStatusEvent) GetRequestID ¶
func (e OptimizationStatusEvent) GetRequestID() string
func (OptimizationStatusEvent) GetTimestamp ¶
func (e OptimizationStatusEvent) GetTimestamp() time.Time
type PlanApprovalAction ¶
type PlanApprovalAction int
PlanApprovalAction represents the user's choice for plan approval
const ( PlanApprovalAccept PlanApprovalAction = iota PlanApprovalReject PlanApprovalAcceptStandard )
func (PlanApprovalAction) String ¶
func (a PlanApprovalAction) String() string
type PlanApprovalRequestedEvent ¶
type PlanApprovalRequestedEvent struct {
RequestID string
Timestamp time.Time
PlanContent string
PlanID string
ResponseChan chan PlanApprovalAction `json:"-"`
}
PlanApprovalRequestedEvent indicates plan mode completion requires user approval
func (PlanApprovalRequestedEvent) GetRequestID ¶
func (e PlanApprovalRequestedEvent) GetRequestID() string
func (PlanApprovalRequestedEvent) GetTimestamp ¶
func (e PlanApprovalRequestedEvent) GetTimestamp() time.Time
type ReminderQuery ¶
type ReminderQuery struct {
Hook HookPoint
Turn int
SessionTurn int
MaxTurns int
Fired map[string]bool
ToolFailed bool
RepeatedFailures int
FailedTool string
FinishReason string
IncompleteTodos []TodoItem
StalledStrikes int
EmptyResponse bool
TodoCount int
ModeChanged bool
PrevMode AgentMode
Mode AgentMode
ModeGuidance map[string]string
}
ReminderQuery carries the context a SystemReminderProvider needs to decide which reminders are due at a hook point.
Turn and SessionTurn differ deliberately. Turn is the agent-loop turn within the CURRENT run (one user message in chat), used by the turns_before_max trigger relative to MaxTurns. SessionTurn is the cumulative model-turn count across the whole chat session - it does NOT reset when a new user message starts a fresh run, so the `interval` trigger fires on every Nth conversational turn as users expect (per-request Turns would reset to 1 each message and an interval reminder would essentially never fire in chat). In headless `infer headless` a single invocation IS the session, so the two are equal.
Fired carries reminder names already emitted this session (consulted by the `once` trigger); the caller marks names fired after injecting.
ToolFailed reports whether the tool batch that just completed had any failed call. It is meaningful only at the post_tool hook (set right before that dispatch) and drives the `on_failure` trigger.
RepeatedFailures and FailedTool are set at the post_tool hook when the same tool call has failed threshold+ consecutive times; they drive the `on_repeated_failure` trigger. FailedTool is the function name, for templating.
FinishReason carries the LLM response's finish_reason string. It drives the `on_truncation` trigger at the post_stream hook (firing when the value is "length").
IncompleteTodos carries the remaining open todo items from the model's TodoWrite list; it drives the `on_stalled_todos` trigger at the post_stream hook (firing when non-empty and the response had no tool calls). StalledStrikes is the count of consecutive no-tool-call responses, gating that trigger's strike cap (threshold).
EmptyResponse reports that the just-finished assistant turn carried neither text nor a tool call (a reasoning-only reply); it drives the `on_empty_response` trigger at the post_stream hook.
ModeChanged reports whether the agent mode differs from the previous streaming turn; PrevMode/Mode carry the transition. They are meaningful only at the pre_stream hook (set right before that dispatch) and drive the `on_mode_change` trigger.
type RetryStatus ¶
RetryStatus tracks the current retry state for reconnection attempts. A nil *RetryStatus means no retry is in progress.
type RetryStatusSink ¶ added in v0.207.0
type RetryStatusSink interface {
SetRetryStatus(status *RetryStatus)
}
RetryStatusSink receives the agent's retry progress so a UI can show it.
type ScreenRecordingStatusEvent ¶ added in v0.208.0
ScreenRecordingStatusEvent is pushed through the UI notifier when a RecordStart screen recording begins or its ffmpeg process ends (RecordStop, the max_duration cap, or shutdown). It is also a ChatEvent so headless can bridge it into the rendered stream.
func (ScreenRecordingStatusEvent) GetRequestID ¶ added in v0.208.0
func (e ScreenRecordingStatusEvent) GetRequestID() string
func (ScreenRecordingStatusEvent) GetTimestamp ¶ added in v0.208.0
func (e ScreenRecordingStatusEvent) GetTimestamp() time.Time
type ScreenRegion ¶
type ScreenRegion struct {
X int `json:"x"`
Y int `json:"y"`
Width int `json:"width"`
Height int `json:"height"`
}
ScreenRegion represents a rectangular region of the screen
type SelfGatedTool ¶ added in v0.216.0
type SelfGatedTool interface {
SelfGated() bool
}
SelfGatedTool is implemented by tools that a context of their own switches on, such as the A2A tools under a2a.enabled. The tools.enabled switch for local tools does not gate them, their IsEnabled alone decides.
type SessionTool ¶ added in v0.216.0
type SessionTool interface {
NeedsSession() bool
}
SessionTool is implemented by tools that keep state past their own call, such as a running screen recording, and so need a chat or headless session.
type ShellDetachedEvent ¶
type ShellDetachedEvent struct {
RequestID string
Timestamp time.Time
ShellID string
Command string
}
ShellDetachedEvent indicates a Bash command has been moved to background
func (ShellDetachedEvent) GetRequestID ¶
func (e ShellDetachedEvent) GetRequestID() string
func (ShellDetachedEvent) GetTimestamp ¶
func (e ShellDetachedEvent) GetTimestamp() time.Time
type Skill ¶
type Skill struct {
Name string
Description string
Path string
Scope SkillScope
PluginName string
}
Skill is the in-memory metadata for a discovered SKILL.md. The body of the file is intentionally not loaded at startup - only frontmatter - so the model reads it on demand via the existing Read tool (progressive disclosure, matching the contract).
func (Skill) DisplayName ¶
DisplayName returns the qualified name for display. Plugin skills are shown as "pluginName:skillName" so the user/LLM can reference them unambiguously.
func (Skill) Summary ¶
func (s Skill) Summary() SkillSummary
Summary returns the wire-serializable projection of the skill.
type SkillLoadError ¶
SkillLoadError records a per-skill validation failure so `infer skills list` can surface why a directory was skipped without crashing startup.
type SkillScope ¶
type SkillScope string
SkillScope identifies where a skill came from: the project (.infer/skills/), the open-standard location (.agents/skills/), the user-global location (~/.infer/skills/), an installed plugin (~/.infer/plugins/<name>/skills/), or the centralized catalog (dynamically discovered at runtime).
const ( SkillScopeProject SkillScope = "project" SkillScopeAgents SkillScope = "agents" SkillScopeUser SkillScope = "user" SkillScopePlugin SkillScope = "plugin" SkillScopeCatalog SkillScope = "catalog" )
type SkillSummary ¶
type SkillSummary struct {
Name string `json:"name"`
Description string `json:"description"`
Scope string `json:"scope"`
}
SkillSummary is the serializable projection of a Skill (qualified name, description, scope) used wherever skills cross a wire boundary.
type SkillsService ¶
type SkillsService interface {
// Load scans the configured skill directories and populates the
// in-memory list. Safe to call once at startup; calling again rescans.
// Returns nil and does nothing when skills are disabled in config.
Load(ctx context.Context) error
// List returns the currently loaded skills. The slice is a defensive
// copy - callers may retain or mutate it freely.
List() []Skill
// Get returns the loaded skill with the given name and true, or a zero
// Skill and false when no such skill is loaded. Used by deterministic
// activation to resolve an explicitly invoked skill name to its metadata
// (description + path) for injection.
Get(name string) (Skill, bool)
// Errors returns validation failures encountered during the most recent
// Load. Cleared on each Load call.
Errors() []SkillLoadError
// Discover looks up a skill by name in the centralized catalog when
// progressive discovery is enabled and no local skill of that name
// exists. Returns the skill metadata (name, description, path) and
// true on success, or a zero Skill and false when the skill is not
// found in the catalog or discovery is disabled. The skill body is
// fetched only when the skill is actually activated (progressive).
// Local skills always take precedence - if a skill with the same name
// is already loaded, no catalog lookup is performed.
Discover(ctx context.Context, name string) (Skill, bool)
// CleanupDynamic removes dynamically downloaded skills from disk.
// When cleanup is enabled in config, this is called after the session
// ends to remove any skills that were fetched from the catalog.
CleanupDynamic(ctx context.Context) error
}
SkillsService discovers and exposes Agent Skills. Implementations must be safe for concurrent reads after Load returns.
type SoundEffectService ¶ added in v0.206.0
type SoundEffectService interface {
Generate(ctx context.Context, prompt, outPath string, seconds *float32, loop *bool) error
}
SoundEffectService generates a short sound effect or ambience clip from a text prompt through the gateway's SFX API, writing WAV audio to outPath. A non-nil seconds caps the clip length in seconds; a non-nil loop requests a clip that loops seamlessly. An omitted knob leaves the choice to the configured provider.
type SpeechService ¶ added in v0.186.0
type SpeechService interface {
Synthesize(ctx context.Context, text, voiceSamplePath, outPath string) error
}
SpeechService synthesizes speech through the gateway's Audio API, writing the audio to outPath; a non-empty voiceSamplePath is forwarded as a reference sample for zero-shot voice cloning.
type SubagentInfo ¶ added in v0.214.0
type SubagentInfo struct {
Name string `json:"name"`
Description string `json:"description"`
Model string `json:"model,omitempty"`
Tools []string `json:"tools,omitempty"`
ReadOnly bool `json:"read_only"`
Source string `json:"source"`
}
SubagentInfo describes one Markdown-defined subagent preset (.infer/agents/*.md) for user-facing listings like /agents. An empty Model means inherit and an empty Tools list means the parent's tools are inherited.
type SystemReminder ¶
SystemReminder is a resolved reminder ready to inject into the conversation. When AppendToToolResult is true, the Text is appended to the last tool-role message content (for tool_call/tool pairing) instead of inserted as a standalone user message. Set by the provider for on_repeated_failure reminders.
type SystemReminderProvider ¶
type SystemReminderProvider interface {
RemindersDue(q ReminderQuery) []SystemReminder
}
SystemReminderProvider decides which system reminders are due for a given ReminderQuery (hook point, per-run turn, cumulative session turn, max turns, and the already-fired set). It is implemented by config from the user's reminders list; the agent depends on this interface so reminder policy can be faked in tests.
type TodoItem ¶
type TodoItem struct {
ID string `json:"id"`
Content string `json:"content"`
Status string `json:"status"`
}
TodoItem represents a single todo item
type TodoUpdateChatEvent ¶
type TodoUpdateChatEvent struct {
BaseChatEvent
Todos []TodoItem
}
TodoUpdateChatEvent indicates the todo list has been updated (flows through chat event channel)
type TodoWriteToolResult ¶
type TodoWriteToolResult struct {
Todos []TodoItem `json:"todos"`
TotalTasks int `json:"total_tasks"`
CompletedTasks int `json:"completed_tasks"`
InProgressTask string `json:"in_progress_task,omitempty"`
ValidationOK bool `json:"validation_ok"`
}
TodoWriteToolResult represents the result of a TodoWrite operation
type Tool ¶
type Tool interface {
// Definition returns the tool definition for the LLM
Definition() sdk.ChatCompletionTool
// Execute runs the tool with given arguments
Execute(ctx context.Context, args map[string]any) (*ToolExecutionResult, error)
// Validate checks if the tool arguments are valid
Validate(args map[string]any) error
// IsEnabled returns whether this tool is enabled
IsEnabled() bool
// FormatResult formats tool execution results for different contexts
FormatResult(result *ToolExecutionResult, formatType FormatterType) string
// FormatPreview returns a short preview of the result for UI display
FormatPreview(result *ToolExecutionResult) string
// ShouldCollapseArg determines if an argument should be collapsed in display
ShouldCollapseArg(key string) bool
// ShouldAlwaysExpand determines if tool results should always be expanded in UI
ShouldAlwaysExpand() bool
}
Tool represents a single tool with its definition, handler, and validator
type ToolApprovalRequestedEvent ¶
type ToolApprovalRequestedEvent struct {
RequestID string
Timestamp time.Time
ToolCall sdk.ChatCompletionMessageToolCall
// Context is optional text shown above the call in the approval prompt.
// RequestApproval escalations use it for the judge's reason and the
// agent's justification; regular approvals leave it empty.
Context string
ResponseChan chan ApprovalAction `json:"-"`
}
ToolApprovalRequestedEvent is used for standard tool approval workflow. Computer-use tools use a separate pause/resume mechanism.
func (ToolApprovalRequestedEvent) GetRequestID ¶
func (e ToolApprovalRequestedEvent) GetRequestID() string
func (ToolApprovalRequestedEvent) GetTimestamp ¶
func (e ToolApprovalRequestedEvent) GetTimestamp() time.Time
type ToolApprovalResolvedEvent ¶
ToolApprovalResolvedEvent signals that a tool approval was answered (terminal or panel), so bus subscribers like the extension bridge clear their card. It is the reliable "answered" signal, replacing the racy next-event heuristic.
func (ToolApprovalResolvedEvent) GetRequestID ¶
func (e ToolApprovalResolvedEvent) GetRequestID() string
func (ToolApprovalResolvedEvent) GetTimestamp ¶
func (e ToolApprovalResolvedEvent) GetTimestamp() time.Time
type ToolApprovalResponseEvent ¶
type ToolApprovalResponseEvent struct {
Action ApprovalAction
ToolCall sdk.ChatCompletionMessageToolCall
}
ToolApprovalResponseEvent captures the user's approval decision
type ToolCancelledEvent ¶
type ToolCancelledEvent struct {
RequestID string
Timestamp time.Time
ToolCallID string
ToolName string
}
ToolCancelledEvent is published when the conversation validator synthesizes a Tool-role response for an assistant tool_call whose real execution never completed (typically because the user pressed Esc between the model emitting tool_calls and the tools running). The conversation view uses this to surface a "[cancelled]" entry so the user understands why a requested tool never produced output.
func (ToolCancelledEvent) GetRequestID ¶
func (e ToolCancelledEvent) GetRequestID() string
func (ToolCancelledEvent) GetTimestamp ¶
func (e ToolCancelledEvent) GetTimestamp() time.Time
type ToolExecutionCompletedEvent ¶
type ToolExecutionCompletedEvent struct {
SessionID string
RequestID string
Timestamp time.Time
TotalExecuted int
SuccessCount int
FailureCount int
Results []*ToolExecutionResult
}
ToolExecutionCompletedEvent indicates tool execution is complete
func (ToolExecutionCompletedEvent) GetRequestID ¶
func (e ToolExecutionCompletedEvent) GetRequestID() string
func (ToolExecutionCompletedEvent) GetTimestamp ¶
func (e ToolExecutionCompletedEvent) GetTimestamp() time.Time
type ToolExecutionProgressEvent ¶
type ToolExecutionProgressEvent struct {
BaseChatEvent
ToolCallID string
ToolName string
Arguments string
Status string
Message string
Images []ImageAttachment
}
ToolExecutionProgressEvent indicates progress in tool execution
type ToolExecutionResult ¶
type ToolExecutionResult struct {
ToolName string `json:"tool_name"`
ToolCallID string `json:"tool_call_id,omitempty"`
Arguments map[string]any `json:"arguments"`
Success bool `json:"success"`
Duration time.Duration `json:"duration"`
Error string `json:"error,omitempty"`
Data any `json:"data,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
Diff string `json:"diff,omitempty"`
Rejected bool `json:"rejected,omitempty"`
Images []ImageAttachment `json:"images,omitempty"`
}
ToolExecutionResult represents the complete result of a tool execution
type ToolManifest ¶ added in v0.216.0
type ToolManifest struct {
Name string `yaml:"name"`
Description string `yaml:"description"`
Parameters map[string]any `yaml:"parameters"`
Modes []AgentMode `yaml:"modes,omitempty"`
RequireApproval *bool `yaml:"require_approval,omitempty"`
}
ToolManifest defines a tool: the JSON Schema the model sees, the agent modes it may run in and its default approval; the Go tool registered under the same name executes it. Nil Modes means defaultToolModes and a nil RequireApproval inherits tools.safety.require_approval, so the zero value is the policy of any tool without a manifest, such as an MCP tool.
func ParseToolManifest ¶ added in v0.216.0
func ParseToolManifest(data []byte) (ToolManifest, error)
ParseToolManifest decodes and validates a manifest, rejecting unknown fields so a misspelled policy key fails loudly instead of silently defaulting.
func (ToolManifest) AvailableIn ¶ added in v0.216.0
func (m ToolManifest) AvailableIn(mode AgentMode) bool
AvailableIn reports whether the tool may run in mode.
func (ToolManifest) Definition ¶ added in v0.216.0
func (m ToolManifest) Definition() sdk.ChatCompletionTool
Definition builds the definition sent to the model. The parameters are a deep copy, so the caller may adjust them.
func (ToolManifest) RequiresApproval ¶ added in v0.216.0
func (m ToolManifest) RequiresApproval(inherited bool) bool
RequiresApproval reports whether a call needs approval: the tool's own setting when it has one, else the inherited global require_approval.
func (ToolManifest) Validate ¶ added in v0.216.0
func (m ToolManifest) Validate() error
Validate checks the name, the description and that the parameters are a JSON Schema object whose required fields are declared.
func (ToolManifest) WithRequireApproval ¶ added in v0.216.0
func (m ToolManifest) WithRequireApproval(configured *bool) ToolManifest
WithRequireApproval returns the manifest with the approval setting a user configured for the tool, when there is one.
type ToolManifestLookup ¶ added in v0.216.0
type ToolManifestLookup interface {
Manifest(name string) ToolManifest
}
ToolManifestLookup resolves a tool's manifest by name, so callers can ask for its policy (read-only, plan mode, default approval) without knowing which bounded context defines the tool.
type ToolManifests ¶ added in v0.216.0
type ToolManifests map[string]ToolManifest
ToolManifests are a bounded context's built-in tool manifests by tool name.
func LoadToolManifests ¶ added in v0.216.0
func LoadToolManifests(fsys fs.FS, dir string) (ToolManifests, error)
LoadToolManifests parses every *.yaml file in dir of fsys. Each file is named after its tool, e.g. Read.yaml.
func MustLoadToolManifests ¶ added in v0.216.0
func MustLoadToolManifests(fsys fs.FS, dir string) ToolManifests
MustLoadToolManifests is LoadToolManifests for embedded manifests, where a broken file is a programming error.
func (ToolManifests) Manifest ¶ added in v0.216.0
func (ms ToolManifests) Manifest(name string) ToolManifest
Manifest returns the named tool's manifest. A tool without one gets a manifest carrying only its name, which is the default policy.
func (ToolManifests) MustGet ¶ added in v0.216.0
func (ms ToolManifests) MustGet(name string) ToolManifest
MustGet returns a built-in tool's manifest. A built-in tool without one is a programming error.
func (ToolManifests) Names ¶ added in v0.216.0
func (ms ToolManifests) Names() []string
Names returns the tool names, in no particular order.
type ToolProgressCallback ¶ added in v0.184.0
type ToolProgressCallback func(message string)
ToolProgressCallback receives a progress line describing what a tool is currently doing. Callers throttle their own reporting; a callback must be safe to invoke from the goroutine running the tool.
func GetToolProgressCallback ¶ added in v0.184.0
func GetToolProgressCallback(ctx context.Context) ToolProgressCallback
GetToolProgressCallback retrieves the tool progress callback from context. Returns nil if the key is not set or holds another type, so callers guard with a nil check rather than assuming a reporter is always present.
type ToolService ¶
type ToolService interface {
ToolManifestLookup
ListTools() []sdk.ChatCompletionTool
ListToolsForMode(mode AgentMode) []sdk.ChatCompletionTool
ListAvailableTools() []string
ListMarkdownSubagents() []SubagentInfo
ExecuteTool(ctx context.Context, tool sdk.ChatCompletionMessageToolCallFunction) (*ToolExecutionResult, error)
ExecuteToolDirect(ctx context.Context, tool sdk.ChatCompletionMessageToolCallFunction) (*ToolExecutionResult, error)
IsToolEnabled(name string) bool
ValidateTool(name string, args map[string]any) error
GetTool(name string) (Tool, error)
}
ToolService handles tool execution
type TreeToolResult ¶
type TreeToolResult struct {
Path string `json:"path"`
Output string `json:"output"`
TotalFiles int `json:"total_files"`
TotalDirs int `json:"total_dirs"`
MaxDepth int `json:"max_depth"`
MaxFiles int `json:"max_files"`
ShowHidden bool `json:"show_hidden"`
Format string `json:"format"`
UsingNativeTree bool `json:"using_native_tree"`
Truncated bool `json:"truncated"`
}
TreeToolResult represents the result of a tree operation
type UINotifier ¶
type UINotifier interface {
Notify(event any)
}
UINotifier delivers a background-originated event to the single Bubble Tea Update loop. It is the one ingress every background producer uses to push work or status changes into the UI, replacing the per-source self-rescheduling pollers. The only production implementation wraps (*tea.Program).Send and lives in cmd/chat.go; keeping this interface tea-free lets services depend on it without importing bubbletea. The event is an `any` (tea.Msg is itself `any`).
type UserInputEvent ¶
type UserInputEvent struct {
Content string
Images []ImageAttachment
FromExtension bool
}
UserInputEvent represents user input submission. FromExtension marks input injected over the browser-extension bridge: the sender watches the side panel, which has no terminal question UI, so interactive gates (like the catalog-skill install confirmation) must not block on it.
type UserMessageChatEvent ¶ added in v0.182.0
type UserMessageChatEvent struct {
BaseChatEvent
Content string
}
UserMessageChatEvent mirrors a user message that entered the conversation (typed in the TUI, queued, or sent from the extension) so external consumers such as the extension bridge can render it. Content is the plain text.
type UserQuestion ¶
type UserQuestion struct {
Header string `json:"header"`
Question string `json:"question"`
Options []UserQuestionOption `json:"options"`
MultiSelect bool `json:"multiSelect"`
}
UserQuestion is one clarifying question the agent asks the user via the AskUserQuestion tool. It mirrors the tool schema: a short header chip, the question text, 2-4 options, and whether multiple options may be selected.
type UserQuestionAnswer ¶
type UserQuestionAnswer struct {
Header string `json:"header"`
Question string `json:"question"`
SelectedLabels []string `json:"selectedLabels"`
OtherText string `json:"otherText,omitempty"`
}
UserQuestionAnswer is the user's response to one UserQuestion. SelectedLabels holds the chosen option label(s); OtherText is non-empty when the user picked the synthesized "Other" free-text choice (it may coexist with selected labels in multi-select). Header and Question are echoed so the tool result is self-describing for the model.
type UserQuestionBroker ¶
type UserQuestionBroker interface {
AskUserQuestions(ctx context.Context, questions []UserQuestion) (answers []UserQuestionAnswer, ok bool, err error)
}
UserQuestionBroker publishes an interactive clarifying-question request to the user (chat TUI, or a headless host over stdin) and blocks until the user answers or the context is cancelled. It is injected into the AskUserQuestion tool's execution context when UserQuestionsAvailable reports a host that can render the form. Returns ok=false when the user dismisses the form (the response channel is closed without a value) or on cancellation.
func GetUserQuestionBroker ¶
func GetUserQuestionBroker(ctx context.Context) UserQuestionBroker
GetUserQuestionBroker retrieves the question broker from context. Returns nil if the key is not set or the value is not a UserQuestionBroker.
type UserQuestionOption ¶
type UserQuestionOption struct {
Label string `json:"label"`
Description string `json:"description"`
}
UserQuestionOption is a single selectable choice within a UserQuestion.
type UserQuestionRequestedEvent ¶
type UserQuestionRequestedEvent struct {
RequestID string
ToolCallID string
Timestamp time.Time
Questions []UserQuestion
ResponseChan chan []UserQuestionAnswer `json:"-"`
}
UserQuestionRequestedEvent is published when the AskUserQuestion tool asks the user one or more interactive clarifying questions. ResponseChan delivers the collected answers back to the blocked tool goroutine; closing it without a value signals cancellation.
func (UserQuestionRequestedEvent) GetRequestID ¶
func (e UserQuestionRequestedEvent) GetRequestID() string
func (UserQuestionRequestedEvent) GetTimestamp ¶
func (e UserQuestionRequestedEvent) GetTimestamp() time.Time
type VideoRequest ¶ added in v0.206.0
type VideoRequest struct {
Prompt string
Seconds string
Size string
AvatarPath string
AudioPath string
ReferencePaths []string
}
VideoRequest is one video render: a text prompt (required unless the audio drives the render), the optional seconds and size passthroughs, the optional avatar portrait and driving audio for lip-synced talking clips, and the optional reference images of the subject (e.g. an avatar from several angles) that keep them consistent in a prompt render. The gateway rejects reference images together with a portrait.
func (VideoRequest) IsAvatar ¶ added in v0.206.0
func (r VideoRequest) IsAvatar() bool
IsAvatar reports whether the request is a lip-synced avatar render: the audio clip drives it, so it goes to the avatar model.
type VideoService ¶ added in v0.206.0
type VideoService interface {
Render(ctx context.Context, request VideoRequest, outPath string) error
}
VideoService renders a video clip through the gateway's Videos API, writing MP4 content to outPath. With an avatar and audio it renders a lip-synced talking clip; the render blocks until the gateway job completes, fails or the context ends.
type WebSearchResponse ¶
type WebSearchResponse struct {
Query string `json:"query"`
Engine string `json:"engine"`
Results []WebSearchResult `json:"results"`
Total int `json:"total"`
Time time.Duration `json:"time"`
Error string `json:"error,omitempty"`
}
WebSearchResponse represents the complete search response
type WebSearchResult ¶
type WebSearchResult struct {
Title string `json:"title"`
URL string `json:"url"`
Snippet string `json:"snippet"`
}
WebSearchResult represents a single search result
Source Files
¶
- agent.go
- annotation.go
- approval_escalation.go
- approval_policy.go
- capabilities.go
- chat.go
- chat_events.go
- context.go
- context_helpers.go
- events.go
- github.go
- hooks.go
- judge.go
- media.go
- services.go
- session_state.go
- skills.go
- tool_contracts.go
- tool_manifest.go
- tools.go
- ui_events.go
- ui_notifier.go
- user_question.go
- values.go
- web.go