Documentation
¶
Overview ¶
Package extensions provides the Go-native extension registry, API surface, and ordered event runner used by the coding agent.
Index ¶
- Constants
- Variables
- func EmitSessionShutdown(ctx context.Context, runner *Runner, event SessionShutdownEvent) bool
- func LoadCompiled(cwd string, catalog []CompiledExtension) (*Registry, []CompiledLoadError)
- func WithInputHandler(ctx context.Context, handler InputHandler) context.Context
- func WithInputOptions(ctx context.Context, options InputOptions) context.Context
- func WrapRegisteredTool(tool RegisteredTool, runner *Runner) engine.AgentTool
- type API
- type Actions
- type ActivityOutcome
- type AfterProviderResponseEvent
- type AgentBeforeSettleEvent
- type AgentEndEvent
- type AgentSettledEvent
- type AgentStartEvent
- type AuthStatus
- type AutocompleteEditorComponent
- type AutocompleteItem
- type AutocompleteProvider
- type AutocompleteProviderFactory
- type AutocompleteRequest
- type AutocompleteResult
- type BashResult
- type BeforeAgentStartCombinedResult
- type BeforeAgentStartEvent
- type BeforeAgentStartResult
- type BeforeProviderHeadersEvent
- type BeforeProviderRequestEvent
- type BoundaryContextPreview
- type BoundaryDispatch
- type BoundaryResult
- type BoundaryState
- type Command
- type CommandActions
- type CommandContext
- type CompactOptions
- type CompactionReason
- type CompiledExtension
- type CompiledLoadError
- type Component
- type ComponentFactory
- type Context
- type ContextActions
- type ContextEvent
- type ContextFile
- type ContextResult
- type ContextUsage
- type ContextWithSystemEvent
- type CustomDone
- type CustomFactory
- type CustomMessage
- type CustomOptions
- type DeliveryMode
- type Diagnostic
- type DialogOptions
- type DiscoveredPath
- type DiscoveredResources
- type DisposableComponent
- type EditorComponent
- type EditorFactory
- type EntryRenderOptions
- type EntryRenderer
- type Event
- type EventBus
- type EventListener
- type EventType
- type ExecOptions
- type ExecResult
- type Extension
- type ExtensionError
- type Factory
- type Flag
- type FlagType
- type FocusableComponent
- type FooterDataProvider
- type FooterFactory
- type ForkOptions
- type ForkPosition
- type Handler
- type HeaderFactory
- type InputAction
- type InputComponent
- type InputEvent
- type InputHandler
- type InputOptions
- type InputPresentation
- type InputResult
- type InputSource
- type KeybindingConflict
- type KeybindingDefinition
- type Keybindings
- type LoadoutTool
- type MarkdownTransformContext
- type MarkdownTransformer
- type MessageEndEvent
- type MessageEndResult
- type MessageRenderOptions
- type MessageRenderer
- type MessageStartEvent
- type MessageUpdateEvent
- type Mode
- type ModelRegistry
- type ModelSelectEvent
- type ModelSelectSource
- type NavigateTreeOptions
- type NewSessionOptions
- type NoopUI
- func (NoopUI) AddAutocompleteProvider(AutocompleteProviderFactory)
- func (NoopUI) Confirm(context.Context, string, string, *DialogOptions) (bool, error)
- func (NoopUI) Custom(context.Context, CustomFactory, *CustomOptions) (any, bool, error)
- func (NoopUI) Editor(context.Context, string, *string) (string, bool, error)
- func (NoopUI) GetAllThemes() []ThemeInfo
- func (NoopUI) GetEditorComponent() EditorFactory
- func (NoopUI) GetEditorText() string
- func (NoopUI) GetTheme(string) Theme
- func (NoopUI) GetToolsExpanded() bool
- func (NoopUI) Input(context.Context, string, *string, *DialogOptions) (string, bool, error)
- func (NoopUI) Notify(string, NotificationType)
- func (NoopUI) OnTerminalInput(TerminalInputHandler) func()
- func (NoopUI) PasteToEditor(string)
- func (NoopUI) Select(context.Context, string, []string, *DialogOptions) (string, bool, error)
- func (NoopUI) SetEditorComponent(EditorFactory)
- func (NoopUI) SetEditorText(string)
- func (NoopUI) SetFooter(FooterFactory)
- func (NoopUI) SetHeader(HeaderFactory)
- func (NoopUI) SetHiddenThinkingLabel(*string)
- func (NoopUI) SetStatus(string, *string)
- func (NoopUI) SetTheme(any) ThemeSetResult
- func (NoopUI) SetTitle(string)
- func (NoopUI) SetToolsExpanded(bool)
- func (NoopUI) SetWidget(string, *Widget, *WidgetOptions)
- func (NoopUI) SetWorkingIndicator(*WorkingIndicatorOptions)
- func (NoopUI) SetWorkingMessage(*string)
- func (NoopUI) SetWorkingVisible(bool)
- func (NoopUI) Theme() Theme
- type NotificationType
- type OAuthAuthInfo
- type OAuthCredentials
- type OAuthDeviceCodeInfo
- type OAuthLoginCallbacks
- type OAuthPrompt
- type OAuthProvider
- type OAuthSelectOption
- type OAuthSelectPrompt
- type OverlayAnchor
- type OverlayHandle
- type OverlayOptions
- type OverlayUnfocusOptions
- type ProjectTrustContext
- type ProjectTrustDecision
- type ProjectTrustEvent
- type ProjectTrustResult
- type Provider
- type ProviderConfig
- type ProviderModelConfig
- type ProviderModelStore
- type ProviderModelsStoreEntry
- type ProviderRequestResult
- type ProviderStreamEvent
- type ReadonlySessionManager
- type RefreshModelsContext
- type RegisterOption
- type RegisteredTool
- type Registry
- func (registry *Registry) BindModelRegistry(models ModelRegistry, report func(ExtensionError))
- func (registry *Registry) Events() EventBus
- func (registry *Registry) Extensions() []*Extension
- func (registry *Registry) Fresh(cwd string) (*Registry, error)
- func (registry *Registry) HasPath(path string) bool
- func (registry *Registry) Len() int
- func (registry *Registry) OmitReplaced() []string
- func (registry *Registry) Register(path string, factory Factory, options ...RegisterOption) error
- func (registry *Registry) RegisteredFlags() []Flag
- func (registry *Registry) SetFlagValue(name string, value any)
- type RenderShell
- type ReplacedSessionContext
- type ResolvedCommand
- type ResourcesDiscoverEvent
- type ResourcesDiscoverReason
- type ResourcesDiscoverResult
- type Runner
- func (runner *Runner) ActiveTools() ([]string, error)
- func (runner *Runner) AllRegisteredTools() []RegisteredTool
- func (runner *Runner) BindCommandContext(actions *CommandActions)
- func (runner *Runner) Command(name string) *ResolvedCommand
- func (runner *Runner) CreateCommandContext() CommandContext
- func (runner *Runner) CreateContext() Context
- func (runner *Runner) CreateReplacedSessionContext() ReplacedSessionContext
- func (runner *Runner) CreateToolContext(toolCallID string) Context
- func (runner *Runner) Emit(ctx context.Context, event Event) any
- func (runner *Runner) EmitBeforeAgentStart(ctx context.Context, prompt string, images []*ai.ImageContent, ...) *BeforeAgentStartCombinedResult
- func (runner *Runner) EmitBeforeProviderHeaders(ctx context.Context, headers ai.ProviderHeaders) ai.ProviderHeaders
- func (runner *Runner) EmitBeforeProviderRequest(ctx context.Context, payload any) any
- func (runner *Runner) EmitBoundary(ctx context.Context, base Event, ...) BoundaryDispatch
- func (runner *Runner) EmitBoundaryError(event EventType, message string)
- func (runner *Runner) EmitContext(ctx context.Context, messages engine.AgentMessages) engine.AgentMessages
- func (runner *Runner) EmitInput(ctx context.Context, text string, images []*ai.ImageContent, ...) InputResult
- func (runner *Runner) EmitMessageEnd(ctx context.Context, event MessageEndEvent) engine.AgentMessage
- func (runner *Runner) EmitProjectTrust(ctx context.Context, event ProjectTrustEvent, trustContext Context) (*ProjectTrustResult, []ExtensionError)
- func (runner *Runner) EmitResourcesDiscover(ctx context.Context, cwd string, reason ResourcesDiscoverReason) DiscoveredResources
- func (runner *Runner) EmitToolCall(ctx context.Context, event ToolCallEvent) *ToolCallResult
- func (runner *Runner) EmitToolResult(ctx context.Context, event ToolResultEvent) *ToolResultResult
- func (runner *Runner) EmitUserBashChecked(ctx context.Context, event UserBashEvent) (*UserBashResult, error)
- func (runner *Runner) EntryRenderer(customType string) EntryRenderer
- func (runner *Runner) Events() EventBus
- func (runner *Runner) ExecuteCommand(ctx context.Context, name, args string) bool
- func (runner *Runner) ExtensionPaths() []string
- func (runner *Runner) FlagValues() map[string]any
- func (runner *Runner) Flags() map[string]Flag
- func (runner *Runner) HasHandlers(event EventType) bool
- func (runner *Runner) HasUI() bool
- func (runner *Runner) Invalidate(message string)
- func (runner *Runner) MessageRenderer(customType string) MessageRenderer
- func (runner *Runner) ModelRegistry() ModelRegistry
- func (runner *Runner) OnError(listener func(ExtensionError)) func()
- func (runner *Runner) RegisteredCommands() []ResolvedCommand
- func (runner *Runner) RegisteredFlags() []Flag
- func (runner *Runner) ReportError(extensionError ExtensionError)
- func (runner *Runner) SetFlagValue(name string, value any)
- func (runner *Runner) SetToolCallHost(host *ToolCallHost)
- func (runner *Runner) SetUI(ui UI, mode Mode)
- func (runner *Runner) ShortcutDiagnostics() []Diagnostic
- func (runner *Runner) ShortcutOrder() []string
- func (runner *Runner) Shortcuts(bindings map[string][]string) map[string]Shortcut
- func (runner *Runner) Shutdown()
- func (runner *Runner) ToolDefinition(name string) *ToolDefinition
- func (runner *Runner) UI() UI
- type RunnerOptions
- type ScopedModel
- type SendMessageOptions
- type SendUserMessageOptions
- type SessionBeforeCompactEvent
- type SessionBeforeCompactResult
- type SessionBeforeForkEvent
- type SessionBeforeForkResult
- type SessionBeforeSwitchEvent
- type SessionBeforeSwitchResult
- type SessionBeforeTreeEvent
- type SessionBeforeTreeResult
- type SessionBoundaryDraft
- type SessionCompactEvent
- type SessionCompactFailedEvent
- type SessionInfoChangedEvent
- type SessionReplacementResult
- type SessionShutdownEvent
- type SessionShutdownReason
- type SessionStartEvent
- type SessionStartReason
- type SessionSwitchReason
- type SessionTreeEvent
- type Shortcut
- type Skill
- type SlashCommandInfo
- type SlashCommandSource
- type SourceInfo
- type SourceOrigin
- type SourceScope
- type SwitchSessionOptions
- type SystemPromptOptions
- type TerminalInputHandler
- type TerminalInputResult
- type Theme
- type ThemeInfo
- type ThemeSetResult
- type ThinkingLevelSelectEvent
- type ToolAnnotations
- type ToolCallEvent
- type ToolCallHost
- type ToolCallResult
- type ToolContext
- type ToolDefinition
- type ToolExecutionEndEvent
- type ToolExecutionStartEvent
- type ToolExecutionUpdateEvent
- type ToolExposure
- type ToolInfo
- type ToolLoadout
- type ToolLoadoutChanges
- type ToolNamespace
- type ToolRenderContext
- type ToolRenderResultOptions
- type ToolResultEvent
- type ToolResultResult
- type TreePreparation
- type TreeSummary
- type TrustUI
- type TurnEndEvent
- type TurnStartEvent
- type UI
- type UIHost
- type UIPromptEndEvent
- type UIPromptKind
- type UIPromptStartEvent
- type UserBashEvent
- type UserBashResult
- type Widget
- type WidgetOptions
- type WidgetPlacement
- type WorkingIndicatorOptions
Constants ¶
const BuiltinPathPrefix = "builtin:"
BuiltinPathPrefix names built-in extensions and tools: "builtin:<name>".
Variables ¶
var ( ErrRuntimeNotInitialized = errors.New("Extension runtime not initialized") )
Functions ¶
func EmitSessionShutdown ¶
func EmitSessionShutdown(ctx context.Context, runner *Runner, event SessionShutdownEvent) bool
func LoadCompiled ¶
func LoadCompiled(cwd string, catalog []CompiledExtension) (*Registry, []CompiledLoadError)
LoadCompiled registers the enabled catalog entries; enablement decisions belong to the caller (agent/assembly resolves settings into DefaultEnabled).
func WithInputHandler ¶ added in v0.9.0
func WithInputHandler(ctx context.Context, handler InputHandler) context.Context
func WithInputOptions ¶ added in v0.9.0
func WithInputOptions(ctx context.Context, options InputOptions) context.Context
func WrapRegisteredTool ¶
func WrapRegisteredTool(tool RegisteredTool, runner *Runner) engine.AgentTool
Types ¶
type API ¶
type API interface {
On(EventType, Handler)
// OnWithUnsubscribe registers a handler and returns an idempotent unsubscribe.
OnWithUnsubscribe(EventType, Handler) func()
RegisterTool(ToolDefinition)
RegisterCommand(string, Command)
RegisterShortcut(string, Shortcut)
RegisterFlag(string, Flag)
GetFlag(string) (any, bool)
RegisterMessageRenderer(string, MessageRenderer)
RegisterEntryRenderer(string, EntryRenderer)
SendMessage(context.Context, CustomMessage, *SendMessageOptions) error
SendUserMessage(context.Context, ai.UserContent, *SendUserMessageOptions) error
AppendEntry(context.Context, string, any) error
SetSessionName(context.Context, string) error
GetSessionName(context.Context) (*string, error)
SetLabel(context.Context, string, *string) error
Exec(context.Context, string, []string, *ExecOptions) (ExecResult, error)
GetActiveTools() ([]string, error)
GetAllTools() ([]ToolInfo, error)
SetActiveTools([]string) error
GetCommands() ([]SlashCommandInfo, error)
SetModel(context.Context, *ai.Model) (bool, error)
GetThinkingLevel() (engine.ThinkingLevel, error)
SetThinkingLevel(engine.ThinkingLevel) error
RegisterProvider(Provider)
RegisterProviderConfig(string, ProviderConfig)
UnregisterProvider(string)
Events() EventBus
}
type Actions ¶
type Actions struct {
SendMessage func(context.Context, CustomMessage, *SendMessageOptions) error
SendUserMessage func(context.Context, ai.UserContent, *SendUserMessageOptions) error
AppendEntry func(context.Context, string, any) error
SetSessionName func(context.Context, string) error
GetSessionName func(context.Context) (*string, error)
SetLabel func(context.Context, string, *string) error
GetActiveTools func() ([]string, error)
GetAllTools func() ([]ToolInfo, error)
SetActiveTools func([]string) error
RefreshTools func()
GetCommands func() ([]SlashCommandInfo, error)
SetModel func(context.Context, *ai.Model) (bool, error)
GetThinkingLevel func() (engine.ThinkingLevel, error)
SetThinkingLevel func(engine.ThinkingLevel) error
RegisterProvider func(Provider) error
RegisterProviderConfig func(string, ProviderConfig) error
UnregisterProvider func(string) error
}
type ActivityOutcome ¶ added in v0.14.0
type ActivityOutcome string
ActivityOutcome is how the latest response ended: "completed", "aborted" or "error".
type AfterProviderResponseEvent ¶
func (AfterProviderResponseEvent) Type ¶
func (AfterProviderResponseEvent) Type() EventType
type AgentBeforeSettleEvent ¶ added in v0.14.0
type AgentBeforeSettleEvent struct{ BoundaryState }
AgentBeforeSettleEvent is the final actionable boundary before agent_settled.
func (AgentBeforeSettleEvent) Type ¶ added in v0.14.0
func (AgentBeforeSettleEvent) Type() EventType
type AgentEndEvent ¶
type AgentEndEvent struct{ Messages engine.AgentMessages }
func (AgentEndEvent) Type ¶
func (AgentEndEvent) Type() EventType
type AgentSettledEvent ¶
type AgentSettledEvent struct{}
func (AgentSettledEvent) Type ¶
func (AgentSettledEvent) Type() EventType
type AgentStartEvent ¶
type AgentStartEvent struct{}
func (AgentStartEvent) Type ¶
func (AgentStartEvent) Type() EventType
type AuthStatus ¶
type AutocompleteEditorComponent ¶
type AutocompleteEditorComponent interface {
EditorComponent
SetAutocompleteProvider(AutocompleteProvider)
}
AutocompleteEditorComponent is the optional editor capability used when an extension replaces the active editor while autocomplete is configured.
type AutocompleteItem ¶
type AutocompleteProvider ¶
type AutocompleteProvider interface {
TriggerCharacters() []string
GetSuggestions(context.Context, AutocompleteRequest) (*AutocompleteResult, error)
ApplyCompletion(AutocompleteRequest, AutocompleteItem, string) ([]string, int, int)
ShouldTriggerFileCompletion(AutocompleteRequest) bool
}
type AutocompleteProviderFactory ¶
type AutocompleteProviderFactory func(AutocompleteProvider) AutocompleteProvider
type AutocompleteRequest ¶
type AutocompleteResult ¶
type AutocompleteResult struct {
Prefix string
Items []AutocompleteItem
}
type BashResult ¶
type BeforeAgentStartCombinedResult ¶
type BeforeAgentStartCombinedResult struct {
Messages []CustomMessage `json:"messages"`
SystemPrompt *string `json:"-"`
SystemPromptOptions SystemPromptOptions `json:"systemPromptOptions"`
}
type BeforeAgentStartEvent ¶
type BeforeAgentStartEvent struct {
Prompt string
Images []*ai.ImageContent
SystemPrompt string
SystemPromptOptions SystemPromptOptions
}
func (BeforeAgentStartEvent) Type ¶
func (BeforeAgentStartEvent) Type() EventType
type BeforeAgentStartResult ¶
type BeforeAgentStartResult struct {
Message *CustomMessage
SystemPrompt *string
}
type BeforeProviderHeadersEvent ¶
type BeforeProviderHeadersEvent struct{ Headers ai.ProviderHeaders }
func (BeforeProviderHeadersEvent) Type ¶
func (BeforeProviderHeadersEvent) Type() EventType
type BeforeProviderRequestEvent ¶
type BeforeProviderRequestEvent struct{ Payload any }
func (BeforeProviderRequestEvent) Type ¶
func (BeforeProviderRequestEvent) Type() EventType
type BoundaryContextPreview ¶ added in v0.14.0
type BoundaryContextPreview struct {
ContextEntries []session.SessionEntry `json:"contextEntries"`
ContextMessages engine.AgentMessages `json:"contextMessages"`
LLMMessages ai.MessageList `json:"llmMessages"`
PendingMessages engine.AgentMessages `json:"pendingMessages"`
CanContinue bool `json:"canContinue"`
}
BoundaryContextPreview is the context the next request would see with the proposed entries applied.
type BoundaryDispatch ¶ added in v0.14.0
type BoundaryDispatch struct {
Entries []SessionBoundaryDraft
Continue bool
Context BoundaryContextPreview
Valid bool
}
BoundaryDispatch is the outcome of an actionable boundary. Invalid entries (the last preview failed to build) discard every proposal.
type BoundaryResult ¶ added in v0.14.0
type BoundaryResult struct {
Entries *[]SessionBoundaryDraft `json:"entries,omitempty"`
Continue *bool `json:"continue,omitempty"`
}
BoundaryResult replaces the chained entries and/or continuation when set.
type BoundaryState ¶ added in v0.14.0
type BoundaryState struct {
Entries []SessionBoundaryDraft `json:"entries"`
Continue bool `json:"continue"`
Context BoundaryContextPreview `json:"context"`
Outcome ActivityOutcome `json:"outcome"`
}
BoundaryState is what each handler of an actionable boundary sees: the entries and continuation chained by earlier handlers, and their preview.
type Command ¶
type Command struct {
// SettingsLabel adds this command as a native Settings page when non-empty.
SettingsLabel string
Name string
SourceInfo SourceInfo
Description string
GetArgumentCompletions func(context.Context, string) ([]AutocompleteItem, error)
Handler func(context.Context, string, CommandContext) error
}
type CommandActions ¶
type CommandActions struct {
WaitForIdle func(context.Context) error
NewSession func(context.Context, *NewSessionOptions) (SessionReplacementResult, error)
Fork func(context.Context, string, *ForkOptions) (SessionReplacementResult, error)
SwitchSession func(context.Context, string, *SwitchSessionOptions) (SessionReplacementResult, error)
Reload func(context.Context) error
}
type CommandContext ¶
type CommandContext interface {
Context
GetSystemPromptOptions() SystemPromptOptions
WaitForIdle(context.Context) error
NewSession(context.Context, *NewSessionOptions) (SessionReplacementResult, error)
Fork(context.Context, string, *ForkOptions) (SessionReplacementResult, error)
SwitchSession(context.Context, string, *SwitchSessionOptions) (SessionReplacementResult, error)
Reload(context.Context) error
}
type CompactOptions ¶
type CompactOptions struct {
CustomInstructions string
OnComplete func(session.CompactionResult)
OnError func(error)
}
type CompactionReason ¶
type CompactionReason string
const ( CompactionManual CompactionReason = "manual" CompactionThreshold CompactionReason = "threshold" CompactionOverflow CompactionReason = "overflow" )
type CompiledExtension ¶
type CompiledLoadError ¶
func (CompiledLoadError) Error ¶
func (loadError CompiledLoadError) Error() string
type ComponentFactory ¶
type Context ¶
type Context interface {
UI() UI
Mode() Mode
HasUI() bool
CWD() string
SessionManager() ReadonlySessionManager
ModelRegistry() ModelRegistry
Model() *ai.Model
ScopedModels() []ScopedModel
// ThinkingLevel is the current thinking level, when provided by the
// session runtime; empty otherwise.
ThinkingLevel() engine.ThinkingLevel
IsIdle() bool
IsProjectTrusted() bool
Signal() context.Context
Abort()
HasPendingMessages() bool
Shutdown()
GetContextUsage() *ContextUsage
Compact(*CompactOptions)
GetSystemPrompt() string
}
type ContextActions ¶
type ContextActions struct {
RequestInput InputHandler
GetModel func() *ai.Model
GetScopedModels func() []ScopedModel
IsIdle func() bool
IsProjectTrusted func() bool
GetSignal func() context.Context
Abort func()
HasPendingMessages func() bool
Shutdown func()
GetContextUsage func() *ContextUsage
Compact func(*CompactOptions)
GetSystemPrompt func() string
GetSystemPromptOptions func() SystemPromptOptions
}
type ContextEvent ¶
type ContextEvent struct{ Messages engine.AgentMessages }
ContextEvent carries the conversation without system messages; the prompt and tool state are restored after each handler.
func (ContextEvent) Type ¶
func (ContextEvent) Type() EventType
type ContextFile ¶
type ContextResult ¶
type ContextResult struct{ Messages engine.AgentMessages }
type ContextUsage ¶
type ContextWithSystemEvent ¶ added in v0.14.0
type ContextWithSystemEvent struct{ Messages engine.AgentMessages }
ContextWithSystemEvent runs after every context handler on the full transcript, system messages included; its result is sent as returned.
func (ContextWithSystemEvent) Type ¶ added in v0.14.0
func (ContextWithSystemEvent) Type() EventType
type CustomDone ¶
type CustomDone func(any)
type CustomFactory ¶
type CustomFactory func(UIHost, Theme, Keybindings, CustomDone) (Component, error)
type CustomMessage ¶
type CustomOptions ¶
type CustomOptions struct {
Overlay bool
StaticOverlayOptions *OverlayOptions
DynamicOverlayOptions func() OverlayOptions
OnHandle func(OverlayHandle)
}
func ModalOptions ¶ added in v0.10.0
func ModalOptions() *CustomOptions
ModalOptions keeps Orb dialogs readable on wide terminals and usable on narrow ones.
type DeliveryMode ¶
type DeliveryMode string
const ( DeliverSteer DeliveryMode = "steer" DeliverFollowUp DeliveryMode = "followUp" DeliverNextTurn DeliveryMode = "nextTurn" )
type Diagnostic ¶
type DialogOptions ¶
type DiscoveredPath ¶
type DiscoveredResources ¶
type DiscoveredResources struct {
SkillPaths []DiscoveredPath `json:"skillPaths"`
PromptPaths []DiscoveredPath `json:"promptPaths"`
ThemePaths []DiscoveredPath `json:"themePaths"`
}
type DisposableComponent ¶
type DisposableComponent interface {
Component
Dispose()
}
type EditorComponent ¶
type EditorFactory ¶
type EditorFactory func(UIHost, Theme, Keybindings) EditorComponent
type EntryRenderOptions ¶
type EntryRenderOptions struct{ Expanded bool }
type EntryRenderer ¶
type EntryRenderer func(any, EntryRenderOptions, Theme) Component
type EventBus ¶
type EventBus interface {
Emit(context.Context, string, any) []error
On(string, EventListener) func()
Clear()
}
func NewEventBus ¶
func NewEventBus() EventBus
type EventType ¶
type EventType string
const ( EventProjectTrust EventType = "project_trust" EventResourcesDiscover EventType = "resources_discover" EventSessionStart EventType = "session_start" EventSessionInfoChanged EventType = "session_info_changed" EventSessionBeforeSwitch EventType = "session_before_switch" EventSessionBeforeFork EventType = "session_before_fork" EventSessionBeforeCompact EventType = "session_before_compact" EventSessionCompact EventType = "session_compact" EventSessionCompactFailed EventType = "session_compact_failed" EventSessionShutdown EventType = "session_shutdown" EventSessionBeforeTree EventType = "session_before_tree" EventSessionTree EventType = "session_tree" EventContext EventType = "context" EventContextWithSystem EventType = "context_with_system" EventBeforeProviderRequest EventType = "before_provider_request" EventBeforeProviderHeaders EventType = "before_provider_headers" EventAfterProviderResponse EventType = "after_provider_response" EventProviderStreamEvent EventType = "provider_stream_event" EventBeforeAgentStart EventType = "before_agent_start" EventAgentStart EventType = "agent_start" EventAgentEnd EventType = "agent_end" EventAgentBeforeSettle EventType = "agent_before_settle" EventAgentSettled EventType = "agent_settled" EventUIPromptStart EventType = "ui_prompt_start" EventUIPromptEnd EventType = "ui_prompt_end" EventTurnStart EventType = "turn_start" EventTurnEnd EventType = "turn_end" EventMessageStart EventType = "message_start" EventMessageUpdate EventType = "message_update" EventMessageEnd EventType = "message_end" EventToolExecutionStart EventType = "tool_execution_start" EventToolExecutionUpdate EventType = "tool_execution_update" EventToolExecutionEnd EventType = "tool_execution_end" EventModelSelect EventType = "model_select" EventThinkingLevelSelect EventType = "thinking_level_select" EventToolCall EventType = "tool_call" EventToolResult EventType = "tool_result" EventUserBash EventType = "user_bash" EventInput EventType = "input" )
type ExecOptions ¶
type ExecResult ¶
type ExecResult struct {
Stdout string `json:"stdout"`
Stderr string `json:"stderr"`
Code int `json:"code"`
Killed bool `json:"killed"`
}
func Exec ¶
func Exec(ctx context.Context, command string, args []string, options *ExecOptions) (ExecResult, error)
type Extension ¶
type Extension struct {
Path string
ResolvedPath string
Hidden bool
// Replaceable built-ins step aside for an extension that registers one of
// their tool, command, or flag names.
Replaceable bool
SourceInfo SourceInfo
// contains filtered or unexported fields
}
type ExtensionError ¶
type FocusableComponent ¶ added in v0.10.0
type FocusableComponent interface {
InputComponent
SetFocused(bool)
}
FocusableComponent is an InputComponent that tracks focus.
type FooterDataProvider ¶
type FooterDataProvider interface {
}
type FooterFactory ¶
type FooterFactory func(UIHost, Theme, FooterDataProvider) Component
type ForkOptions ¶
type ForkOptions struct {
Position ForkPosition
WithSession func(context.Context, ReplacedSessionContext) error
}
type ForkPosition ¶
type ForkPosition string
const ( ForkBefore ForkPosition = "before" ForkAt ForkPosition = "at" )
type HeaderFactory ¶
type InputAction ¶
type InputAction string
const ( InputContinue InputAction = "continue" InputTransform InputAction = "transform" InputHandled InputAction = "handled" )
type InputComponent ¶ added in v0.10.0
InputComponent receives raw terminal input while focused. It is how out-of-process components take keys without linking a UI toolkit; UI drivers adapt it to their own key events.
type InputEvent ¶
type InputEvent struct {
Text string
Images []*ai.ImageContent
Source InputSource
StreamingBehavior *DeliveryMode
}
func (InputEvent) Type ¶
func (InputEvent) Type() EventType
type InputHandler ¶ added in v0.9.0
InputHandler routes extension questions through an attached runtime controller.
func InputHandlerFromContext ¶ added in v0.9.0
func InputHandlerFromContext(ctx context.Context) InputHandler
type InputOptions ¶ added in v0.9.0
type InputOptions struct {
Presentation *InputPresentation
Render func(context.Context, UI) (string, error)
Validate func(string) error
}
func InputOptionsFromContext ¶ added in v0.9.0
func InputOptionsFromContext(ctx context.Context) InputOptions
type InputPresentation ¶ added in v0.9.0
type InputPresentation struct {
Kind string `json:"kind"`
Data json.RawMessage `json:"data"`
}
InputPresentation is optional display data; authorization remains with the runtime.
type InputResult ¶
type InputResult struct {
Action InputAction `json:"action"`
Text string `json:"text,omitempty"`
Images []*ai.ImageContent `json:"images,omitempty"`
}
type InputSource ¶
type InputSource string
const ( InputInteractive InputSource = "interactive" InputRPC InputSource = "rpc" InputExtension InputSource = "extension" )
type KeybindingConflict ¶
type KeybindingDefinition ¶
type Keybindings ¶
type LoadoutTool ¶ added in v0.14.0
type LoadoutTool struct {
Name string `json:"name"`
Label string `json:"label"`
Description string `json:"description"`
Parameters ai.JSONSchema `json:"parameters"`
}
LoadoutTool is one tool as a loadout lists it.
type MarkdownTransformer ¶
type MarkdownTransformer func(markdown string, context MarkdownTransformContext) string
MarkdownTransformer rewrites interactive message markdown before rendering. Extension registration is deferred; interactive mode composes the built-in transformers as a list.
type MessageEndEvent ¶
type MessageEndEvent struct{ Message engine.AgentMessage }
func (MessageEndEvent) Type ¶
func (MessageEndEvent) Type() EventType
type MessageEndResult ¶
type MessageEndResult struct{ Message engine.AgentMessage }
type MessageRenderOptions ¶
MessageRenderOptions.OutputPad is the horizontal padding configured by the outputPad setting.
type MessageRenderer ¶
type MessageRenderer func(CustomMessage, MessageRenderOptions, Theme) Component
type MessageStartEvent ¶
type MessageStartEvent struct{ Message engine.AgentMessage }
func (MessageStartEvent) Type ¶
func (MessageStartEvent) Type() EventType
type MessageUpdateEvent ¶
type MessageUpdateEvent struct {
Message engine.AgentMessage
AssistantMessageEvent ai.AssistantMessageEvent
}
func (MessageUpdateEvent) Type ¶
func (MessageUpdateEvent) Type() EventType
type ModelRegistry ¶
type ModelRegistry interface {
Reload() error
Error() string
Models() []ai.Model
Find(provider, id string) (ai.Model, bool)
HasConfiguredAuth(provider string, env map[string]string) bool
GetProviderAuthStatus(provider string, env map[string]string) AuthStatus
IsUsingOAuth(provider string) bool
Available(env map[string]string) []ai.Model
AvailableWithError(env map[string]string) ([]ai.Model, error)
ResolveAPIKey(context.Context, string, map[string]string) (*string, error)
ResolveProviderAuth(context.Context, string, map[string]string) (*aiauth.AuthResult, error)
ResolveModelHeaders(context.Context, ai.Model, map[string]string, ...*string) (*map[string]string, error)
StreamSimple(context.Context, *ai.Model, ai.Context, *ai.SimpleStreamOptions) (ai.AssistantMessageEventStream, error)
Provider(string) (Provider, bool)
ProviderDisplayName(string) string
ProviderAuth(string) aiauth.ProviderAuth
RegisteredProviderConfig(string) (ProviderConfig, bool)
RegisteredNativeProvider(string) (Provider, bool)
RegisteredProviderIDs() []string
RegisterProvider(Provider) error
RegisterProviderConfig(string, ProviderConfig) error
UnregisterProvider(string) error
}
type ModelSelectEvent ¶
type ModelSelectEvent struct {
Model *ai.Model
PreviousModel *ai.Model
Source ModelSelectSource
}
func (ModelSelectEvent) Type ¶
func (ModelSelectEvent) Type() EventType
type ModelSelectSource ¶
type ModelSelectSource string
const ( ModelSelectSet ModelSelectSource = "set" ModelSelectCycle ModelSelectSource = "cycle" ModelSelectRestore ModelSelectSource = "restore" )
type NavigateTreeOptions ¶
type NavigateTreeOptions struct {
}
type NewSessionOptions ¶
type NewSessionOptions struct {
// Prepare configures a new journal before the executor factory runs.
Prepare func(*session.SessionManager) error
ParentSession string
Setup func(*session.SessionManager) error
WithSession func(context.Context, ReplacedSessionContext) error
}
type NoopUI ¶
type NoopUI struct{}
func (NoopUI) AddAutocompleteProvider ¶
func (NoopUI) AddAutocompleteProvider(AutocompleteProviderFactory)
func (NoopUI) Custom ¶
func (NoopUI) Custom(context.Context, CustomFactory, *CustomOptions) (any, bool, error)
func (NoopUI) GetAllThemes ¶
func (NoopUI) GetEditorComponent ¶
func (NoopUI) GetEditorComponent() EditorFactory
func (NoopUI) GetEditorText ¶
func (NoopUI) GetToolsExpanded ¶
func (NoopUI) Notify ¶
func (NoopUI) Notify(string, NotificationType)
func (NoopUI) OnTerminalInput ¶
func (NoopUI) OnTerminalInput(TerminalInputHandler) func()
func (NoopUI) PasteToEditor ¶
func (NoopUI) SetEditorComponent ¶
func (NoopUI) SetEditorComponent(EditorFactory)
func (NoopUI) SetEditorText ¶
func (NoopUI) SetFooter ¶
func (NoopUI) SetFooter(FooterFactory)
func (NoopUI) SetHeader ¶
func (NoopUI) SetHeader(HeaderFactory)
func (NoopUI) SetHiddenThinkingLabel ¶
func (NoopUI) SetTheme ¶
func (NoopUI) SetTheme(any) ThemeSetResult
func (NoopUI) SetToolsExpanded ¶
func (NoopUI) SetWorkingIndicator ¶
func (NoopUI) SetWorkingIndicator(*WorkingIndicatorOptions)
func (NoopUI) SetWorkingMessage ¶
func (NoopUI) SetWorkingVisible ¶
type NotificationType ¶
type NotificationType string
const ( NotifyInfo NotificationType = "info" NotifyWarning NotificationType = "warning" NotifyError NotificationType = "error" )
type OAuthAuthInfo ¶
type OAuthCredentials ¶
type OAuthCredentials struct {
Refresh string `json:"refresh"`
Access string `json:"access"`
Expires int64 `json:"expires"`
Extra map[string]any `json:"-"`
}
func (OAuthCredentials) MarshalJSON ¶
func (credentials OAuthCredentials) MarshalJSON() ([]byte, error)
func (*OAuthCredentials) UnmarshalJSON ¶
func (credentials *OAuthCredentials) UnmarshalJSON(data []byte) error
type OAuthDeviceCodeInfo ¶
type OAuthLoginCallbacks ¶
type OAuthLoginCallbacks struct {
Signal context.Context
OnAuth func(OAuthAuthInfo)
OnDeviceCode func(OAuthDeviceCodeInfo)
OnPrompt func(OAuthPrompt) (string, error)
OnProgress func(string)
OnManualCodeInput func() (string, error)
OnSelect func(OAuthSelectPrompt) (*string, error)
}
type OAuthPrompt ¶
type OAuthProvider ¶
type OAuthProvider struct {
Name string
Login func(context.Context, OAuthLoginCallbacks) (OAuthCredentials, error)
RefreshToken func(context.Context, OAuthCredentials) (OAuthCredentials, error)
GetAPIKey func(OAuthCredentials) (string, error)
ModifyModels func([]ai.Model, OAuthCredentials) ([]ai.Model, error)
}
type OAuthSelectOption ¶
type OAuthSelectPrompt ¶
type OAuthSelectPrompt struct {
Message string
Options []OAuthSelectOption
}
type OverlayAnchor ¶
type OverlayAnchor string
const ( OverlayTopLeft OverlayAnchor = "top-left" OverlayTop OverlayAnchor = "top" OverlayTopRight OverlayAnchor = "top-right" OverlayLeft OverlayAnchor = "left" OverlayCenter OverlayAnchor = "center" OverlayRight OverlayAnchor = "right" OverlayBottomLeft OverlayAnchor = "bottom-left" OverlayBottom OverlayAnchor = "bottom" OverlayBottomRight OverlayAnchor = "bottom-right" )
type OverlayHandle ¶
type OverlayHandle interface {
Hide()
SetHidden(bool)
IsHidden() bool
Focus()
Unfocus(...OverlayUnfocusOptions)
IsFocused() bool
}
type OverlayOptions ¶
type OverlayUnfocusOptions ¶
type OverlayUnfocusOptions struct {
Target Component
}
type ProjectTrustContext ¶
type ProjectTrustDecision ¶
type ProjectTrustDecision string
const ( ProjectTrustYes ProjectTrustDecision = "yes" ProjectTrustNo ProjectTrustDecision = "no" ProjectTrustUndecided ProjectTrustDecision = "undecided" )
type ProjectTrustEvent ¶
type ProjectTrustEvent struct{ CWD string }
func (ProjectTrustEvent) Type ¶
func (ProjectTrustEvent) Type() EventType
type ProjectTrustResult ¶
type ProjectTrustResult struct {
Trusted ProjectTrustDecision `json:"trusted"`
Remember bool `json:"remember,omitempty"`
}
type Provider ¶
type Provider struct {
ID string
Name string
BaseURL string
Headers map[string]string
Auth aiauth.ProviderAuth
Config ProviderConfig
FilterModels func([]ai.Model, *aiauth.Credential) ([]ai.Model, error)
GetModels func() ([]ai.Model, error)
RefreshModels func(RefreshModelsContext) error
Stream engine.StreamFn
StreamSimple engine.StreamFn
// RegistrationValue is returned only to the VM that owns it; callbacks
// above remain the cross-VM representation held by the shared registry.
RegistrationValue any
}
type ProviderConfig ¶
type ProviderConfig struct {
Name string
BaseURL string
APIKey string
API ai.API
Stream engine.StreamFn
Headers map[string]string
AuthHeader *bool
Models []ProviderModelConfig
RefreshModels func(RefreshModelsContext) ([]ProviderModelConfig, error)
OAuth *OAuthProvider
Defined map[string]bool
// RegistrationValues retains owner-scoped values solely so the bridge can
// expose the effective registration through the owning VM.
RegistrationValues map[string]any
}
type ProviderModelConfig ¶
type ProviderModelConfig struct {
ID string
Name string
API ai.API
BaseURL string
Reasoning bool
ThinkingLevelMap *map[ai.ModelThinkingLevel]*string
Input ai.InputModalities
Cost ai.ModelCost
ContextWindow float64
MaxTokens float64
InputLimits *ai.ModelInputLimits
SamplingParams map[string]any
Headers map[string]string
Compat json.RawMessage
}
type ProviderModelStore ¶
type ProviderRequestResult ¶
ProviderRequestResult distinguishes an unchanged payload from an explicit nil replacement.
type ProviderStreamEvent ¶ added in v0.14.0
type ProviderStreamEvent struct {
Provider ai.ProviderID
API ai.API
Model string
Data json.RawMessage
}
ProviderStreamEvent carries a parsed provider stream event before normalization. It is notification-only and must be treated as read-only.
func (ProviderStreamEvent) Type ¶ added in v0.14.0
func (ProviderStreamEvent) Type() EventType
type ReadonlySessionManager ¶
type ReadonlySessionManager interface {
IsPersisted() bool
GetCWD() string
GetSessionDir() string
GetSessionID() string
GetSessionFile() string
GetLeafID() *string
GetLeafEntry() *session.SessionEntry
GetEntry(string) *session.SessionEntry
GetEntries() []session.SessionEntry
GetHeader() *session.SessionHeader
GetSessionName() *string
GetLabel(string) *string
GetChildren(string) []session.SessionEntry
GetBranch(...string) []session.SessionEntry
GetTree() []*session.SessionTreeNode
BuildContextEntries() []session.SessionEntry
BuildSessionContext() session.SessionContext
}
type RefreshModelsContext ¶
type RefreshModelsContext struct {
Credential *aiauth.Credential
Store ProviderModelStore
AllowNetwork bool
Force bool
Signal context.Context
}
type RegisterOption ¶
type RegisterOption func(*registerOptions)
func WithHidden ¶
func WithHidden(hidden bool) RegisterOption
func WithReplaceable ¶ added in v0.14.0
func WithReplaceable(replaceable bool) RegisterOption
func WithSourceInfo ¶
func WithSourceInfo(sourceInfo SourceInfo) RegisterOption
type RegisteredTool ¶
type RegisteredTool struct {
Definition ToolDefinition
SourceInfo SourceInfo
}
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func NewRegistry ¶
func (*Registry) BindModelRegistry ¶
func (registry *Registry) BindModelRegistry(models ModelRegistry, report func(ExtensionError))
func (*Registry) Extensions ¶
func (*Registry) Fresh ¶
Fresh recreates every registered extension against a new active runtime. Factories run again so captured API and command contexts belong exclusively to the replacement session.
func (*Registry) OmitReplaced ¶ added in v0.14.0
OmitReplaced leaves out replaceable extensions that share a tool, command, or flag name with another extension, so a third-party extension that registers /mcp replaces the built-in MCP extension instead of both running. It returns one warning per built-in left out.
func (*Registry) Register ¶
func (registry *Registry) Register(path string, factory Factory, options ...RegisterOption) error
func (*Registry) RegisteredFlags ¶
func (*Registry) SetFlagValue ¶
type RenderShell ¶
type RenderShell string
const ( RenderShellDefault RenderShell = "default" RenderShellSelf RenderShell = "self" )
type ReplacedSessionContext ¶
type ReplacedSessionContext interface {
CommandContext
SendMessage(context.Context, CustomMessage, *SendMessageOptions) error
SendUserMessage(context.Context, ai.UserContent, *SendUserMessageOptions) error
}
type ResolvedCommand ¶
type ResourcesDiscoverEvent ¶
type ResourcesDiscoverEvent struct {
CWD string
Reason ResourcesDiscoverReason
}
func (ResourcesDiscoverEvent) Type ¶
func (ResourcesDiscoverEvent) Type() EventType
type ResourcesDiscoverReason ¶
type ResourcesDiscoverReason string
const ( ResourcesDiscoverStartup ResourcesDiscoverReason = "startup" ResourcesDiscoverReload ResourcesDiscoverReason = "reload" )
type ResourcesDiscoverResult ¶
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
func NewRunner ¶
func NewRunner(registry *Registry, options RunnerOptions) *Runner
func (*Runner) ActiveTools ¶
func (*Runner) AllRegisteredTools ¶
func (runner *Runner) AllRegisteredTools() []RegisteredTool
func (*Runner) BindCommandContext ¶
func (runner *Runner) BindCommandContext(actions *CommandActions)
func (*Runner) Command ¶
func (runner *Runner) Command(name string) *ResolvedCommand
func (*Runner) CreateCommandContext ¶
func (runner *Runner) CreateCommandContext() CommandContext
func (*Runner) CreateContext ¶
func (*Runner) CreateReplacedSessionContext ¶
func (runner *Runner) CreateReplacedSessionContext() ReplacedSessionContext
CreateReplacedSessionContext creates the post-replacement context passed to new, fork, and switch callbacks.
func (*Runner) CreateToolContext ¶ added in v0.14.0
CreateToolContext is the context of the tool call toolCallID: a ToolContext when the session runs nested calls.
func (*Runner) EmitBeforeAgentStart ¶
func (runner *Runner) EmitBeforeAgentStart( ctx context.Context, prompt string, images []*ai.ImageContent, systemPrompt string, options SystemPromptOptions, ) *BeforeAgentStartCombinedResult
func (*Runner) EmitBeforeProviderHeaders ¶
func (runner *Runner) EmitBeforeProviderHeaders(ctx context.Context, headers ai.ProviderHeaders) ai.ProviderHeaders
func (*Runner) EmitBeforeProviderRequest ¶
func (*Runner) EmitBoundary ¶ added in v0.14.0
func (runner *Runner) EmitBoundary( ctx context.Context, base Event, buildContext func([]SessionBoundaryDraft) (BoundaryContextPreview, error), ) BoundaryDispatch
EmitBoundary dispatches turn_end or agent_before_settle: each handler sees the entries and continuation chained so far plus their preview, rebuilt by buildContext after every handler.
func (*Runner) EmitBoundaryError ¶ added in v0.14.0
EmitBoundaryError reports a boundary failure that no single handler owns.
func (*Runner) EmitContext ¶
func (runner *Runner) EmitContext(ctx context.Context, messages engine.AgentMessages) engine.AgentMessages
EmitContext runs the request-time transforms in two phases. context handlers see the conversation only; an unchanged result keeps every system message in place, a changed one gets the current prompt and tool state as one leading system message, so pruning cannot drop it. context_with_system handlers then see the full transcript and their output is used as returned.
func (*Runner) EmitInput ¶
func (runner *Runner) EmitInput( ctx context.Context, text string, images []*ai.ImageContent, source InputSource, streamingBehavior *DeliveryMode, ) InputResult
func (*Runner) EmitMessageEnd ¶
func (runner *Runner) EmitMessageEnd(ctx context.Context, event MessageEndEvent) engine.AgentMessage
func (*Runner) EmitProjectTrust ¶
func (runner *Runner) EmitProjectTrust(ctx context.Context, event ProjectTrustEvent, trustContext Context) (*ProjectTrustResult, []ExtensionError)
func (*Runner) EmitResourcesDiscover ¶
func (runner *Runner) EmitResourcesDiscover(ctx context.Context, cwd string, reason ResourcesDiscoverReason) DiscoveredResources
func (*Runner) EmitToolCall ¶
func (runner *Runner) EmitToolCall(ctx context.Context, event ToolCallEvent) *ToolCallResult
func (*Runner) EmitToolResult ¶
func (runner *Runner) EmitToolResult(ctx context.Context, event ToolResultEvent) *ToolResultResult
func (*Runner) EmitUserBashChecked ¶ added in v0.7.0
func (runner *Runner) EmitUserBashChecked(ctx context.Context, event UserBashEvent) (*UserBashResult, error)
func (*Runner) EntryRenderer ¶
func (runner *Runner) EntryRenderer(customType string) EntryRenderer
func (*Runner) Events ¶ added in v0.19.0
Events is this attachment's bus, including when a runtime replaces it on reload.
func (*Runner) ExecuteCommand ¶
func (*Runner) ExtensionPaths ¶
func (*Runner) FlagValues ¶
func (*Runner) HasHandlers ¶
func (*Runner) Invalidate ¶
func (*Runner) MessageRenderer ¶
func (runner *Runner) MessageRenderer(customType string) MessageRenderer
func (*Runner) ModelRegistry ¶
func (runner *Runner) ModelRegistry() ModelRegistry
func (*Runner) OnError ¶
func (runner *Runner) OnError(listener func(ExtensionError)) func()
func (*Runner) RegisteredCommands ¶
func (runner *Runner) RegisteredCommands() []ResolvedCommand
func (*Runner) RegisteredFlags ¶
func (*Runner) ReportError ¶ added in v0.14.0
func (runner *Runner) ReportError(extensionError ExtensionError)
ReportError reports an extension failure outside event dispatch, such as a tool's prepareLoadout hook.
func (*Runner) SetFlagValue ¶
func (*Runner) SetToolCallHost ¶ added in v0.14.0
func (runner *Runner) SetToolCallHost(host *ToolCallHost)
SetToolCallHost lets tools run other tools (ToolContext.ExecuteTool).
func (*Runner) ShortcutDiagnostics ¶
func (runner *Runner) ShortcutDiagnostics() []Diagnostic
func (*Runner) ShortcutOrder ¶
ShortcutOrder returns registered shortcut keys in extension registration order. Upstream getShortcuts returns an insertion-ordered Map; the TUI dispatcher walks this order so first-registered shortcuts win ties.
func (*Runner) ToolDefinition ¶
func (runner *Runner) ToolDefinition(name string) *ToolDefinition
type RunnerOptions ¶
type RunnerOptions struct {
CWD string
SessionManager ReadonlySessionManager
ModelRegistry ModelRegistry
Mode Mode
UI UI
Actions Actions
ContextActions ContextActions
CommandActions *CommandActions
ErrorHandler func(ExtensionError)
}
type ScopedModel ¶
type ScopedModel struct {
Model ai.Model `json:"model"`
ThinkingLevel *ai.ModelThinkingLevel `json:"thinkingLevel,omitempty"`
}
type SendMessageOptions ¶
type SendMessageOptions struct {
// Tri-state as upstream: unset still steers a streaming turn, an explicit
// false suppresses it, true prompts when idle.
TriggerTurn *bool
DeliverAs DeliveryMode
}
type SendUserMessageOptions ¶
type SendUserMessageOptions struct {
DeliverAs DeliveryMode
// ExpandPromptTemplates dispatches extension commands and expands skill
// commands and prompt templates. Defaults to off, as upstream.
ExpandPromptTemplates bool
}
type SessionBeforeCompactEvent ¶
type SessionBeforeCompactEvent struct {
Preparation harness.CompactionPreparation
BranchEntries []session.SessionEntry
CustomInstructions *string
Reason CompactionReason
WillRetry bool
Signal context.Context
}
func (SessionBeforeCompactEvent) Type ¶
func (SessionBeforeCompactEvent) Type() EventType
type SessionBeforeCompactResult ¶
type SessionBeforeCompactResult struct {
Cancel bool
Compaction *session.CompactionResult
}
type SessionBeforeForkEvent ¶
type SessionBeforeForkEvent struct {
EntryID string
Position ForkPosition
}
func (SessionBeforeForkEvent) Type ¶
func (SessionBeforeForkEvent) Type() EventType
type SessionBeforeForkResult ¶
type SessionBeforeSwitchEvent ¶
type SessionBeforeSwitchEvent struct {
Reason SessionSwitchReason
TargetSessionFile *string
}
func (SessionBeforeSwitchEvent) Type ¶
func (SessionBeforeSwitchEvent) Type() EventType
type SessionBeforeSwitchResult ¶
type SessionBeforeSwitchResult struct{ Cancel bool }
type SessionBeforeTreeEvent ¶
type SessionBeforeTreeEvent struct {
Preparation TreePreparation
Signal context.Context
}
func (SessionBeforeTreeEvent) Type ¶
func (SessionBeforeTreeEvent) Type() EventType
type SessionBeforeTreeResult ¶
type SessionBeforeTreeResult struct {
Cancel bool
Summary *TreeSummary
CustomInstructions *string
ReplaceInstructions *bool
Label *string
}
type SessionBoundaryDraft ¶ added in v0.14.0
type SessionBoundaryDraft struct {
Type string `json:"type"`
CustomType string `json:"customType,omitempty"`
Data any `json:"data,omitempty"`
Content any `json:"content,omitempty"`
Display bool `json:"display,omitempty"`
Details any `json:"details,omitempty"`
TargetID string `json:"targetId,omitempty"`
Replacement json.RawMessage `json:"replacement,omitempty"`
Summary string `json:"summary,omitempty"`
FirstKeptEntryID *string `json:"firstKeptEntryId,omitempty"`
Usage *ai.Usage `json:"usage,omitempty"`
}
SessionBoundaryDraft is a structural entry a turn_end or agent_before_settle handler proposes: "custom" (CustomType, Data), "custom_message" (CustomType, Content, Display, Details), "context_edit" (TargetID, Replacement) or "compaction" (Summary, FirstKeptEntryID, Details, Usage). A compaction with no FirstKeptEntryID keeps no preceding entries.
type SessionCompactEvent ¶
type SessionCompactEvent struct {
CompactionEntry session.SessionEntry
FromExtension bool
Reason CompactionReason
WillRetry bool
}
func (SessionCompactEvent) Type ¶
func (SessionCompactEvent) Type() EventType
type SessionCompactFailedEvent ¶ added in v0.6.0
type SessionCompactFailedEvent struct {
Reason CompactionReason
ErrorMessage *string `json:"errorMessage,omitempty"`
Aborted bool
WillRetry bool
FromExtension bool
}
func (SessionCompactFailedEvent) Type ¶ added in v0.6.0
func (SessionCompactFailedEvent) Type() EventType
type SessionInfoChangedEvent ¶
type SessionInfoChangedEvent struct{ Name *string }
func (SessionInfoChangedEvent) Type ¶
func (SessionInfoChangedEvent) Type() EventType
type SessionReplacementResult ¶
type SessionReplacementResult struct{ Cancelled bool }
type SessionShutdownEvent ¶
type SessionShutdownEvent struct {
Reason SessionShutdownReason
TargetSessionFile *string
}
func (SessionShutdownEvent) Type ¶
func (SessionShutdownEvent) Type() EventType
type SessionShutdownReason ¶
type SessionShutdownReason string
const ( SessionShutdownQuit SessionShutdownReason = "quit" SessionShutdownReload SessionShutdownReason = "reload" SessionShutdownNew SessionShutdownReason = "new" SessionShutdownResume SessionShutdownReason = "resume" SessionShutdownFork SessionShutdownReason = "fork" )
type SessionStartEvent ¶
type SessionStartEvent struct {
Reason SessionStartReason
PreviousSessionFile *string
}
func (SessionStartEvent) Type ¶
func (SessionStartEvent) Type() EventType
type SessionStartReason ¶
type SessionStartReason string
const ( SessionStartStartup SessionStartReason = "startup" SessionStartReload SessionStartReason = "reload" SessionStartNew SessionStartReason = "new" SessionStartResume SessionStartReason = "resume" SessionStartFork SessionStartReason = "fork" )
type SessionSwitchReason ¶
type SessionSwitchReason string
const ( SessionSwitchNew SessionSwitchReason = "new" SessionSwitchResume SessionSwitchReason = "resume" )
type SessionTreeEvent ¶
type SessionTreeEvent struct {
NewLeafID *string
OldLeafID *string
SummaryEntry *session.SessionEntry
FromExtension *bool
}
func (SessionTreeEvent) Type ¶
func (SessionTreeEvent) Type() EventType
type SlashCommandInfo ¶
type SlashCommandInfo struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Source SlashCommandSource `json:"source"`
SourceInfo SourceInfo `json:"sourceInfo"`
}
type SlashCommandSource ¶
type SlashCommandSource string
const ( SlashCommandExtension SlashCommandSource = "extension" SlashCommandPrompt SlashCommandSource = "prompt" SlashCommandSkill SlashCommandSource = "skill" )
type SourceInfo ¶
type SourceInfo struct {
Path string `json:"path"`
Source string `json:"source"`
Scope SourceScope `json:"scope"`
Origin SourceOrigin `json:"origin"`
BaseDir *string `json:"baseDir,omitempty"`
}
type SourceOrigin ¶
type SourceOrigin string
const ( SourceOriginPackage SourceOrigin = "package" SourceOriginTopLevel SourceOrigin = "top-level" )
type SourceScope ¶
type SourceScope string
const ( SourceScopeUser SourceScope = "user" SourceScopeProject SourceScope = "project" SourceScopeTemporary SourceScope = "temporary" )
type SwitchSessionOptions ¶
type SwitchSessionOptions struct {
WithSession func(context.Context, ReplacedSessionContext) error
}
type SystemPromptOptions ¶
type SystemPromptOptions struct {
CustomPrompt *string `json:"customPrompt,omitempty"`
ForceSystemPrompt *string `json:"forceSystemPrompt,omitempty"`
SelectedTools []string `json:"selectedTools"`
ToolSnippets map[string]string `json:"toolSnippets"`
ToolGuidelines map[string][]string `json:"toolGuidelines"`
PromptGuidelines []string `json:"promptGuidelines"`
AppendSystemPrompt *string `json:"appendSystemPrompt"`
Sections map[string]string `json:"sections"`
CWD string `json:"cwd"`
ContextFiles []ContextFile `json:"contextFiles"`
Skills []Skill `json:"skills"`
}
type TerminalInputHandler ¶
type TerminalInputHandler func(string) *TerminalInputResult
type TerminalInputResult ¶
type Theme ¶
type Theme interface {
FG(color, text string) string
BG(color, text string) string
Bold(string) string
Italic(string) string
Underline(string) string
Inverse(string) string
Strikethrough(string) string
FGANSI(string) string
BGANSI(string) string
ColorMode() string
// Colors maps every token to its concrete #rrggbb color.
Colors() map[string]string
// Appearance is "dark" or "light".
Appearance() string
ThinkingBorderColor(engine.ThinkingLevel) func(string) string
BashModeBorderColor() func(string) string
}
type ThemeSetResult ¶
type ThinkingLevelSelectEvent ¶
type ThinkingLevelSelectEvent struct {
Level engine.ThinkingLevel
PreviousLevel engine.ThinkingLevel
}
func (ThinkingLevelSelectEvent) Type ¶
func (ThinkingLevelSelectEvent) Type() EventType
type ToolAnnotations ¶ added in v0.14.0
type ToolAnnotations struct {
ReadOnlyHint *bool `json:"readOnlyHint,omitempty"`
DestructiveHint *bool `json:"destructiveHint,omitempty"`
IdempotentHint *bool `json:"idempotentHint,omitempty"`
OpenWorldHint *bool `json:"openWorldHint,omitempty"`
}
ToolAnnotations are unverified hints about what a tool does, with the meaning of MCP tool annotations.
type ToolCallEvent ¶
type ToolCallEvent struct {
ToolCallID string
ToolName string
ParentToolCallID string `json:",omitempty"`
Input map[string]any
}
ToolCallEvent and ToolResultEvent of calls a tool made through ExecuteTool carry the caller's id as ParentToolCallID.
func (ToolCallEvent) Type ¶
func (ToolCallEvent) Type() EventType
type ToolCallHost ¶ added in v0.14.0
type ToolCallHost struct {
Tools func() []LoadoutTool
Execute func(ctx context.Context, parentToolCallID, name string, args any, onUpdate engine.AgentToolUpdateCallback) engine.AgentToolCallOutcome
}
ToolCallHost runs a session's nested tool calls.
type ToolCallResult ¶
type ToolContext ¶ added in v0.14.0
type ToolContext interface {
Context
// Tools are the tools ExecuteTool can call.
Tools() []LoadoutTool
// ExecuteTool runs another tool through the same validation, hooks and
// permission checks as model-issued calls. The call gets the id
// "<calling id>/<n>" and its events carry ParentToolCallID; it is not in
// the transcript but recorded on the caller's result. Failures (unknown
// tools, validation errors, blocked calls) come back as IsError outcomes.
ExecuteTool(ctx context.Context, name string, args any, onUpdate engine.AgentToolUpdateCallback) engine.AgentToolCallOutcome
}
ToolContext is the Context a tool's Execute receives in a session.
type ToolDefinition ¶
type ToolDefinition struct {
Name string
Label string
Description string
PromptSnippet string
// PromptGuidelines is the registration-time snapshot of the tool's prompt
// guidelines.
PromptGuidelines []string
// PromptGuidelinesFunc, when set, re-reads the tool's current prompt
// guidelines (upstream tools may declare a lazy `get promptGuidelines()`
// whose value changes between turns, e.g. an available-model list). The
// session runtime consults it before building each turn's system prompt
// and falls back to the PromptGuidelines snapshot on nil or error.
PromptGuidelinesFunc func(context.Context) ([]string, error)
Parameters ai.JSONSchema
ConstrainedSampling *ai.ConstrainedSamplingConfig
RenderShell RenderShell
PrepareArguments engine.PrepareArgumentsFunc
ExecutionMode engine.ToolExecutionMode
// OutputSchema is the JSON Schema of StructuredContent in successful results.
OutputSchema ai.JSONSchema
// Exposure defaults to ToolDirect.
Exposure ToolExposure
Namespace *ToolNamespace
Annotations *ToolAnnotations
// DefaultActive false keeps a direct or model-only tool off until named in
// --tools, defaultTools or SetActiveTools.
DefaultActive *bool
// PrepareLoadout adjusts how the loadout is presented while this tool is
// active; orchestrating tools list the callable tools in their description.
PrepareLoadout func(ToolLoadout) *ToolLoadoutChanges
Execute func(context.Context, string, any, engine.AgentToolUpdateCallback, Context) (engine.AgentToolResult, error)
RenderCall func(any, Theme, ToolRenderContext) Component
RenderResult func(engine.AgentToolResult, ToolRenderResultOptions, Theme, ToolRenderContext) Component
}
func (ToolDefinition) EffectiveExposure ¶ added in v0.14.0
func (definition ToolDefinition) EffectiveExposure() ToolExposure
EffectiveExposure is the definition's exposure, codemode read as deferred.
type ToolExecutionEndEvent ¶
type ToolExecutionEndEvent struct {
ToolCallID string
ToolName string
Result any
IsError bool
ParentToolCallID string `json:",omitempty"`
}
func (ToolExecutionEndEvent) Type ¶
func (ToolExecutionEndEvent) Type() EventType
type ToolExecutionStartEvent ¶
type ToolExecutionStartEvent struct {
ToolCallID string
ToolName string
Args any
ParentToolCallID string `json:",omitempty"`
}
func (ToolExecutionStartEvent) Type ¶
func (ToolExecutionStartEvent) Type() EventType
type ToolExecutionUpdateEvent ¶
type ToolExecutionUpdateEvent struct {
ToolCallID string
ToolName string
Args any
PartialResult any
ParentToolCallID string `json:",omitempty"`
}
func (ToolExecutionUpdateEvent) Type ¶
func (ToolExecutionUpdateEvent) Type() EventType
type ToolExposure ¶ added in v0.14.0
type ToolExposure string
ToolExposure is how the model reaches a tool; "callable" means through ctx.ExecuteTool from another tool.
- direct (default): declared while active, callable while active.
- model-only: declared while active, never callable; for orchestrating or interactive tools.
- deferred: callable whenever registered, declared only when explicitly activated; tool search can find it. "codemode" is treated as deferred.
- hidden: registered but unreachable; activating it has no effect.
direct and model-only tools are activated when registered; the others are not.
const ( ToolDirect ToolExposure = "direct" ToolModelOnly ToolExposure = "model-only" ToolCodemode ToolExposure = "codemode" ToolDeferred ToolExposure = "deferred" ToolHidden ToolExposure = "hidden" )
type ToolInfo ¶
type ToolInfo struct {
Name string `json:"name"`
Description string `json:"description"`
Parameters ai.JSONSchema `json:"parameters"`
PromptGuidelines []string `json:"promptGuidelines,omitempty"`
Exposure ToolExposure `json:"exposure"`
Namespace *ToolNamespace `json:"namespace,omitempty"`
Annotations *ToolAnnotations `json:"annotations,omitempty"`
SourceInfo SourceInfo `json:"sourceInfo"`
}
type ToolLoadout ¶ added in v0.14.0
type ToolLoadout struct {
// Declared are the active tools, in order, with their original descriptions.
Declared []LoadoutTool `json:"declared"`
// Callable are the tools reachable through ctx.ExecuteTool.
Callable []LoadoutTool `json:"callable"`
// Registered is every registered tool.
Registered []LoadoutTool `json:"registered"`
Exposures map[string]ToolExposure `json:"exposures"`
Namespaces map[string]ToolNamespace `json:"namespaces,omitempty"`
}
ToolLoadout is a session's tools as PrepareLoadout sees them.
type ToolLoadoutChanges ¶ added in v0.14.0
type ToolLoadoutChanges struct {
// Descriptions are model-facing descriptions of declared tools, by name.
Descriptions map[string]string `json:"descriptions,omitempty"`
// HiddenDeclarations stay active and callable, and recorded in the
// transcript, but requests leave their declarations out.
HiddenDeclarations []string `json:"hiddenDeclarations,omitempty"`
}
ToolLoadoutChanges adjust what the model sees while the hooking tool is active.
type ToolNamespace ¶ added in v0.14.0
type ToolNamespace struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
// Instructions is longer usage guidance, such as MCP server instructions;
// not part of tool listings.
Instructions string `json:"instructions,omitempty"`
}
ToolNamespace groups related tools, such as one MCP server's.
type ToolRenderContext ¶
type ToolRenderResultOptions ¶
type ToolResultEvent ¶
type ToolResultEvent struct {
ToolCallID string
ToolName string
ParentToolCallID string `json:",omitempty"`
Input map[string]any
Content ai.ToolResultContent
Details any
StructuredContent any `json:",omitempty"`
IsError bool
Usage *ai.Usage
}
func (ToolResultEvent) Type ¶
func (ToolResultEvent) Type() EventType
type ToolResultResult ¶
type TreePreparation ¶
type TurnEndEvent ¶
type TurnEndEvent struct {
TurnIndex int
Message engine.AgentMessage
ToolResults []*ai.ToolResultMessage
MessageEntryID string
ToolResultEntryIDs []string
BoundaryState
}
TurnEndEvent is an actionable boundary: handlers may persist entries and request one more model request.
func (TurnEndEvent) Type ¶
func (TurnEndEvent) Type() EventType
type TurnStartEvent ¶
func (TurnStartEvent) Type ¶
func (TurnStartEvent) Type() EventType
type UI ¶
type UI interface {
TrustUI
OnTerminalInput(TerminalInputHandler) func()
SetStatus(string, *string)
SetWorkingMessage(*string)
SetWorkingVisible(bool)
SetWorkingIndicator(*WorkingIndicatorOptions)
SetHiddenThinkingLabel(*string)
SetWidget(string, *Widget, *WidgetOptions)
SetHeader(HeaderFactory)
SetTitle(string)
Custom(context.Context, CustomFactory, *CustomOptions) (any, bool, error)
PasteToEditor(string)
SetEditorText(string)
GetEditorText() string
Editor(context.Context, string, *string) (string, bool, error)
AddAutocompleteProvider(AutocompleteProviderFactory)
SetEditorComponent(EditorFactory)
GetEditorComponent() EditorFactory
Theme() Theme
GetAllThemes() []ThemeInfo
GetTheme(string) Theme
SetTheme(any) ThemeSetResult
GetToolsExpanded() bool
SetToolsExpanded(bool)
}
type UIPromptEndEvent ¶ added in v0.6.0
type UIPromptEndEvent UIPromptStartEvent
func (UIPromptEndEvent) Type ¶ added in v0.6.0
func (UIPromptEndEvent) Type() EventType
type UIPromptKind ¶ added in v0.6.0
type UIPromptKind string
const ( UIPromptSelect UIPromptKind = "select" UIPromptConfirm UIPromptKind = "confirm" UIPromptInput UIPromptKind = "input" UIPromptEditor UIPromptKind = "editor" UIPromptCustom UIPromptKind = "custom" )
type UIPromptStartEvent ¶ added in v0.6.0
type UIPromptStartEvent struct {
Reason string
Kind UIPromptKind
Title *string `json:"title,omitempty"`
}
func (UIPromptStartEvent) Type ¶ added in v0.6.0
func (UIPromptStartEvent) Type() EventType
type UserBashEvent ¶
func (UserBashEvent) Type ¶
func (UserBashEvent) Type() EventType
type UserBashResult ¶
type UserBashResult struct {
Operations tools.BashOperations
Result *BashResult
}
type Widget ¶
type Widget struct {
Lines []string
Factory ComponentFactory
}
type WidgetOptions ¶
type WidgetOptions struct{ Placement WidgetPlacement }
type WidgetPlacement ¶
type WidgetPlacement string
const ( WidgetAboveEditor WidgetPlacement = "aboveEditor" WidgetBelowEditor WidgetPlacement = "belowEditor" )
type WorkingIndicatorOptions ¶
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
Package host implements orb's original out-of-process JavaScript extension host protocol and lifecycle manager.
|
Package host implements orb's original out-of-process JavaScript extension host protocol and lifecycle manager. |