bus

package
v0.0.0-...-8155ea7 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: GPL-2.0, GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBusClosed = errors.New("message bus closed")

ErrBusClosed is returned when publishing to a closed MessageBus.

Functions

This section is empty.

Types

type AgentEvent

type AgentEvent struct {
	Kind       AgentEventKind `json:"kind"`
	ToolName   string         `json:"tool_name,omitempty"`
	ToolArgs   map[string]any `json:"tool_args,omitempty"`
	ToolError  string         `json:"tool_error,omitempty"`
	Content    string         `json:"content,omitempty"`
	SessionKey string         `json:"session_key"`
	Channel    string         `json:"channel"`
	ChatID     string         `json:"chat_id"`
	Iteration  int            `json:"iteration,omitempty"`
}

AgentEvent represents a real-time event emitted during agent processing. It is designed to be JSON-serializable and transport-agnostic.

type AgentEventKind

type AgentEventKind string

AgentEventKind identifies the type of agent activity event.

const (
	EventToolStart    AgentEventKind = "tool_start"
	EventToolEnd      AgentEventKind = "tool_end"
	EventContentStart AgentEventKind = "content_start"
	EventContentChunk AgentEventKind = "content_chunk"
	EventThinking     AgentEventKind = "thinking"
	EventDone         AgentEventKind = "done"
	EventError        AgentEventKind = "error"
)

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

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) Close

func (mb *MessageBus) Close()

func (*MessageBus) ConsumeInbound

func (mb *MessageBus) ConsumeInbound(ctx context.Context) (InboundMessage, bool)

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

func (mb *MessageBus) PublishOutboundMedia(ctx context.Context, msg OutboundMediaMessage) error

func (*MessageBus) SubscribeOutbound

func (mb *MessageBus) SubscribeOutbound(ctx context.Context) (OutboundMessage, bool)

func (*MessageBus) SubscribeOutboundMedia

func (mb *MessageBus) SubscribeOutboundMedia(ctx context.Context) (OutboundMediaMessage, bool)

type OutboundMediaMessage

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 OutboundMessage struct {
	Channel          string `json:"channel"`
	ChatID           string `json:"chat_id"`
	Content          string `json:"content"`
	ReplyToMessageID string `json:"reply_to_message_id,omitempty"`
}

type Peer

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

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.

Jump to

Keyboard shortcuts

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