adapter

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter interface {
	Name() string
	Start(ctx context.Context, incoming chan<- IncomingMessage) error
	Send(ctx context.Context, msg OutgoingMessage) error
	Stop() error
}

Adapter defines the interface for communication platform integrations.

type CallbackResolver

type CallbackResolver interface {
	Resolve(ctx context.Context, callbackData string) (responseText string, err error)
}

CallbackResolver handles adapter callback queries (e.g. Telegram inline button clicks). The adapter calls Resolve when it receives a callback; the resolver maps the callback data to a human-readable confirmation string. Returns ("", nil) if the callback is unknown or not handled. Defined here (not in approval/) to avoid circular imports.

type IncomingMessage

type IncomingMessage struct {
	Adapter    string
	ExternalID string // chat/conversation ID
	UserID     string
	UserName   string
	Text       string
	Timestamp  time.Time
	// ConversationID, when non-empty, overrides the default adapter:externalID
	// conversation key. Used by the scheduler to create isolated sessions.
	ConversationID string
	// SessionTier, when non-empty, overrides the engine's global permission
	// tier for this message. Used by the scheduler to enforce per-schedule tiers.
	SessionTier string
	// SkillName, when non-empty, indicates this message targets a specific skill.
	// Used by the scheduler to activate schedule-triggered skills.
	SkillName string
	// IsVoice is true when the original message was a voice note.
	// The adapter sets this after transcribing the audio via STT.
	IsVoice bool
}

IncomingMessage represents a message received from an external platform.

type KeyboardButton

type KeyboardButton struct {
	Label        string
	CallbackData string
}

KeyboardButton is an adapter-agnostic inline action button. Each adapter renders it as appropriate (Telegram: inline keyboard button; others may append as text or ignore if unsupported).

type OutgoingMessage

type OutgoingMessage struct {
	// Adapter is the name of the adapter to route the response through (e.g.
	// "telegram", "discord"). Set by Engine.HandleMessage from the incoming
	// message's Adapter field. The SendFunc implementation (typically a
	// Dispatcher wrapper) uses this to select the correct outbound adapter.
	Adapter    string
	ExternalID string
	Text       string
	// IsVoice signals that the adapter should attempt to send a voice reply
	// (via TTS) instead of plain text, if configured to do so.
	IsVoice bool
	// Buttons, when non-empty, requests the adapter render an inline keyboard.
	// Ignored during voice replies.
	Buttons []KeyboardButton
}

OutgoingMessage represents a message to send to an external platform.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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