channels

package
v0.178.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApprovalChannel added in v0.178.0

type ApprovalChannel interface {
	SendApproval(ctx context.Context, recipientID string, req *ipc.ApprovalRequest) error
}

ApprovalChannel is an optional interface that channels can implement to provide rich approval UIs (e.g., inline keyboard buttons) instead of text-based prompts.

type Channel added in v0.178.0

type Channel interface {
	// Name returns the channel identifier (e.g., "whatsapp", "telegram")
	Name() string
	// Start begins listening for inbound messages. Blocks until ctx is cancelled.
	Start(ctx context.Context, inbox chan<- InboundMessage) error
	// Send delivers an outbound message through this channel
	Send(ctx context.Context, msg OutboundMessage) error
	// Stop gracefully shuts down the channel
	Stop() error
}

Channel represents a pluggable messaging transport (WhatsApp, Telegram, etc.)

type ChannelCommand added in v0.178.0

type ChannelCommand struct {
	Name        string
	Description string
}

ChannelCommand describes a slash command a channel may advertise natively (e.g., Telegram's bot command menu).

type FileRetention added in v0.164.0

type FileRetention struct {
	Dir    string
	Keep   int
	Prefix string
	// contains filtered or unexported fields
}

FileRetention persists a bounded number of inbound files (voice recordings, photo/video attachments) to a local directory, pruning the oldest once the count exceeds Keep. A nil *FileRetention or a Keep <= 0 disables retention (the default behavior).

save serializes on mu because the channel manager may process messages concurrently and they all share one directory.

func NewMediaRetention added in v0.164.0

func NewMediaRetention(dir string, keep int) *FileRetention

NewMediaRetention returns a retainer for inbound photo/video attachments.

func NewVoiceRetention added in v0.164.0

func NewVoiceRetention(dir string, keep int) *FileRetention

NewVoiceRetention returns a retainer for inbound voice/audio recordings.

type HistoryCleaner added in v0.178.0

type HistoryCleaner interface {
	ClearHistory(ctx context.Context, recipientID string) error
}

HistoryCleaner is an optional interface that channels can implement to delete the chat's message history on the remote platform (used by /new).

type InboundMessage added in v0.178.0

type InboundMessage struct {
	ChannelName string                        `json:"channel_name"`
	SenderID    string                        `json:"sender_id"`
	Content     string                        `json:"content"`
	Images      []agentdomain.ImageAttachment `json:"images,omitempty"`
	Timestamp   time.Time                     `json:"timestamp"`
	Metadata    map[string]string             `json:"metadata,omitempty"`
}

InboundMessage represents a message received from an external channel

type MessageButton added in v0.178.0

type MessageButton struct {
	Text string `json:"text"`
	Data string `json:"data"`
}

MessageButton is a tappable button attached to an outbound message. Data is delivered back as inbound message content when tapped (channels that have no button UI ignore buttons entirely).

type OutboundMessage added in v0.178.0

type OutboundMessage struct {
	ChannelName string            `json:"channel_name"`
	RecipientID string            `json:"recipient_id"`
	Content     string            `json:"content"`
	Buttons     []MessageButton   `json:"buttons,omitempty"`
	Timestamp   time.Time         `json:"timestamp"`
	Metadata    map[string]string `json:"metadata,omitempty"`
}

OutboundMessage represents a response to send back through a channel

type TelegramChannel

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

TelegramChannel implements Channel for the Telegram Bot API using the go-telegram/bot SDK with long-polling.

func NewTelegramChannel

func NewTelegramChannel(cfg config.TelegramChannelConfig, transcriber VoiceTranscriber, retention *FileRetention) *TelegramChannel

NewTelegramChannel creates a new Telegram channel. transcriber may be nil, in which case inbound voice messages are ignored. retention may be nil to disable local persistence of inbound voice/audio files.

func (*TelegramChannel) ClearHistory added in v0.149.0

func (t *TelegramChannel) ClearHistory(ctx context.Context, recipientID string) error

ClearHistory best-effort deletes the tracked messages of a chat. Implements HistoryCleaner. Telegram silently skips messages it can no longer delete (older than 48h), and batches that fail are logged and skipped.

func (*TelegramChannel) Name

func (t *TelegramChannel) Name() string

Name returns the channel identifier

func (*TelegramChannel) Send

Send delivers a message through the Telegram Bot API

func (*TelegramChannel) SendApproval added in v0.103.0

func (t *TelegramChannel) SendApproval(ctx context.Context, recipientID string, req *ipc.ApprovalRequest) error

SendApproval sends a tool approval prompt with inline keyboard buttons. Implements ApprovalChannel.

func (*TelegramChannel) SetCommands added in v0.149.0

func (t *TelegramChannel) SetCommands(cmds []ChannelCommand)

SetCommands sets the slash commands advertised to Telegram on Start.

func (*TelegramChannel) Start

func (t *TelegramChannel) Start(ctx context.Context, inbox chan<- InboundMessage) error

Start begins long-polling for Telegram updates and sends inbound messages to the inbox

func (*TelegramChannel) Stop

func (t *TelegramChannel) Stop() error

Stop gracefully shuts down the Telegram channel

type VoiceTranscriber added in v0.116.0

type VoiceTranscriber interface {
	TranscribeFile(ctx context.Context, audioPath string) (string, error)
}

VoiceTranscriber transcribes a downloaded audio file (any format ffmpeg can decode) into text. It is defined here so the channel can be wired with a concrete speech-to-text implementation only when the feature is enabled, while remaining nil (and a no-op) otherwise.

Jump to

Keyboard shortcuts

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