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
- func Prompt(payload json.RawMessage, question string, limit int) (string, error)
- type Config
- type Context
- type MCP
- type Message
- type Module
- func (m *Module) Name() string
- func (m *Module) OnEventsDeleted(uuids []string)
- func (m *Module) OnInit(db *sql.DB) error
- func (m *Module) RegisterMigrations(migrator *storage.Migrator) error
- func (m *Module) RegisterProtectedRoutes(mux *http.ServeMux, protect func(http.Handler) http.Handler)
- func (m *Module) RegisterRoutes(_ *http.ServeMux, store event.Store)
- func (m *Module) SetBroadcaster(b module.Broadcaster)
- func (m *Module) Start(ctx context.Context) error
- func (m *Module) Stop() error
- func (m *Module) TCPServers() []tcp.ServerConfig
- func (m *Module) Type() string
- type Summary
- type Thread
Constants ¶
const ( KindEvent = "event" KindPage = "page" )
Context kinds: an event the server reads itself, or a page the client describes in its own text.
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.
Variables ¶
This section is empty.
Functions ¶
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 ¶
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 (*Module) OnEventsDeleted ¶
func (*Module) RegisterMigrations ¶
RegisterMigrations adds the assist_threads and assist_messages tables.
func (*Module) RegisterProtectedRoutes ¶
func (*Module) RegisterRoutes ¶
func (*Module) SetBroadcaster ¶
func (m *Module) SetBroadcaster(b module.Broadcaster)
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.
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.