Documentation
¶
Index ¶
- Variables
- func FileServerWithIndexFallback(chatBasePath string) http.Handler
- func FormatMessage(agentType mf.AgentType, message string) []st.MessagePart
- func SetupProcess(ctx context.Context, config SetupProcessConfig) (*termexec.Process, error)
- type AgentStatus
- type Event
- type EventEmitter
- func (e *EventEmitter) Subscribe() (int, <-chan Event, []Event)
- func (e *EventEmitter) Unsubscribe(chanId int)
- func (e *EventEmitter) UpdateMessagesAndEmitChanges(newMessages []st.ConversationMessage)
- func (e *EventEmitter) UpdateScreenAndEmitChanges(newScreen string)
- func (e *EventEmitter) UpdateStatusAndEmitChanges(newStatus st.ConversationStatus)
- type EventType
- type Message
- type MessageRequest
- type MessageRequestBody
- type MessageResponse
- type MessageType
- type MessageUpdateBody
- type MessagesResponse
- type ScreenUpdateBody
- type Server
- type ServerConfig
- type SetupProcessConfig
- type StatusChangeBody
- type StatusResponse
Constants ¶
This section is empty.
Variables ¶
var AgentStatusValues = []AgentStatus{ AgentStatusStable, AgentStatusRunning, }
var MessageTypeValues = []MessageType{ MessageTypeUser, MessageTypeRaw, }
Functions ¶
func FileServerWithIndexFallback ¶ added in v0.2.0
FileServerWithIndexFallback creates a file server that serves the given filesystem and falls back to index.html for any path that doesn't match a file
func FormatMessage ¶
func FormatMessage(agentType mf.AgentType, message string) []st.MessagePart
func SetupProcess ¶
Types ¶
type AgentStatus ¶
type AgentStatus string
const ( AgentStatusRunning AgentStatus = "running" AgentStatusStable AgentStatus = "stable" )
func (AgentStatus) Schema ¶
func (a AgentStatus) Schema(r huma.Registry) *huma.Schema
type EventEmitter ¶
type EventEmitter struct {
// contains filtered or unexported fields
}
func NewEventEmitter ¶
func NewEventEmitter(subscriptionBufSize int) *EventEmitter
subscriptionBufSize is the size of the buffer for each subscription. Once the buffer is full, the channel will be closed. Listeners must actively drain the channel, so it's important to set this to a value that is large enough to handle the expected number of events.
func (*EventEmitter) Subscribe ¶
func (e *EventEmitter) Subscribe() (int, <-chan Event, []Event)
Subscribe returns: - a subscription ID that can be used to unsubscribe. - a channel for receiving events. - a list of events that allow to recreate the state of the conversation right before the subscription was created.
func (*EventEmitter) Unsubscribe ¶
func (e *EventEmitter) Unsubscribe(chanId int)
func (*EventEmitter) UpdateMessagesAndEmitChanges ¶
func (e *EventEmitter) UpdateMessagesAndEmitChanges(newMessages []st.ConversationMessage)
Assumes that only the last message can change or new messages can be added. If a new message is injected between existing messages (identified by Id), the behavior is undefined.
func (*EventEmitter) UpdateScreenAndEmitChanges ¶
func (e *EventEmitter) UpdateScreenAndEmitChanges(newScreen string)
func (*EventEmitter) UpdateStatusAndEmitChanges ¶
func (e *EventEmitter) UpdateStatusAndEmitChanges(newStatus st.ConversationStatus)
type Message ¶
type Message struct { Id int `` /* 136-byte string literal not displayed */ Content string `` /* 215-byte string literal not displayed */ Role st.ConversationRole `json:"role" doc:"Role of the message author"` Time time.Time `json:"time" doc:"Timestamp of the message"` }
Message represents a message
type MessageRequest ¶
type MessageRequest struct {
Body MessageRequestBody `json:"body" doc:"Message content and type"`
}
MessageRequest represents a request to create a new message
type MessageRequestBody ¶
type MessageRequestBody struct { Content string `json:"content" example:"Hello, agent!" doc:"Message content"` Type MessageType `` /* 451-byte string literal not displayed */ }
type MessageResponse ¶
type MessageResponse struct { Body struct { Ok bool `` /* 256-byte string literal not displayed */ } }
MessageResponse represents a newly created message
type MessageType ¶
type MessageType string
const ( MessageTypeUser MessageType = "user" MessageTypeRaw MessageType = "raw" )
func (MessageType) Schema ¶
func (m MessageType) Schema(r huma.Registry) *huma.Schema
type MessageUpdateBody ¶
type MessagesResponse ¶
type MessagesResponse struct { Body struct { Messages []Message `json:"messages" nullable:"false" doc:"List of messages"` } }
MessagesResponse represents the list of messages
type ScreenUpdateBody ¶
type ScreenUpdateBody struct {
Screen string `json:"screen"`
}
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents the HTTP server
func NewServer ¶
func NewServer(ctx context.Context, config ServerConfig) (*Server, error)
NewServer creates a new server instance
func (*Server) GetOpenAPI ¶
func (*Server) Handler ¶ added in v0.3.1
Handler returns the underlying chi.Router for testing purposes.
func (*Server) NormalizeSchema ¶ added in v0.9.0
func (*Server) StartSnapshotLoop ¶ added in v0.2.0
type ServerConfig ¶ added in v0.3.3
type SetupProcessConfig ¶ added in v0.2.2
type StatusChangeBody ¶
type StatusChangeBody struct {
Status AgentStatus `json:"status" doc:"Agent status"`
}
type StatusResponse ¶
type StatusResponse struct { Body struct { Status AgentStatus `` /* 158-byte string literal not displayed */ } }
StatusResponse represents the server status