web

package
v2.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: MIT Imports: 21 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

Index

Constants

View Source
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.

View Source
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

func (c *WebChannel) BeginStream(ctx context.Context, chatID string) (channels.Streamer, error)

BeginStream implements channels.StreamingCapable for the web UI.

func (*WebChannel) ClearToolFeedbackMessage

func (c *WebChannel) ClearToolFeedbackMessage(chatID string)

func (*WebChannel) DeleteMessage

func (c *WebChannel) DeleteMessage(ctx context.Context, chatID string, messageID string) error

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 (c *WebChannel) EditMessageWithPayload(
	ctx context.Context,
	chatID string,
	messageID string,
	payload map[string]any,
) error

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

func (c *WebChannel) SendPlaceholder(ctx context.Context, chatID string) (string, error)

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

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.

func (*WebClientChannel) Stop

func (c *WebClientChannel) Stop(ctx context.Context) error

Stop closes the connection.

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.

Jump to

Keyboard shortcuts

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