webui

package
v1.3.14 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: MIT Imports: 23 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 KnightActionFunc added in v1.1.55

type KnightActionFunc func(action, skillName string, params map[string]interface{}) error

KnightActionFunc performs an action on a Knight skill. Returns an error message or empty string on success.

type KnightBudget added in v1.1.54

type KnightBudget struct {
	Used      int `json:"used"`
	Remaining int `json:"remaining"`
	Limit     int `json:"limit"`
}

type KnightCandidate added in v1.1.54

type KnightCandidate struct {
	Name           string   `json:"name"`
	Description    string   `json:"description"`
	Category       string   `json:"category"`
	Score          float64  `json:"score"`
	EvidenceCount  int      `json:"evidence_count"`
	Reason         string   `json:"reason,omitempty"`
	SourceSessions []string `json:"source_sessions,omitempty"`
}

type KnightSkill added in v1.1.54

type KnightSkill struct {
	Name        string   `json:"name"`
	Description string   `json:"description"`
	Scope       string   `json:"scope"`
	Staging     bool     `json:"staging"`
	CreatedBy   string   `json:"created_by"`
	UsageCount  int      `json:"usage_count"`
	Frozen      bool     `json:"frozen"`
	Platforms   []string `json:"platforms,omitempty"`
	Path        string   `json:"path,omitempty"`
	CreatedAt   string   `json:"created_at,omitempty"`
	UpdatedAt   string   `json:"updated_at,omitempty"`
}

type KnightSkillContentFunc added in v1.1.55

type KnightSkillContentFunc func(name string, staging bool) (string, error)

KnightSkillContentFunc reads the raw content of a skill file by name and staging flag.

type KnightStatus added in v1.1.54

type KnightStatus struct {
	Enabled bool              `json:"enabled"`
	Running bool              `json:"running"`
	Status  string            `json:"status"` // human-readable status string
	Budget  KnightBudget      `json:"budget"`
	Active  []KnightSkill     `json:"active"`
	Staging []KnightSkill     `json:"staging"`
	Queue   []KnightCandidate `json:"queue"`
}

KnightStatus holds all Knight state exposed via the WebUI API.

type KnightStatusFunc added in v1.1.54

type KnightStatusFunc func() KnightStatus

KnightStatusFunc returns current Knight agent status and skill data.

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) SetKnightActionFn added in v1.1.55

func (s *Server) SetKnightActionFn(fn KnightActionFunc)

SetKnightActionFn sets the callback for Knight skill actions.

func (*Server) SetKnightSkillContentFn added in v1.1.55

func (s *Server) SetKnightSkillContentFn(fn KnightSkillContentFunc)

SetKnightSkillContentFn sets the callback for reading skill file content.

func (*Server) SetKnightStatusFn added in v1.1.54

func (s *Server) SetKnightStatusFn(fn KnightStatusFunc)

SetKnightStatusFn sets the callback for Knight agent status.

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) SetSaveScope added in v1.1.53

func (s *Server) SetSaveScope(scope string)

SetSaveScope sets the config save scope for WebUI operations.

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.

func (*Server) Token added in v1.2.6

func (s *Server) Token() string

Token returns the server's auth token for display in the TUI/daemon.

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