Documentation
¶
Index ¶
- Variables
- type AudioChunk
- type InboundMessage
- type MediaPart
- type MessageBus
- func (mb *MessageBus) AudioChunksChan() <-chan AudioChunk
- func (mb *MessageBus) Close()
- func (mb *MessageBus) GetStreamer(ctx context.Context, channel, chatID string) (Streamer, bool)
- func (mb *MessageBus) InboundChan() <-chan InboundMessage
- func (mb *MessageBus) OutboundChan() <-chan OutboundMessage
- func (mb *MessageBus) OutboundMediaChan() <-chan OutboundMediaMessage
- func (mb *MessageBus) PublishAudioChunk(ctx context.Context, chunk AudioChunk) error
- func (mb *MessageBus) PublishInbound(ctx context.Context, msg InboundMessage) error
- func (mb *MessageBus) PublishOutbound(ctx context.Context, msg OutboundMessage) error
- func (mb *MessageBus) PublishOutboundMedia(ctx context.Context, msg OutboundMediaMessage) error
- func (mb *MessageBus) PublishVoiceControl(ctx context.Context, ctrl VoiceControl) error
- func (mb *MessageBus) SetStreamDelegate(d StreamDelegate)
- func (mb *MessageBus) VoiceControlsChan() <-chan VoiceControl
- type OutboundMediaMessage
- type OutboundMessage
- type Peer
- type SenderInfo
- type StreamDelegate
- type Streamer
- type VoiceControl
Constants ¶
This section is empty.
Variables ¶
var ErrBusClosed = errors.New("message bus closed")
ErrBusClosed is returned when publishing to a closed MessageBus.
Functions ¶
This section is empty.
Types ¶
type AudioChunk ¶ added in v0.2.5
type AudioChunk struct {
SessionID string `json:"session_id"`
SpeakerID string `json:"speaker_id"` // User ID or SSRC
ChatID string `json:"chat_id"` // Where to respond
Channel string `json:"channel"` // Source channel type (e.g. "discord")
Sequence uint64 `json:"sequence"`
Timestamp uint32 `json:"timestamp"`
SampleRate int `json:"sample_rate"`
Channels int `json:"channels"`
Format string `json:"format"` // "opus", "pcm", etc
Data []byte `json:"data"`
}
AudioChunk represents a chunk of streaming voice data.
type InboundMessage ¶
type InboundMessage struct {
Channel string `json:"channel"`
SenderID string `json:"sender_id"`
Sender SenderInfo `json:"sender"`
ChatID string `json:"chat_id"`
Content string `json:"content"`
Media []string `json:"media,omitempty"`
Peer Peer `json:"peer"` // routing peer
MessageID string `json:"message_id,omitempty"` // platform message ID
MediaScope string `json:"media_scope,omitempty"` // media lifecycle scope
SessionKey string `json:"session_key"`
Metadata map[string]string `json:"metadata,omitempty"`
}
type MediaPart ¶ added in v0.2.0
type MediaPart struct {
Type string `json:"type"` // "image" | "audio" | "video" | "file"
Ref string `json:"ref"` // media store ref, e.g. "media://abc123"
Caption string `json:"caption,omitempty"` // optional caption text
Filename string `json:"filename,omitempty"` // original filename hint
ContentType string `json:"content_type,omitempty"` // MIME type hint
}
MediaPart describes a single media attachment to send.
type MessageBus ¶
type MessageBus struct {
// contains filtered or unexported fields
}
func NewMessageBus ¶
func NewMessageBus() *MessageBus
func (*MessageBus) AudioChunksChan ¶ added in v0.2.5
func (mb *MessageBus) AudioChunksChan() <-chan AudioChunk
func (*MessageBus) Close ¶
func (mb *MessageBus) Close()
func (*MessageBus) GetStreamer ¶ added in v0.2.4
GetStreamer returns a Streamer for the given channel+chatID via the delegate.
func (*MessageBus) InboundChan ¶ added in v0.2.4
func (mb *MessageBus) InboundChan() <-chan InboundMessage
func (*MessageBus) OutboundChan ¶ added in v0.2.4
func (mb *MessageBus) OutboundChan() <-chan OutboundMessage
func (*MessageBus) OutboundMediaChan ¶ added in v0.2.4
func (mb *MessageBus) OutboundMediaChan() <-chan OutboundMediaMessage
func (*MessageBus) PublishAudioChunk ¶ added in v0.2.5
func (mb *MessageBus) PublishAudioChunk(ctx context.Context, chunk AudioChunk) error
func (*MessageBus) PublishInbound ¶
func (mb *MessageBus) PublishInbound(ctx context.Context, msg InboundMessage) error
func (*MessageBus) PublishOutbound ¶
func (mb *MessageBus) PublishOutbound(ctx context.Context, msg OutboundMessage) error
func (*MessageBus) PublishOutboundMedia ¶ added in v0.2.0
func (mb *MessageBus) PublishOutboundMedia(ctx context.Context, msg OutboundMediaMessage) error
func (*MessageBus) PublishVoiceControl ¶ added in v0.2.5
func (mb *MessageBus) PublishVoiceControl(ctx context.Context, ctrl VoiceControl) error
func (*MessageBus) SetStreamDelegate ¶ added in v0.2.4
func (mb *MessageBus) SetStreamDelegate(d StreamDelegate)
SetStreamDelegate registers a StreamDelegate (typically the channel Manager).
func (*MessageBus) VoiceControlsChan ¶ added in v0.2.5
func (mb *MessageBus) VoiceControlsChan() <-chan VoiceControl
type OutboundMediaMessage ¶ added in v0.2.0
type OutboundMediaMessage struct {
Channel string `json:"channel"`
ChatID string `json:"chat_id"`
Parts []MediaPart `json:"parts"`
}
OutboundMediaMessage carries media attachments from Agent to channels via the bus.
type OutboundMessage ¶
type Peer ¶ added in v0.2.0
type Peer struct {
Kind string `json:"kind"` // "direct" | "group" | "channel" | ""
ID string `json:"id"`
}
Peer identifies the routing peer for a message (direct, group, channel, etc.)
type SenderInfo ¶ added in v0.2.0
type SenderInfo struct {
Platform string `json:"platform,omitempty"` // "telegram", "discord", "slack", ...
PlatformID string `json:"platform_id,omitempty"` // raw platform ID, e.g. "123456"
CanonicalID string `json:"canonical_id,omitempty"` // "platform:id" format
Username string `json:"username,omitempty"` // username (e.g. @alice)
DisplayName string `json:"display_name,omitempty"` // display name
}
SenderInfo provides structured sender identity information.
type StreamDelegate ¶ added in v0.2.4
type StreamDelegate interface {
// GetStreamer returns a Streamer for the given channel+chatID if the channel
// supports streaming. Returns nil, false if streaming is unavailable.
GetStreamer(ctx context.Context, channel, chatID string) (Streamer, bool)
}
StreamDelegate is implemented by the channel Manager to provide streaming capabilities to the agent loop without tight coupling.
type Streamer ¶ added in v0.2.4
type Streamer interface {
Update(ctx context.Context, content string) error
Finalize(ctx context.Context, content string) error
Cancel(ctx context.Context)
}
Streamer pushes incremental content to a streaming-capable channel. Defined here so the agent loop can use it without importing pkg/channels.
type VoiceControl ¶ added in v0.2.5
type VoiceControl struct {
SessionID string `json:"session_id"`
ChatID string `json:"chat_id"`
Type string `json:"type"` // "state", "command"
Action string `json:"action"` // "idle", "listening", "start", "stop", "leave"
}
VoiceControl represents state or commands for voice sessions.