explain

package
v2.16.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: MIT Imports: 27 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package explain lets the person talk to the agents of a harnsy project over h2a (github.com/harnesy/h2a-go) about what they look at in Buggregator: an event (the server builds its text) or a page (the client describes it). Conversations are kept in SQLite; obvious secrets are masked before a text leaves the machine. Off unless a URL and a token are set.

Index

Constants

View Source
const (
	KindEvent = "event"
	KindPage  = "page"
)

Context kinds: an event the server reads itself, or a page the client describes in its own text.

View Source
const (
	EventName       = "assist.message"
	LegacyEventName = "explain.message"
)

EventName is the WebSocket event of a new line in a thread, on the thread's project channel. LegacyEventName is sent too for event threads while the UI still uses /api/explain.

View Source
const (
	StatusChannel   = "assist"
	StatusEventName = "assist.status"
)

StatusChannel is the server channel every UI client is subscribed to; StatusEventName on it says the pass's address list changed (the node sends a new welcome when the person edits the pass).

Variables

This section is empty.

Functions

func Prompt

func Prompt(payload json.RawMessage, question string, limit int) (string, error)

Prompt builds the plain text the agents get for a Sentry error event, at most limit bytes (0: defaultTextBytes). question, when set, is the person's own words, put first.

Types

type Config

type Config struct {
	URL   string // wss://<node gateway>/h2a/v1
	Token string // the pass's token (h2a_…), a secret
	To    string // the address the explanations go to; "" = lead
	MCP   MCP
}

Config of the h2a connection.

type Context

type Context struct {
	Kind    string `json:"kind"`
	Key     string `json:"key"`
	Title   string `json:"title,omitempty"`
	Text    string `json:"text,omitempty"`
	Project string `json:"project,omitempty"`
}

Context is what a conversation is about.

type MCP

type MCP struct {
	On        bool
	ReadOnly  bool
	Transport string // socket or http
}

MCP is what the module knows of Buggregator's own MCP server: when it is on and read-only, every first message points the agents to it.

type Message

type Message struct {
	From    string    `json:"from"` // "you" or "agent"
	Role    string    `json:"role,omitempty"`
	Project string    `json:"project,omitempty"`
	Text    string    `json:"text"`
	Context bool      `json:"context,omitempty"` // the context text sent first
	At      time.Time `json:"at"`
}

Message is one line of a thread: the person's words or an agent's answer.

type Module

type Module struct {
	module.BaseModule
	// contains filtered or unexported fields
}

func New

func New(cfg Config) *Module

func (*Module) Name

func (m *Module) Name() string

func (*Module) OnEventsDeleted

func (m *Module) OnEventsDeleted(uuids []string)

func (*Module) OnInit

func (m *Module) OnInit(db *sql.DB) error

func (*Module) RegisterMigrations

func (m *Module) RegisterMigrations(migrator *storage.Migrator) error

RegisterMigrations adds the assist_threads and assist_messages tables.

func (*Module) RegisterProtectedRoutes

func (m *Module) RegisterProtectedRoutes(mux *http.ServeMux, protect func(http.Handler) http.Handler)

func (*Module) RegisterRoutes

func (m *Module) RegisterRoutes(_ *http.ServeMux, store event.Store)

func (*Module) SetBroadcaster

func (m *Module) SetBroadcaster(b module.Broadcaster)

func (*Module) Start

func (m *Module) Start(ctx context.Context) error

Start connects in the background: harnsy being away never stops Buggregator.

func (*Module) Stop

func (m *Module) Stop() error

func (*Module) TCPServers

func (m *Module) TCPServers() []tcp.ServerConfig

TCPServers runs the h2a client with the other servers: started after startup, stopped on shutdown. It opens no port.

func (*Module) Type

func (m *Module) Type() string

type Summary

type Summary struct {
	ID        int64     `json:"id"`
	Kind      string    `json:"kind"`
	Key       string    `json:"key"`
	Title     string    `json:"title"`
	Project   string    `json:"project"`
	To        string    `json:"to"`
	UpdatedAt time.Time `json:"updated_at"`
	LastFrom  string    `json:"last_from"`
}

Summary is a thread in the recent list.

type Thread

type Thread struct {
	ID           int64     `json:"id"`
	Kind         string    `json:"kind"`
	Key          string    `json:"key"`
	Title        string    `json:"title"`
	Project      string    `json:"project"`
	Conversation string    `json:"conversation"`
	To           string    `json:"to"` // the h2a address the thread was started with
	CreatedAt    time.Time `json:"created_at"`
	UpdatedAt    time.Time `json:"updated_at"`
	Messages     []Message `json:"messages"`
}

Thread is the conversation with the agents about one context.

Jump to

Keyboard shortcuts

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