web

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package web provides the web dashboard and chat interface for Thane.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterRoutes

func RegisterRoutes(mux *http.ServeMux)

RegisterRoutes adds the chat UI routes to a mux. This is the legacy package-level function kept for backward compatibility when no WebServer is wired in.

Types

type AnticipationStore

type AnticipationStore interface {
	Active() ([]*scheduler.Anticipation, error)
	All() ([]*scheduler.Anticipation, error)
	Get(id string) (*scheduler.Anticipation, error)
}

AnticipationStore is the subset of scheduler.AnticipationStore used by the dashboard.

type AnticipationsData

type AnticipationsData struct {
	PageData
	Anticipations []*anticipationRow
	Filter        string // "active" or "all"
}

AnticipationsData is the template context for the anticipations list page.

type ChatData

type ChatData struct {
	PageData
}

ChatData is the template context for the chat page.

type Config

type Config struct {
	BrandName         string // Display name in the nav bar. Defaults to "Thane".
	StatsFunc         StatsFunc
	RouterFunc        RouterFunc
	HealthFunc        HealthFunc
	ContactStore      ContactStore
	FactStore         FactStore
	TaskStore         TaskStore
	AnticipationStore AnticipationStore
	SessionStore      SessionStore
	LogStore          LogStore          // Optional: structured log index queries.
	LiveMessageSource LiveMessageSource // Optional: live messages for active sessions.
	Logger            *slog.Logger
}

Config holds the dependencies needed to construct a WebServer.

type ContactDetailData

type ContactDetailData struct {
	PageData
	ID         uuid.UUID
	Name       string
	Kind       string
	TrustZone  string
	Org        string
	Title      string
	AISummary  string
	Note       string
	CreatedAt  string
	UpdatedAt  string
	Properties []contacts.Property
}

ContactDetailData is the template context for a single contact.

type ContactStore

type ContactStore interface {
	ListAll() ([]*contacts.Contact, error)
	Search(query string) ([]*contacts.Contact, error)
	GetWithProperties(id uuid.UUID) (*contacts.Contact, error)
	FindByTrustZone(zone string) ([]*contacts.Contact, error)
	ListByKind(kind string) ([]*contacts.Contact, error)
}

ContactStore is the subset of contacts.Store used by the dashboard.

type ContactsData

type ContactsData struct {
	PageData
	Contacts  []*contactRow
	Query     string
	TrustZone string
	Kind      string
}

ContactsData is the template context for the contacts list page.

type DashboardData

type DashboardData struct {
	PageData
	Stats  StatsSnapshot
	Router RouterInfo
	Health map[string]HealthStatus
	Uptime time.Duration
}

DashboardData is the template context for the runtime overview page.

type FactStore

type FactStore interface {
	GetAll() ([]*knowledge.Fact, error)
	GetByCategory(category knowledge.Category) ([]*knowledge.Fact, error)
	Search(query string) ([]*knowledge.Fact, error)
}

FactStore is the subset of knowledge.Store used by the dashboard.

type FactsData

type FactsData struct {
	PageData
	Facts    []*factRow
	Query    string
	Category string
}

FactsData is the template context for the facts list page.

type HealthFunc

type HealthFunc func() map[string]HealthStatus

HealthFunc returns dependency health keyed by service name.

type HealthStatus

type HealthStatus struct {
	Connected bool      `json:"connected"`
	Since     time.Time `json:"since,omitempty"`
	LastError string    `json:"last_error,omitempty"`
}

HealthStatus describes the health of a single dependency.

type LiveMessageSource

type LiveMessageSource interface {
	GetMessages(conversationID string) []memory.Message
}

LiveMessageSource provides access to live (unarchived) conversation messages. Used as a fallback for active sessions whose messages haven't been archived yet.

type LogStore added in v0.8.1

type LogStore interface {
	QueryBySession(sessionID, level, subsystem string, limit int) ([]logging.LogEntry, error)
}

LogStore queries the structured log index for session-scoped entries.

type PageData

type PageData struct {
	BrandName string
	ActiveNav string
}

PageData contains fields shared by all page templates. Every template data struct should embed this so the layout can render the nav bar.

type RouterFunc

type RouterFunc func() RouterInfo

RouterFunc returns combined router statistics and model list.

type RouterInfo

type RouterInfo struct {
	Stats  router.Stats   `json:"stats"`
	Models []router.Model `json:"models"`
}

RouterInfo combines routing stats and the model roster.

type SessionDetailData

type SessionDetailData struct {
	PageData
	Session               *sessionDetailView
	Messages              []*messageRow
	ToolCalls             []*toolCallRow
	ToolSummary           []*toolSummaryRow
	Iterations            []*iterationRow
	UnattributedToolCalls []*toolCallRow
	LogsEnabled           bool
}

SessionDetailData is the template context for the session detail page.

type SessionLogsData added in v0.8.1

type SessionLogsData struct {
	PageData
	SessionID string
	Entries   []*logEntryRow
	Level     string // current filter value
	Subsystem string // current filter value
}

SessionLogsData is the template data for the session_logs.html partial.

type SessionStore

type SessionStore interface {
	ListSessions(conversationID string, limit int) ([]*memory.Session, error)
	ListChildSessions(parentSessionID string) ([]*memory.Session, error)
	GetSession(sessionID string) (*memory.Session, error)
	GetSessionTranscript(sessionID string) ([]memory.Message, error)
	GetSessionToolCalls(sessionID string) ([]memory.ArchivedToolCall, error)
	GetSessionIterations(sessionID string) ([]memory.ArchivedIteration, error)
}

SessionStore is the subset of memory.ArchiveStore used by the web dashboard's session inspector.

type SessionsData

type SessionsData struct {
	PageData
	Sessions       []*sessionRow
	ConversationID string
}

SessionsData is the template context for the sessions list page.

type StatsFunc

type StatsFunc func() StatsSnapshot

StatsFunc returns a snapshot of session statistics.

type StatsSnapshot

type StatsSnapshot struct {
	Build map[string]string `json:"build,omitempty"`
}

StatsSnapshot holds runtime info for the dashboard. Currently only build metadata is needed; per-conversation stats were removed because they are misleading in Thane's multi-conversation architecture.

type TaskDetailData

type TaskDetailData struct {
	PageData
	Task       *scheduler.Task
	NextFire   string
	Executions []*scheduler.Execution
}

TaskDetailData is the template context for a single task.

type TaskStore

type TaskStore interface {
	ListTasks(enabledOnly bool) ([]*scheduler.Task, error)
	GetTask(id string) (*scheduler.Task, error)
	GetTaskExecutions(taskID string, limit int) ([]*scheduler.Execution, error)
}

TaskStore is the subset of scheduler.Scheduler used by the dashboard.

type TasksData

type TasksData struct {
	PageData
	Tasks []*taskRow
}

TasksData is the template context for the tasks list page.

type WebServer

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

WebServer serves the web dashboard and chat UI.

func NewWebServer

func NewWebServer(cfg Config) *WebServer

NewWebServer creates a WebServer with parsed templates. It panics if templates contain syntax errors, providing fail-fast behavior at startup.

func (*WebServer) RegisterRoutes

func (s *WebServer) RegisterRoutes(mux *http.ServeMux)

RegisterRoutes adds dashboard, chat UI, and static file routes to the mux.

Jump to

Keyboard shortcuts

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