bus

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SystemChannel            = "system"
	SystemTypeSubagentResult = "subagent_result"

	SystemMetaType          = "system_type"
	SystemMetaTaskID        = "task_id"
	SystemMetaTaskLabel     = "task_label"
	SystemMetaOriginChannel = "origin_channel"
	SystemMetaOriginChatID  = "origin_chat_id"
	SystemMetaOriginSender  = "origin_sender_id"
	SystemMetaStatus        = "status"
)

Variables

This section is empty.

Functions

func NewRequestID added in v0.1.5

func NewRequestID() string

NewRequestID creates a request id for tracing.

func RequestIDFromContext added in v0.1.5

func RequestIDFromContext(ctx context.Context) string

RequestIDFromContext reads request id from context.

func WithRequestID added in v0.1.5

func WithRequestID(ctx context.Context, requestID string) context.Context

WithRequestID adds a request id to context.

Types

type InboundMessage

type InboundMessage struct {
	Channel   string
	SenderID  string
	ChatID    string
	SessionID string
	Content   string
	Timestamp time.Time
	Media     []string
	Metadata  map[string]any
	RequestID string
}

InboundMessage received from a channel

func NewSubagentResultInbound added in v0.3.0

func NewSubagentResultInbound(taskID, label, originChannel, originChatID, originSenderID, result, requestID string, runErr error) *InboundMessage

NewSubagentResultInbound creates a normalized system message for async subagent callbacks.

func (*InboundMessage) SessionKey

func (m *InboundMessage) SessionKey() string

SessionKey returns unique session identifier

type MessageBus

type MessageBus struct {
	// contains filtered or unexported fields
}

MessageBus handles message routing between channels and agent

func NewMessageBus

func NewMessageBus(bufferSize int) *MessageBus

NewMessageBus creates a new message bus

func (*MessageBus) Close

func (b *MessageBus) Close()

Close closes both channels

func (*MessageBus) Inbound

func (b *MessageBus) Inbound() <-chan *InboundMessage

Inbound returns the inbound channel for consuming

func (*MessageBus) Outbound

func (b *MessageBus) Outbound() <-chan *OutboundMessage

Outbound returns the outbound channel for consuming

func (*MessageBus) PublishInbound

func (b *MessageBus) PublishInbound(msg *InboundMessage)

PublishInbound sends a message to the agent

func (*MessageBus) PublishOutbound

func (b *MessageBus) PublishOutbound(msg *OutboundMessage)

PublishOutbound sends a message to channels

type OutboundMessage

type OutboundMessage struct {
	Channel   string
	ChatID    string
	Content   string
	ReplyTo   string
	Media     []string
	Metadata  map[string]any
	RequestID string
}

OutboundMessage to send to a channel

Jump to

Keyboard shortcuts

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