Skip to content

Chat Types Reference ​

All chat types live in internal/chat/types.go. This package defines the command/event contract and is imported by every other subsystem - it has no behavior, only types.

ChatCommand (TUI/Web → Coordinator) ​

All commands implement the ChatCommand interface (marker: IsChatCommand()).

CommandFieldsPurpose
StartChatSessionCommandSessionID, ConfigInitialize a new session
SubmitChatPromptCommandSessionID, RequestID, Prompt, SubmittedAtSubmit user input
SteerChatPromptCommandSessionID, RequestID, TextInject text during in-flight response
UpdateChatSessionCommandSessionID, PatchChange model, temperature, system prompt, etc.
CancelChatRequestCommandSessionID, RequestIDCancel in-flight LLM request
ResetChatSessionCommandSessionIDReset to initial session state
CloseChatSessionCommandSessionIDClose and persist session
ReloadExtensionsCommandSessionIDReload all plugin extensions
RunExtensionCommandCommandSessionID, Name, ArgsExecute a plugin slash command
RespondInteractivePromptCommandRequestID, Confirmed, Canceled, ResponseAnswer a tool confirmation/question
ListSessionsCommandLimit, CursorList saved sessions
LoadSessionCommandSessionIDLoad a saved session's messages
DeleteSessionCommandSessionIDDelete a saved session
ExportSessionCommandSessionID, FormatExport session as JSONL

ChatEvent (Coordinator → TUI/Web) ​

All events implement the ChatEvent interface (marker: IsChatEvent()).

Session Lifecycle Events ​

EventFieldsWhen
ChatSessionSnapshotEventStateFull state sync (on start, after turns, on update)
SessionLoadedEventStateAfter a saved session is loaded

Streaming Events ​

EventFieldsWhen
ChatResponseStartedEventSessionID, RequestID, StartedAtLLM begins generating
ChatResponseDeltaEventSessionID, RequestID, Delta, Snapshot, ReceivedAtEach text token
ChatReasoningDeltaEventSessionID, RequestID, Delta, Snapshot, ReceivedAtEach reasoning token
ChatResponseCompletedEventState, RequestID, FinishReason, CompletedAtLLM finishes generating
ChatResponseCancelledEventSessionID, RequestIDUser cancels generation

Tool Events ​

EventFieldsWhen
ChatToolCallDeltaEventSessionID, RequestID, CallID, Index, ToolName, ArgumentsSummaryTool call being streamed
ChatToolExecutionStartedEventSessionID, RequestID, CallID, ToolName, ArgumentsSummary, StartedAtTool execution begins
ChatToolOutputEventSessionID, RequestID, CallID, ChunkLive stdout chunk from tool
ChatToolExecutionCompletedEventSessionID, RequestID, CallID, ToolName, Status, ResultSummary, IsError, CompletedAtTool execution ends

Notification & Error Events ​

EventFieldsWhen
ChatRuntimeErrorEventSessionID, RequestID, Message, Fatal, OccurredAtRuntime error
ChatNotificationEventMessage, Level ("info"/"warn"/"error"), OccurredAtInformational notice

Interactive Prompt Events ​

EventFieldsWhen
InteractivePromptRequestedEventRequestID, Kind ("confirm"/"question"), Title, Message, RequestedAtTool needs user input

Session Management Events ​

EventFieldsWhen
SessionsListedEventSessions, NextCursorResponse to ListSessionsCommand
SessionDeletedEventSessionIDResponse to DeleteSessionCommand
SessionExportedEventSessionID, Format, PathResponse to ExportSessionCommand

Extension Events ​

EventFieldsWhen
ExtensionsReloadedEventPluginsAfter plugin reload
ExtensionCommandsChangedEventCommandsPlugin command registry changes
ExtensionCommandResultEventName, ResultResult of a plugin command
CommandsChangedEventCommandsFull command registry changes

Core Types ​

ChatSessionState ​

The complete session state carried in snapshots:

go
type ChatSessionState struct {
    SessionID      string
    Provider       string
    Model          ChatModelRef
    Status         string            // "idle", "streaming", "error"
    Parameters     ChatParameters
    Messages       []ChatMessage
    PendingAssistant string         // partial in-flight assistant text
    ActiveRequestID  string
    LastUsage      ChatUsage
    SystemPrompt   string
    ReasoningEffort string
    ShowReasoning  bool
}

ChatMessage ​

go
type ChatMessage struct {
    Role             ChatRole      // "system", "user", "assistant", "tool"
    Content          string
    ReasoningContent string
    ToolCalls        []ChatToolCall
    ToolCallID       string        // for role "tool" messages
    Name             string        // optional tool/function name
}

ChatToolCall ​

go
type ChatToolCall struct {
    ID       string
    Type     string           // always "function"
    Function ChatFunctionCall
}

type ChatFunctionCall struct {
    Name      string
    Arguments string          // JSON string
}

ChatParameters ​

go
type ChatParameters struct {
    MaxTokens       int
    Temperature     float64
    ReasoningEffort string
}

ChatModelRef ​

go
type ChatModelRef struct {
    ID            string
    URL           string              // provider base URL override
    Config        *ModelConfig        // context window, pricing, capabilities
    ContextWindow int                 // maximum context window in tokens
    Cost          *ChatCost           // per-1M-token pricing
}

ChatCost ​

go
type ChatCost struct {
    Input      float64
    Output     float64
    CacheRead  float64
    CacheWrite float64
}

ChatUsage ​

go
type ChatUsage struct {
    PromptTokens     int
    CompletionTokens int
    OutputTokens     int
    TotalTokens      int
}

ChatSessionConfig ​

go
type ChatSessionConfig struct {
    Provider       string
    Model          ChatModelRef
    SystemPrompt   string
    Parameters     ChatParameters
    ShowReasoning  bool
    ReasoningEffort string
}

ChatSessionPatch ​

Used in UpdateChatSessionCommand to change settings:

go
type ChatSessionPatch struct {
    Model           *ChatModelRef
    SystemPrompt    *string
    MaxTokens       *int
    Temperature     *float64
    ReasoningEffort *string
    Provider        *string
}

Non-ChatEvent Bus Types ​

These types are published on the event bus but do not implement ChatEvent:

ScheduleTickEvent ​

Published at a configurable interval for background work (plugin scheduling):

go
type ScheduleTickEvent struct {
    OccurredAt time.Time
}

PluginLifecycleEvent ​

Published for plugin lifecycle notifications:

go
type PluginLifecycleEvent struct {
    Event     string
    SessionID string
    Payload   any  // *api.EventPayload at rest
}

StreamCallbacks ​

The streaming callback interface used by Streamer:

go
type StreamCallbacks struct {
    OnDelta          func(delta, snapshot string)
    OnReasoningDelta func(delta, snapshot string)
    OnToolCallDelta  func(delta ChatToolCallDelta)
}

CommandRef ​

Used by the command registry and TUI for slash command autocomplete:

go
type CommandRef struct {
    Name        string   // e.g., "/model", "/plugin:hello:greet"
    Label       string   // human-readable label
    Description string
    AcceptsArgs bool
}

Extension Types ​

ExtensionCommand ​

A slash command provided by a plugin:

go
type ExtensionCommand struct {
    Name          string
    Description   string
    ExtensionName string
}

ExtensionReloader ​

Interface implemented by the plugin manager:

go
type ExtensionReloader interface {
    ReloadExtensions(ctx context.Context, idle bool) (ExtensionReloadResult, error)
    ExtensionCommands() []ExtensionCommand
    RunExtensionCommand(ctx context.Context, name, args string, uiBridge any) (string, error)
}

SessionSummary ​

go
type SessionSummary struct {
    ID           string
    ModelID      string
    Provider     string
    CreatedAt    time.Time
    UpdatedAt    time.Time
    Status       string
    MessageCount int
    TotalTokens  int
    Cost         float64
}

WebSocket Wire Protocol ​

The Envelope wrapper used on the WebSocket between the Go bridge and the Vue SPA:

go
type Envelope struct {
    Type    string          `json:"type"`
    Payload json.RawMessage `json:"payload"`
}

The TypeScript protocol types are mirrored in internal/webui/src/lib/protocol.ts. See Server & Bridge for the wire format details.

Built with VitePress.