Documentation
¶
Index ¶
- Constants
- type WebChannel
- func (c *WebChannel) BeginStream(ctx context.Context, chatID string) (channels.Streamer, error)
- func (c *WebChannel) ClearToolFeedbackMessage(chatID string)
- func (c *WebChannel) DeleteMessage(ctx context.Context, chatID string, messageID string) error
- func (c *WebChannel) DismissToolFeedbackMessage(ctx context.Context, chatID string)
- func (c *WebChannel) EditMessage(ctx context.Context, chatID string, messageID string, content string) error
- func (c *WebChannel) EditMessageWithPayload(ctx context.Context, chatID string, messageID string, payload map[string]any) error
- func (c *WebChannel) FinalizeToolFeedbackMessage(ctx context.Context, msg bus.OutboundMessage) ([]string, bool)
- func (c *WebChannel) RecordToolFeedbackMessage(chatID, messageID, content string)
- func (c *WebChannel) Send(ctx context.Context, msg bus.OutboundMessage) ([]string, error)
- func (c *WebChannel) SendMedia(ctx context.Context, msg bus.OutboundMediaMessage) ([]string, error)
- func (c *WebChannel) SendPlaceholder(ctx context.Context, chatID string) (string, error)
- func (c *WebChannel) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (c *WebChannel) Start(ctx context.Context) error
- func (c *WebChannel) StartTyping(ctx context.Context, chatID string) (func(), error)
- func (c *WebChannel) Stop(ctx context.Context) error
- func (c *WebChannel) WebhookPath() string
- type WebClientChannel
- func (c *WebClientChannel) Send(ctx context.Context, msg bus.OutboundMessage) ([]string, error)
- func (c *WebClientChannel) Start(ctx context.Context) error
- func (c *WebClientChannel) StartTyping(ctx context.Context, chatID string) (func(), error)
- func (c *WebClientChannel) Stop(ctx context.Context) error
- type WebMessage
Constants ¶
const ( // TypeMessageSend is sent from client to server. TypeMessageSend = "message.send" TypeMediaSend = "media.send" TypePing = "ping" // TypeMessageCreate is sent from server to client. TypeMessageCreate = "message.create" TypeMessageUpdate = "message.update" TypeMessageDelete = "message.delete" TypeMediaCreate = "media.create" TypeTypingStart = "typing.start" TypeTypingStop = "typing.stop" TypeError = "error" TypePong = "pong" PayloadKeyContent = "content" PayloadKeyKind = "kind" PayloadKeyPlaceholder = "placeholder" PayloadKeyToolCalls = "tool_calls" PayloadKeyModelName = "model_name" PayloadKeySelection = "selection" PayloadKeyServedTarget = "served_target" PayloadKeyServedIdentity = "served_identity" PayloadKeyUsage = "usage" MessageKindThought = "thought" MessageKindToolCalls = "tool_calls" )
Protocol message types.
const MediaContentSecurityPolicy = "sandbox; default-src 'none'"
MediaContentSecurityPolicy is the CSP of every downloaded file: opened in the browser, it runs no script and loads nothing.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type WebChannel ¶
type WebChannel struct {
*channels.BaseChannel
// contains filtered or unexported fields
}
WebChannel implements the native web chat protocol WebSocket channel. It serves as the reference implementation for all optional capability interfaces.
func NewWebChannel ¶
func NewWebChannel( bc *config.Channel, cfg *config.WebChatSettings, messageBus *bus.MessageBus, ) (*WebChannel, error)
NewWebChannel creates a new web chat channel.
func (*WebChannel) BeginStream ¶
BeginStream implements channels.StreamingCapable for the web UI.
func (*WebChannel) ClearToolFeedbackMessage ¶
func (c *WebChannel) ClearToolFeedbackMessage(chatID string)
func (*WebChannel) DeleteMessage ¶
DeleteMessage implements channels.MessageDeleter.
func (*WebChannel) DismissToolFeedbackMessage ¶
func (c *WebChannel) DismissToolFeedbackMessage(ctx context.Context, chatID string)
func (*WebChannel) EditMessage ¶
func (c *WebChannel) EditMessage(ctx context.Context, chatID string, messageID string, content string) error
EditMessage implements channels.MessageEditor.
func (*WebChannel) EditMessageWithPayload ¶
func (*WebChannel) FinalizeToolFeedbackMessage ¶
func (c *WebChannel) FinalizeToolFeedbackMessage(ctx context.Context, msg bus.OutboundMessage) ([]string, bool)
func (*WebChannel) RecordToolFeedbackMessage ¶
func (c *WebChannel) RecordToolFeedbackMessage(chatID, messageID, content string)
func (*WebChannel) Send ¶
func (c *WebChannel) Send(ctx context.Context, msg bus.OutboundMessage) ([]string, error)
Send implements Channel — sends a message to the appropriate WebSocket connection.
func (*WebChannel) SendMedia ¶
func (c *WebChannel) SendMedia(ctx context.Context, msg bus.OutboundMediaMessage) ([]string, error)
SendMedia implements channels.MediaSender for the web UI. Media is delivered as a normal assistant message carrying structured attachments plus an authenticated same-origin download URL.
func (*WebChannel) SendPlaceholder ¶
SendPlaceholder implements channels.PlaceholderCapable. It sends a placeholder message via the web chat protocol that will later be edited to the actual response via EditMessage (channels.MessageEditor).
func (*WebChannel) ServeHTTP ¶
func (c *WebChannel) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements http.Handler for the shared HTTP server.
func (*WebChannel) Start ¶
func (c *WebChannel) Start(ctx context.Context) error
Start implements Channel.
func (*WebChannel) StartTyping ¶
func (c *WebChannel) StartTyping(ctx context.Context, chatID string) (func(), error)
StartTyping implements channels.TypingCapable.
func (*WebChannel) Stop ¶
func (c *WebChannel) Stop(ctx context.Context) error
Stop implements Channel.
func (*WebChannel) WebhookPath ¶
func (c *WebChannel) WebhookPath() string
WebhookPath implements channels.WebhookHandler.
type WebClientChannel ¶
type WebClientChannel struct {
*channels.BaseChannel
// contains filtered or unexported fields
}
WebClientChannel connects to a remote web chat protocol WebSocket server.
func NewWebClientChannel ¶
func NewWebClientChannel( bc *config.Channel, cfg *config.WebChatClientSettings, messageBus *bus.MessageBus, ) (*WebClientChannel, error)
NewWebClientChannel creates a new web chat protocol client channel.
func (*WebClientChannel) Send ¶
func (c *WebClientChannel) Send(ctx context.Context, msg bus.OutboundMessage) ([]string, error)
Send sends a message to the remote server.
func (*WebClientChannel) Start ¶
func (c *WebClientChannel) Start(ctx context.Context) error
Start dials the remote server and begins reading.
func (*WebClientChannel) StartTyping ¶
func (c *WebClientChannel) StartTyping(ctx context.Context, chatID string) (func(), error)
StartTyping implements channels.TypingCapable.
type WebMessage ¶
type WebMessage struct {
Type string `json:"type"`
ID string `json:"id,omitempty"`
SessionID string `json:"session_id,omitempty"`
Timestamp int64 `json:"timestamp,omitempty"`
Payload map[string]any `json:"payload,omitempty"`
}
WebMessage is the wire format for all web chat protocol messages.