webui

package
v1.1.52 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type A2ADiscoverFunc added in v1.1.47

type A2ADiscoverFunc func() []A2ADiscoveredInstance

A2ADiscoverFunc returns discovered A2A instances (other running ggcode processes).

type A2ADiscoveredInstance added in v1.1.47

type A2ADiscoveredInstance struct {
	ID        string `json:"id"`
	Workspace string `json:"workspace"`
	Endpoint  string `json:"endpoint"`
	Status    string `json:"status"`
	StartedAt string `json:"started_at"`
}

A2ADiscoveredInstance describes a remote ggcode instance discovered via A2A.

type AgentRunner added in v1.1.51

type AgentRunner interface {
	RunStream(ctx context.Context, userMsg string, onEvent func(provider.StreamEvent)) error
	RunStreamWithContent(ctx context.Context, content []provider.ContentBlock, onEvent func(provider.StreamEvent)) error
	Messages() []provider.Message
}

AgentRunner is kept for backward compatibility — ChatBridge replaces it.

type ChatBridge added in v1.1.51

type ChatBridge interface {
	// Messages returns the current agent conversation history.
	Messages() []provider.Message
	// SendUserMessage injects a user message into the agent.
	// If the agent is idle, it starts a new run. If running, the message
	// is queued as an interruption (same as TUI/IM mid-run input).
	SendUserMessage(content []provider.ContentBlock)
	// Subscribe registers a callback for agent streaming events.
	// Returns an unsubscribe function.
	Subscribe(fn func(provider.StreamEvent)) func()
}

ChatBridge is the interface between webui and the agent. Implemented by im.DaemonBridge — webchat sends messages through the bridge (which routes them as interruptions to the running agent loop) and subscribes to agent events via the EventSubscriber.

type IMActionFunc

type IMActionFunc func(adapter string, action string) error

IMActionFunc performs an IM action (enable/disable/mute/unmute/unbind).

type IMRuntimeStatus

type IMRuntimeStatus struct {
	Adapter   string   `json:"adapter"`
	Platform  string   `json:"platform"`
	Healthy   bool     `json:"healthy"`
	Status    string   `json:"status"`
	LastError string   `json:"last_error,omitempty"`
	BoundDir  string   `json:"bound_dir,omitempty"`
	ChannelID string   `json:"channel_id,omitempty"`
	TargetID  string   `json:"target_id,omitempty"`
	Muted     bool     `json:"muted"`
	Disabled  bool     `json:"disabled"`
	AllDirs   []string `json:"all_dirs,omitempty"` // all persisted bound directories
}

IMRuntimeStatus describes a running IM adapter's state.

type IMStatusFunc

type IMStatusFunc func() []IMRuntimeStatus

IMStatusFunc returns runtime IM adapter states. Keys are adapter names.

type MCPRuntimeStatus

type MCPRuntimeStatus struct {
	Connected bool     `json:"connected"`
	Pending   bool     `json:"pending"`
	Disabled  bool     `json:"disabled"`
	Error     string   `json:"error,omitempty"`
	Tools     []string `json:"tools,omitempty"`
}

MCPRuntimeStatus describes a running MCP server's state.

type MCPStatusFunc

type MCPStatusFunc func() map[string]MCPRuntimeStatus

MCPStatusFunc returns runtime MCP server statuses. Keys are server names.

type Server

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

Server provides a built-in WebUI for configuration and chat.

func NewServer

func NewServer(cfg *config.Config) *Server

NewServer creates a WebUI server bound to the given config.

func (*Server) Addr

func (s *Server) Addr() string

Addr returns the listening address (empty if not started).

func (*Server) Close

func (s *Server) Close() error

Close shuts down the server.

func (*Server) SetA2ADiscoverFn added in v1.1.47

func (s *Server) SetA2ADiscoverFn(fn A2ADiscoverFunc)

SetA2ADiscoverFn sets the A2A instance discovery provider.

func (*Server) SetAgent added in v1.1.51

func (s *Server) SetAgent(a AgentRunner)

SetAgent sets the agent runner for chat functionality (legacy mode).

func (*Server) SetChatBridge added in v1.1.51

func (s *Server) SetChatBridge(b ChatBridge)

SetChatBridge sets the chat bridge for WebChat (preferred mode). When set, WebChat uses bridge's interruption/subscription model instead of directly running the agent.

func (*Server) SetIMActionFn

func (s *Server) SetIMActionFn(fn IMActionFunc)

SetIMActionFn sets the IM action handler.

func (*Server) SetIMStatusFn

func (s *Server) SetIMStatusFn(fn IMStatusFunc)

SetIMStatusFn sets the runtime IM status provider.

func (*Server) SetMCPStatusFn

func (s *Server) SetMCPStatusFn(fn MCPStatusFunc)

SetMCPStatusFn sets the runtime MCP status provider.

func (*Server) SetRestartFn

func (s *Server) SetRestartFn(fn func())

SetRestartFn sets the restart callback (triggers process self-restart).

func (*Server) SetSessionStore added in v1.1.51

func (s *Server) SetSessionStore(store session.Store, workspace string)

SetSessionStore sets the session store for browsing history.

func (*Server) Start

func (s *Server) Start(addr string) (string, error)

Start starts the HTTP server on the given address (e.g. "127.0.0.1:0" for auto). Returns the actual listening address.

type TUIAgent added in v1.1.51

type TUIAgent interface {
	Messages() []provider.Message
}

TUIAgent is the subset of agent.Agent needed by TUIChatBridge.

type TUIChatBridge added in v1.1.51

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

TUIChatBridge implements ChatBridge for TUI mode. In TUI mode, the agent is driven by the bubbletea program. Webchat messages are injected into the TUI event loop (not directly into the agent), so they go through the normal submit flow. Agent events are broadcast via Subscribe (wired in TUI's stream callback).

func NewTUIChatBridge added in v1.1.51

func NewTUIChatBridge(agent TUIAgent, sender WebchatMessageSender) *TUIChatBridge

NewTUIChatBridge creates a ChatBridge for TUI mode.

func (*TUIChatBridge) BroadcastEvent added in v1.1.51

func (b *TUIChatBridge) BroadcastEvent(event provider.StreamEvent)

BroadcastEvent sends an event to all subscribers. Called from the TUI's agent stream callback to forward events to webchat.

func (*TUIChatBridge) Messages added in v1.1.51

func (b *TUIChatBridge) Messages() []provider.Message

Messages returns the current agent conversation history.

func (*TUIChatBridge) SendUserMessage added in v1.1.51

func (b *TUIChatBridge) SendUserMessage(content []provider.ContentBlock)

SendUserMessage routes a webchat message through the TUI event loop. The message appears to the agent as if the user typed it in the terminal. This avoids any concurrency issues with the agent — the TUI handles queuing, interruption, and submission just like a keyboard input.

func (*TUIChatBridge) Subscribe added in v1.1.51

func (b *TUIChatBridge) Subscribe(fn func(provider.StreamEvent)) func()

Subscribe registers a callback for agent streaming events. In TUI mode, events are broadcast from the TUI's stream callback via BroadcastEvent (called in internal/tui/submit.go).

type WebchatMessageSender added in v1.1.51

type WebchatMessageSender interface {
	SendWebchatMessage(text string)
}

WebchatMessageSender injects a webchat user message into the TUI event loop. Implemented by a closure that calls program.Send(webchatUserMsg{...}).

Jump to

Keyboard shortcuts

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