channels

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2026 License: MIT Imports: 44 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckCapability added in v0.3.1

func CheckCapability(capabilities ChannelCapabilities, capability CapabilityType, ctx ChatContext) bool

CheckCapability checks if a capability is enabled in the given context

func FormatThreadBindingDisabledError added in v0.3.2

func FormatThreadBindingDisabledError(channel, accountID, kind string) string

FormatThreadBindingDisabledError formats an error message for disabled thread bindings.

func FormatThreadBindingSpawnDisabledError added in v0.3.2

func FormatThreadBindingSpawnDisabledError(channel, accountID, kind string) string

FormatThreadBindingSpawnDisabledError formats an error message for disabled spawn.

func IsCapabilityEnabled added in v0.3.1

func IsCapabilityEnabled(capabilities ChannelCapabilities, capability CapabilityType, scope CapabilityScope, isWhitelisted bool) bool

IsCapabilityEnabled checks if a capability is enabled for the given context

func ResolveThreadBindingIdleTimeoutMsForChannel added in v0.3.2

func ResolveThreadBindingIdleTimeoutMsForChannel(cfg *config.Config, channel, accountID string) int

ResolveThreadBindingIdleTimeoutMsForChannel returns the idle timeout for a channel.

func ResolveThreadBindingIntroText added in v0.3.2

func ResolveThreadBindingIntroText(agentID, label string, idleTimeoutMs, maxAgeMs int, sessionCwd string, sessionDetails []string) string

ResolveThreadBindingIntroText generates intro text for a thread binding.

func ResolveThreadBindingMaxAgeMsForChannel added in v0.3.2

func ResolveThreadBindingMaxAgeMsForChannel(cfg *config.Config, channel, accountID string) int

ResolveThreadBindingMaxAgeMsForChannel returns the max age for a channel.

func ResolveThreadBindingThreadName added in v0.3.2

func ResolveThreadBindingThreadName(agentID, label string) string

ResolveThreadBindingThreadName generates a thread name for a binding.

Types

type ATMessageEventData

type ATMessageEventData struct {
	ID        string `json:"id"`
	Content   string `json:"content"`
	Timestamp string `json:"timestamp"`
	Author    struct {
		ID       string `json:"id"`
		Username string `json:"username"`
	} `json:"author"`
	ChannelID string `json:"channel_id"`
	GuildID   string `json:"guild_id"`
}

ATMessageEventData 频道 @消息事件数据

type AcpSessionRouter added in v0.3.2

type AcpSessionRouter interface {
	RouteToAcpSession(channel, accountID, conversationID string) string
	IsACPThreadBinding(channel, accountID, conversationID string) bool
}

AcpSessionRouter is an interface for routing messages to ACP sessions. This avoids circular dependency between channels and acp packages.

type BaseChannel

type BaseChannel interface {
	// Name 返回通道名称
	Name() string

	// AccountID 返回通道账号ID
	AccountID() string

	// Start 启动通道
	Start(ctx context.Context) error

	// Stop 停止通道
	Stop() error

	// Send 发送消息
	Send(msg *bus.OutboundMessage) error

	// SendStream 发送流式消息
	SendStream(chatID string, stream <-chan *bus.StreamMessage) error

	// IsAllowed 检查发送者是否允许
	IsAllowed(senderID string) bool
}

BaseChannel 通道基础接口

type BaseChannelConfig

type BaseChannelConfig struct {
	Enabled    bool     `mapstructure:"enabled" json:"enabled"`
	AccountID  string   `mapstructure:"account_id" json:"account_id"` // 账号ID
	Name       string   `mapstructure:"name" json:"name"`             // 账号显示名称
	AllowedIDs []string `mapstructure:"allowed_ids" json:"allowed_ids"`
}

BaseChannelConfig 通道基础配置

type BaseChannelImpl

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

BaseChannelImpl 通道基础实现

func NewBaseChannelImpl

func NewBaseChannelImpl(name, accountID string, config BaseChannelConfig, bus *bus.MessageBus) *BaseChannelImpl

NewBaseChannelImpl 创建通道基础实现

func (*BaseChannelImpl) AccountID

func (c *BaseChannelImpl) AccountID() string

AccountID 返回通道账号ID

func (*BaseChannelImpl) IsAllowed

func (c *BaseChannelImpl) IsAllowed(senderID string) bool

IsAllowed 检查发送者是否允许

func (*BaseChannelImpl) IsRunning

func (c *BaseChannelImpl) IsRunning() bool

IsRunning 检查是否运行中

func (*BaseChannelImpl) Name

func (c *BaseChannelImpl) Name() string

Name 返回通道名称

func (*BaseChannelImpl) PublishInbound

func (c *BaseChannelImpl) PublishInbound(ctx context.Context, msg *bus.InboundMessage) error

PublishInbound 发布入站消息

func (*BaseChannelImpl) SendStream

func (c *BaseChannelImpl) SendStream(chatID string, stream <-chan *bus.StreamMessage) error

SendStream 发送流式消息 (默认实现,收集所有chunk后一次性发送)

func (*BaseChannelImpl) Start

func (c *BaseChannelImpl) Start(ctx context.Context) error

Start 启动通道

func (*BaseChannelImpl) Stop

func (c *BaseChannelImpl) Stop() error

Stop 停止通道

func (*BaseChannelImpl) WaitForStop

func (c *BaseChannelImpl) WaitForStop() <-chan struct{}

WaitForStop 等待停止信号

type BindInput added in v0.3.2

type BindInput struct {
	TargetSessionKey string
	TargetKind       string
	Conversation     ThreadBindingConversation
	Placement        string
	Metadata         ThreadBindingMetadata
}

Bind creates a new thread binding.

type C2CMessageEventData

type C2CMessageEventData struct {
	ID        string `json:"id"`
	Content   string `json:"content"`
	Timestamp string `json:"timestamp"`
	Author    struct {
		UserOpenID string `json:"user_openid"`
	} `json:"author"`
}

C2CMessageEventData C2C 消息事件数据

type CapabilityScope added in v0.3.1

type CapabilityScope string

CapabilityScope defines where a capability is available

const (
	CapabilityScopeOff       CapabilityScope = "off"       // disabled
	CapabilityScopeDM        CapabilityScope = "dm"        // direct messages only
	CapabilityScopeGroup     CapabilityScope = "group"     // groups only
	CapabilityScopeAll       CapabilityScope = "all"       // everywhere
	CapabilityScopeAllowlist CapabilityScope = "allowlist" // whitelisted chats only
)

func ParseCapabilityScope added in v0.3.1

func ParseCapabilityScope(s string) CapabilityScope

ParseCapabilityScope parses a capability scope from string

type CapabilityType added in v0.3.1

type CapabilityType string

CapabilityType represents a channel capability

const (
	// CapabilityReactions - add/remove reactions to messages
	CapabilityReactions CapabilityType = "reactions"
	// CapabilityInlineButtons - send messages with inline buttons
	CapabilityInlineButtons CapabilityType = "inline_buttons"
	// CapabilityThreads - create and manage message threads
	CapabilityThreads CapabilityType = "threads"
	// CapabilityPolls - create and manage polls
	CapabilityPolls CapabilityType = "polls"
	// CapabilityStreaming - stream message responses
	CapabilityStreaming CapabilityType = "streaming"
	// CapabilityMedia - send/receive media files
	CapabilityMedia CapabilityType = "media"
	// CapabilityNativeCommands - native slash commands
	CapabilityNativeCommands CapabilityType = "native_commands"
)

type ChannelCapabilities added in v0.3.1

type ChannelCapabilities struct {
	// Reactions support
	Reactions CapabilityScope `mapstructure:"reactions" json:"reactions"`
	// Inline buttons support
	InlineButtons CapabilityScope `mapstructure:"inline_buttons" json:"inline_buttons"`
	// Thread support
	Threads CapabilityScope `mapstructure:"threads" json:"threads"`
	// Poll support
	Polls CapabilityScope `mapstructure:"polls" json:"polls"`
	// Streaming support
	Streaming CapabilityScope `mapstructure:"streaming" json:"streaming"`
	// Media support
	Media CapabilityScope `mapstructure:"media" json:"media"`
	// Native slash commands
	NativeCommands CapabilityScope `mapstructure:"native_commands" json:"native_commands"`
}

ChannelCapabilities defines what features a channel supports

func DefaultCapabilities added in v0.3.1

func DefaultCapabilities() ChannelCapabilities

DefaultCapabilities returns default capabilities for a channel

func GetDefaultCapabilitiesForChannel added in v0.3.1

func GetDefaultCapabilitiesForChannel(channelType string) ChannelCapabilities

GetDefaultCapabilitiesForChannel returns default capabilities for a channel type

func MergeCapabilities added in v0.3.1

func MergeCapabilities(base ChannelCapabilities, overrides []ChannelCapabilities) ChannelCapabilities

MergeCapabilities merges multiple capability configs, later configs override

func ToCapabilities added in v0.3.1

func ToCapabilities(cfg ChannelCapabilityConfig) ChannelCapabilities

ToCapabilities converts config to ChannelCapabilities

type ChannelCapabilityConfig added in v0.3.1

type ChannelCapabilityConfig struct {
	// Reactions support: "off", "dm", "group", "all", "allowlist"
	Reactions string `mapstructure:"reactions" json:"reactions"`
	// Inline buttons support
	InlineButtons string `mapstructure:"inline_buttons" json:"inline_buttons"`
	// Thread support
	Threads string `mapstructure:"threads" json:"threads"`
	// Poll support
	Polls string `mapstructure:"polls" json:"polls"`
	// Streaming support
	Streaming string `mapstructure:"streaming" json:"streaming"`
	// Media support
	Media string `mapstructure:"media" json:"media"`
	// Native commands support
	NativeCommands string `mapstructure:"native_commands" json:"native_commands"`
}

ChannelCapabilityConfig is used in config parsing

type ChatContext added in v0.3.1

type ChatContext struct {
	IsPrivateMessage bool
	IsGroupMessage   bool
	IsWhitelisted    bool
	ChatType         string // "private", "group", "supergroup", etc.
	ChatID           string
}

ChatContext provides context for capability checks

func NewChatContext added in v0.3.1

func NewChatContext(metadata map[string]interface{}) ChatContext

NewChatContext creates a ChatContext from metadata

type DingTalkChannel

type DingTalkChannel struct {
	*BaseChannelImpl
	// contains filtered or unexported fields
}

DingTalkChannel DingTalk 通道实现

func NewDingTalkChannel

func NewDingTalkChannel(cfg config.DingTalkChannelConfig, bus *bus.MessageBus) (*DingTalkChannel, error)

NewDingTalkChannel 创建 DingTalk 通道实例

func (*DingTalkChannel) Send

func (c *DingTalkChannel) Send(msg *bus.OutboundMessage) error

Send 发送消息到 DingTalk

func (*DingTalkChannel) SendDirectReply

func (c *DingTalkChannel) SendDirectReply(sessionWebhook, content string) error

SendDirectReply 使用 session webhook 发送直接回复

func (*DingTalkChannel) SendStream

func (c *DingTalkChannel) SendStream(chatID string, stream <-chan *bus.StreamMessage) error

SendStream 发送流式消息 (DingTalk 不支持,收集后一次性发送)

func (*DingTalkChannel) Start

func (c *DingTalkChannel) Start(ctx context.Context) error

Start 启动 DingTalk 通道 (Stream Mode)

func (*DingTalkChannel) Stop

func (c *DingTalkChannel) Stop() error

Stop 停止 DingTalk 通道

type DiscordChannel

type DiscordChannel struct {
	*BaseChannelImpl
	// contains filtered or unexported fields
}

DiscordChannel Discord 通道

func NewDiscordChannel

func NewDiscordChannel(cfg DiscordConfig, bus *bus.MessageBus) (*DiscordChannel, error)

NewDiscordChannel 创建 Discord 通道

func (*DiscordChannel) AddReaction added in v0.3.1

func (c *DiscordChannel) AddReaction(channelID, messageID, emoji string) error

AddReaction adds a reaction to a message

func (*DiscordChannel) GetReactions added in v0.3.1

func (c *DiscordChannel) GetReactions(channelID, messageID string, limit int) (map[string]*DiscordReactionDetail, error)

GetReactions fetches all reactions for a message with user details

func (*DiscordChannel) RemoveOwnReactions added in v0.3.1

func (c *DiscordChannel) RemoveOwnReactions(channelID, messageID string) ([]string, error)

RemoveAllReactions removes all reactions from a message (only bot's own reactions)

func (*DiscordChannel) RemoveReaction added in v0.3.1

func (c *DiscordChannel) RemoveReaction(channelID, messageID, emoji string) error

RemoveReaction removes a reaction from a message

func (*DiscordChannel) Send

func (c *DiscordChannel) Send(msg *bus.OutboundMessage) error

Send 发送消息

func (*DiscordChannel) SendStream added in v0.3.1

func (c *DiscordChannel) SendStream(chatID string, stream <-chan *bus.StreamMessage) error

SendStream sends streaming messages (edits original message progressively)

func (*DiscordChannel) Start

func (c *DiscordChannel) Start(ctx context.Context) error

Start 启动 Discord 通道

func (*DiscordChannel) Stop

func (c *DiscordChannel) Stop() error

Stop 停止 Discord 通道

type DiscordConfig

type DiscordConfig struct {
	BaseChannelConfig
	Token string `mapstructure:"token" json:"token"`
}

DiscordConfig Discord 配置

type DiscordReaction added in v0.3.1

type DiscordReaction struct {
	EmojiID   string `json:"emoji_id"`
	EmojiName string `json:"emoji_name"`
	Animated  bool   `json:"animated"`
	Count     int    `json:"count"`
}

DiscordReaction represents a Discord reaction

type DiscordReactionDetail added in v0.3.1

type DiscordReactionDetail struct {
	Emoji DiscordReaction
	Users []DiscordReactionUser `json:"users"`
}

DiscordReactionDetail contains reaction details with users

type DiscordReactionUser added in v0.3.1

type DiscordReactionUser struct {
	ID       string `json:"id"`
	Username string `json:"username"`
	Tag      string `json:"tag"`
}

DiscordReactionUser represents a user who reacted

type FeishuChannel

type FeishuChannel struct {
	*BaseChannelImpl
	// contains filtered or unexported fields
}

FeishuChannel 飞书通道 - WebSocket 模式

func NewFeishuChannel

func NewFeishuChannel(cfg config.FeishuChannelConfig, bus *bus.MessageBus) (*FeishuChannel, error)

NewFeishuChannel 创建飞书通道

func (*FeishuChannel) Send

func (c *FeishuChannel) Send(msg *bus.OutboundMessage) error

Send 发送消息

func (*FeishuChannel) Start

func (c *FeishuChannel) Start(ctx context.Context) error

Start 启动飞书通道

func (*FeishuChannel) Stop added in v0.2.1

func (c *FeishuChannel) Stop() error

Stop 停止飞书通道

type GoogleChatChannel

type GoogleChatChannel struct {
	*BaseChannelImpl
	// contains filtered or unexported fields
}

GoogleChatChannel Google Chat 通道

func NewGoogleChatChannel

func NewGoogleChatChannel(cfg GoogleChatConfig, bus *bus.MessageBus) (*GoogleChatChannel, error)

NewGoogleChatChannel 创建 Google Chat 通道

func (*GoogleChatChannel) HandleWebhook

func (c *GoogleChatChannel) HandleWebhook(ctx context.Context, event *chat.DeprecatedEvent) error

HandleWebhook 处理 Google Chat webhook (需要在外部 HTTP 端点调用)

func (*GoogleChatChannel) InitService

func (c *GoogleChatChannel) InitService(ctx context.Context) error

InitService 初始化 Google Chat 服务 (如果需要主动发送)

func (*GoogleChatChannel) Send

Send 发送消息

func (*GoogleChatChannel) SendWithWebhook

func (c *GoogleChatChannel) SendWithWebhook(webhookURL string, msg *bus.OutboundMessage) error

SendWithWebhook 使用 webhook 发送消息 (推荐方式)

func (*GoogleChatChannel) Start

func (c *GoogleChatChannel) Start(ctx context.Context) error

Start 启动 Google Chat 通道

func (*GoogleChatChannel) Stop

func (c *GoogleChatChannel) Stop() error

Stop 停止 Google Chat 通道

type GoogleChatConfig

type GoogleChatConfig struct {
	BaseChannelConfig
	ProjectID   string `mapstructure:"project_id" json:"project_id"`
	Credentials string `mapstructure:"credentials" json:"credentials"` // Service account credentials JSON
}

GoogleChatConfig Google Chat 配置

type GroupATMessageEventData

type GroupATMessageEventData struct {
	ID        string `json:"id"`
	Content   string `json:"content"`
	Timestamp string `json:"timestamp"`
	Author    struct {
		MemberOpenID string `json:"member_openid"`
	} `json:"author"`
	GroupOpenID string `json:"group_openid"`
}

GroupATMessageEventData 群 @消息事件数据

type HelloData

type HelloData struct {
	HeartbeatInterval int `json:"heartbeat_interval"`
}

HelloData Hello 事件数据

type InfoflowChannel

type InfoflowChannel struct {
	*BaseChannelImpl
	// contains filtered or unexported fields
}

InfoflowChannel 百度如流通道

func NewInfoflowChannel

func NewInfoflowChannel(accountID string, cfg InfoflowConfig, bus *bus.MessageBus) (*InfoflowChannel, error)

NewInfoflowChannel 创建如流通道

func (*InfoflowChannel) Send

func (c *InfoflowChannel) Send(msg *bus.OutboundMessage) error

Send 发送消息

func (*InfoflowChannel) SendStream

func (c *InfoflowChannel) SendStream(chatID string, stream <-chan *bus.StreamMessage) error

SendStream 发送流式消息(如流不支持,使用普通发送)

func (*InfoflowChannel) Start

func (c *InfoflowChannel) Start(ctx context.Context) error

Start 启动如流通道

func (*InfoflowChannel) Stop

func (c *InfoflowChannel) Stop() error

Stop 停止通道

type InfoflowConfig

type InfoflowConfig struct {
	BaseChannelConfig
	WebhookURL  string `json:"webhook_url" mapstructure:"webhook_url"`
	Token       string `json:"token" mapstructure:"token"`
	AESKey      string `json:"aes_key" mapstructure:"aes_key"`
	WebhookPort int    `json:"webhook_port" mapstructure:"webhook_port"`
}

InfoflowConfig 如流通道配置

type JSONFileStorage added in v0.3.2

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

JSONFileStorage implements ThreadBindingStorage using JSON files.

func NewJSONFileStorage added in v0.3.2

func NewJSONFileStorage(dataDir string) (*JSONFileStorage, error)

NewJSONFileStorage creates a new JSON file-based storage.

func (*JSONFileStorage) CleanupExpired added in v0.3.2

func (s *JSONFileStorage) CleanupExpired() error

CleanupExpired removes expired bindings from storage.

func (*JSONFileStorage) Delete added in v0.3.2

func (s *JSONFileStorage) Delete(bindingID string) error

Delete removes a binding from storage.

func (*JSONFileStorage) List added in v0.3.2

func (s *JSONFileStorage) List() ([]*ThreadBindingRecord, error)

List returns all bindings from storage.

func (*JSONFileStorage) Load added in v0.3.2

func (s *JSONFileStorage) Load() ([]*ThreadBindingRecord, error)

Load loads all bindings from the JSON file.

func (*JSONFileStorage) Save added in v0.3.2

func (s *JSONFileStorage) Save(record *ThreadBindingRecord) error

Save saves a single binding to the JSON file. This loads all bindings, adds the new one, and saves back.

type Manager

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

Manager 通道管理器

func NewManager

func NewManager(bus *bus.MessageBus) *Manager

NewManager 创建通道管理器

func (*Manager) DispatchOutbound

func (m *Manager) DispatchOutbound(ctx context.Context) error

DispatchOutbound 分发出站消息

func (*Manager) Get

func (m *Manager) Get(name string) (BaseChannel, bool)

Get 获取通道

func (*Manager) IsACPThreadBinding added in v0.3.2

func (m *Manager) IsACPThreadBinding(channel, accountID, conversationID string) bool

IsACPThreadBinding checks if a conversation has an active ACP thread binding.

func (*Manager) List

func (m *Manager) List() []string

List 列出所有通道名称

func (*Manager) Register

func (m *Manager) Register(channel BaseChannel) error

Register 注册通道

func (*Manager) RegisterWithName

func (m *Manager) RegisterWithName(channel BaseChannel, name string) error

RegisterWithName 使用指定名称注册通道

func (*Manager) RouteToAcpSession added in v0.3.2

func (m *Manager) RouteToAcpSession(channel, accountID, conversationID string) string

RouteToAcpSession checks if there's a thread-bound ACP session for this conversation and returns the ACP session key if found.

func (*Manager) SetAcpRouter added in v0.3.2

func (m *Manager) SetAcpRouter(router AcpSessionRouter)

SetAcpRouter sets the ACP session router for thread-bound routing.

func (*Manager) SetThreadBindingService added in v0.3.2

func (m *Manager) SetThreadBindingService(service *ThreadBindingService)

SetThreadBindingService sets the thread binding service.

func (*Manager) SetupFromConfig

func (m *Manager) SetupFromConfig(cfg *config.Config) error

SetupFromConfig 从配置设置通道

func (*Manager) Start

func (m *Manager) Start(ctx context.Context) error

Start 启动所有通道

func (*Manager) Status

func (m *Manager) Status(name string) (map[string]interface{}, error)

Status 获取通道状态

func (*Manager) Stop

func (m *Manager) Stop() error

Stop 停止所有通道

type PreparedAcpThreadBinding added in v0.3.2

type PreparedAcpThreadBinding struct {
	Channel        string
	AccountID      string
	ConversationID string
}

PreparedAcpThreadBinding represents a prepared thread binding for ACP spawn.

type QQChannel

type QQChannel struct {
	*BaseChannelImpl
	// contains filtered or unexported fields
}

QQChannel QQ 官方开放平台 Bot 通道 使用 botgo SDK 实现:https://github.com/tencent-connect/botgo

func NewQQChannel

func NewQQChannel(accountID string, cfg config.QQChannelConfig, bus *bus.MessageBus) (*QQChannel, error)

NewQQChannel 创建 QQ 官方 Bot 通道

func (*QQChannel) GetSession

func (c *QQChannel) GetSession() *dto.WebsocketAP

GetSession 获取当前会话信息(用于调试)

func (*QQChannel) HandleWebhook

func (c *QQChannel) HandleWebhook(ctx context.Context, event []byte) error

HandleWebhook 处理 QQ Webhook 回调(WebSocket 模式下不使用)

func (*QQChannel) Send

func (c *QQChannel) Send(msg *bus.OutboundMessage) error

Send 发送消息

func (*QQChannel) Start

func (c *QQChannel) Start(ctx context.Context) error

Start 启动 QQ 官方 Bot 通道

func (*QQChannel) Stop

func (c *QQChannel) Stop() error

Stop 停止 QQ 官方 Bot 通道

type ReadyData

type ReadyData struct {
	SessionID string `json:"session_id"`
	Version   int    `json:"version"`
	User      struct {
		ID       string `json:"id"`
		Username string `json:"username"`
		Bot      bool   `json:"bot"`
	} `json:"user"`
}

ReadyData Ready 事件数据

type SlackChannel

type SlackChannel struct {
	*BaseChannelImpl
	// contains filtered or unexported fields
}

SlackChannel Slack 通道

func NewSlackChannel

func NewSlackChannel(cfg SlackConfig, bus *bus.MessageBus) (*SlackChannel, error)

NewSlackChannel 创建 Slack 通道

func (*SlackChannel) Send

func (c *SlackChannel) Send(msg *bus.OutboundMessage) error

Send 发送消息

func (*SlackChannel) SendStream added in v0.3.1

func (c *SlackChannel) SendStream(chatID string, stream <-chan *bus.StreamMessage) error

SendStream sends streaming messages (posts initial message for updates)

func (*SlackChannel) Start

func (c *SlackChannel) Start(ctx context.Context) error

Start 启动 Slack 通道

func (*SlackChannel) Stop

func (c *SlackChannel) Stop() error

Stop 停止 Slack 通道

type SlackConfig

type SlackConfig struct {
	BaseChannelConfig
	Token         string `mapstructure:"token" json:"token"`
	SigningSecret string `mapstructure:"signing_secret" json:"signing_secret"`
}

SlackConfig Slack 配置

type TeamsActor

type TeamsActor struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

TeamsActor Teams 参与者

type TeamsAttachment

type TeamsAttachment struct {
	ContentType string                 `json:"contentType"`
	Content     map[string]interface{} `json:"content"`
}

TeamsAttachment Teams 附件

type TeamsChannel

type TeamsChannel struct {
	*BaseChannelImpl
	// contains filtered or unexported fields
}

TeamsChannel Microsoft Teams 通道

func NewTeamsChannel

func NewTeamsChannel(cfg TeamsConfig, bus *bus.MessageBus) (*TeamsChannel, error)

NewTeamsChannel 创建 Teams 通道

func (*TeamsChannel) HandleWebhook

func (c *TeamsChannel) HandleWebhook(ctx context.Context, webhookMsg *TeamsWebhookMessage) error

HandleWebhook 处理 Teams webhook (需要在外部 HTTP 端点调用)

func (*TeamsChannel) Send

func (c *TeamsChannel) Send(msg *bus.OutboundMessage) error

Send 发送消息

func (*TeamsChannel) SendAdaptiveCard

func (c *TeamsChannel) SendAdaptiveCard(msg *bus.OutboundMessage, card map[string]interface{}) error

SendAdaptiveCard 发送自适应卡片 (富格式消息)

func (*TeamsChannel) SendWithWebhook

func (c *TeamsChannel) SendWithWebhook(webhookURL string, msg *bus.OutboundMessage) error

SendWithWebhook 使用 webhook 发送消息 (用于 outgoing webhooks)

func (*TeamsChannel) Start

func (c *TeamsChannel) Start(ctx context.Context) error

Start 启动 Teams 通道

func (*TeamsChannel) Stop

func (c *TeamsChannel) Stop() error

Stop 停止 Teams 通道

type TeamsConfig

type TeamsConfig struct {
	BaseChannelConfig
	AppID       string `mapstructure:"app_id" json:"app_id"`
	AppPassword string `mapstructure:"app_password" json:"app_password"`
	TenantID    string `mapstructure:"tenant_id" json:"tenant_id"`
	WebhookURL  string `mapstructure:"webhook_url" json:"webhook_url"` // For outgoing webhooks
}

TeamsConfig Teams 配置

type TeamsConversation

type TeamsConversation struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

TeamsConversation Teams 会话

type TeamsEntity

type TeamsEntity struct {
	Type string                 `json:"type"`
	Data map[string]interface{} `json:"data,omitempty"`
}

TeamsEntity Teams 实体

type TeamsWebhookMessage

type TeamsWebhookMessage struct {
	Type         string            `json:"type"`
	ID           string            `json:"id"`
	Timestamp    string            `json:"timestamp"`
	ServiceURL   string            `json:"serviceUrl"`
	ChannelID    string            `json:"channelId"`
	From         TeamsActor        `json:"from"`
	Conversation TeamsConversation `json:"conversation"`
	Text         string            `json:"text"`
	Attachments  []TeamsAttachment `json:"attachments"`
	Entities     []TeamsEntity     `json:"entities"`
}

TeamsWebhookMessage Teams webhook 消息

type TelegramChannel

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

TelegramChannel Telegram 通道

func NewTelegramChannel

func NewTelegramChannel(accountID string, cfg TelegramConfig, bus *bus.MessageBus) (*TelegramChannel, error)

NewTelegramChannel 创建 Telegram 通道

func (*TelegramChannel) AnswerCallbackQuery added in v0.3.1

func (c *TelegramChannel) AnswerCallbackQuery(
	callbackQueryID string,
	text string,
	showAlert bool,
) error

AnswerCallbackQuery answers a callback query from an inline button

func (*TelegramChannel) EditMessageReplyMarkup added in v0.3.1

func (c *TelegramChannel) EditMessageReplyMarkup(
	chatID int64,
	messageID int,
	keyboard [][]TelegramInlineButton,
) error

EditMessageReplyMarkup edits the reply markup of a message (to update buttons)

func (*TelegramChannel) IsInlineButtonsEnabled added in v0.3.1

func (c *TelegramChannel) IsInlineButtonsEnabled(chatType string, chatID string) bool

IsInlineButtonsEnabled checks if inline buttons are enabled for the given chat

func (*TelegramChannel) Send

func (c *TelegramChannel) Send(msg *bus.OutboundMessage) error

Send 发送消息

func (*TelegramChannel) SendMessageWithButtons added in v0.3.1

func (c *TelegramChannel) SendMessageWithButtons(
	chatID int64,
	text string,
	keyboard [][]TelegramInlineButton,
	parseMode string,
) error

SendMessageWithButtons sends a message with inline keyboard buttons

func (*TelegramChannel) SendStream added in v0.3.1

func (c *TelegramChannel) SendStream(chatID string, stream <-chan *bus.StreamMessage) error

SendStream sends streaming messages (edits original message progressively)

func (*TelegramChannel) SendTypingIndicator added in v0.3.1

func (c *TelegramChannel) SendTypingIndicator(chatID int64) error

SendTypingIndicator 发送正在输入指示器

func (*TelegramChannel) Start

func (c *TelegramChannel) Start(ctx context.Context) error

Start 启动 Telegram 通道

type TelegramConfig

type TelegramConfig struct {
	BaseChannelConfig
	Token              string `mapstructure:"token" json:"token"`
	InlineButtonsScope string `mapstructure:"inline_buttons_scope" json:"inline_buttons_scope"`
}

TelegramConfig Telegram 配置

type TelegramInlineButton added in v0.3.1

type TelegramInlineButton struct {
	// Text is the button label
	Text string `json:"text"`
	// CallbackData is the data sent when button is clicked (for callback buttons)
	CallbackData string `json:"callback_data,omitempty"`
	// URL is the URL to open (for URL buttons)
	URL string `json:"url,omitempty"`
	// WebAppURL is the URL of a Web App to open (for web app buttons)
	WebAppURL string `json:"web_app_url,omitempty"`
}

TelegramInlineButton represents an inline button

type TelegramInlineButtonsScope added in v0.3.1

type TelegramInlineButtonsScope string

TelegramInlineButtonsScope controls inline button availability

const (
	// TelegramInlineButtonsOff disables inline buttons
	TelegramInlineButtonsOff TelegramInlineButtonsScope = "off"
	// TelegramInlineButtonsDM enables inline buttons only in direct messages
	TelegramInlineButtonsDM TelegramInlineButtonsScope = "dm"
	// TelegramInlineButtonsGroup enables inline buttons only in groups
	TelegramInlineButtonsGroup TelegramInlineButtonsScope = "group"
	// TelegramInlineButtonsAll enables inline buttons everywhere
	TelegramInlineButtonsAll TelegramInlineButtonsScope = "all"
	// TelegramInlineButtonsAllowlist enables inline buttons only for whitelisted chats
	TelegramInlineButtonsAllowlist TelegramInlineButtonsScope = "allowlist"
)

type TelegramInlineKeyboardRow added in v0.3.1

type TelegramInlineKeyboardRow struct {
	Buttons []TelegramInlineButton `json:"buttons"`
}

TelegramInlineKeyboardRow represents a row of inline buttons

type ThreadBindingCapabilities added in v0.3.2

type ThreadBindingCapabilities struct {
	AdapterAvailable bool     // Whether the adapter is available
	BindSupported    bool     // Whether thread binding is supported
	Placements       []string // Supported placement types
}

ThreadBindingCapabilities describes channel's thread binding support.

type ThreadBindingConversation added in v0.3.2

type ThreadBindingConversation struct {
	Channel        string // Channel type (telegram, discord, etc.)
	AccountID      string // Account identifier
	ConversationID string // Thread/conversation identifier
}

ThreadBindingConversation identifies a channel conversation.

type ThreadBindingMetadata added in v0.3.2

type ThreadBindingMetadata struct {
	ThreadName string         // Display name for the thread
	AgentID    string         // Associated agent ID
	Label      string         // Optional label
	BoundBy    string         // Who created the binding ("user" or "system")
	IntroText  string         // Introduction text
	SessionCwd string         // Working directory
	Details    map[string]any // Additional details
}

ThreadBindingMetadata contains additional binding metadata.

type ThreadBindingPolicy added in v0.3.2

type ThreadBindingPolicy struct {
	Channel       string // Channel type
	AccountID     string // Account identifier
	Kind          string // Binding kind ("acp" or "subagent")
	Enabled       bool   // Whether thread bindings are enabled
	SpawnEnabled  bool   // Whether spawning new bindings is allowed
	IdleTimeoutMs int    // Idle timeout in milliseconds
	MaxAgeMs      int    // Maximum age in milliseconds
}

ThreadBindingPolicy represents thread binding policy for a channel.

func ResolveThreadBindingSpawnPolicy added in v0.3.2

func ResolveThreadBindingSpawnPolicy(cfg *config.Config, channel, accountID, kind string) ThreadBindingPolicy

ResolveThreadBindingSpawnPolicy resolves the spawn policy for a channel.

type ThreadBindingRecord added in v0.3.2

type ThreadBindingRecord struct {
	ID               string                    // Unique binding ID
	TargetSessionKey string                    // The ACP session key
	TargetKind       string                    // "session" or "subagent"
	Conversation     ThreadBindingConversation // Channel conversation info
	Placement        string                    // "child" or "peer"
	Metadata         ThreadBindingMetadata     // Binding metadata
	CreatedAt        time.Time                 // Creation time
	ExpiresAt        *time.Time                // Optional expiration
}

ThreadBindingRecord represents a thread binding between a channel thread and an ACP session.

type ThreadBindingService added in v0.3.2

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

ThreadBindingService manages thread bindings.

func NewThreadBindingService added in v0.3.2

func NewThreadBindingService(cfg *config.Config, sessions *session.Manager) *ThreadBindingService

NewThreadBindingService creates a new thread binding service.

func (*ThreadBindingService) Bind added in v0.3.2

func (*ThreadBindingService) CleanupExpired added in v0.3.2

func (s *ThreadBindingService) CleanupExpired() int

CleanupExpired removes expired bindings.

func (*ThreadBindingService) Get added in v0.3.2

func (s *ThreadBindingService) Get(bindingID string) *ThreadBindingRecord

Get retrieves a binding by ID.

func (*ThreadBindingService) GetByConversation added in v0.3.2

func (s *ThreadBindingService) GetByConversation(channel, accountID, conversationID string) *ThreadBindingRecord

GetByConversation retrieves a binding by conversation.

func (*ThreadBindingService) GetBySession added in v0.3.2

func (s *ThreadBindingService) GetBySession(sessionKey string) []*ThreadBindingRecord

GetBySession retrieves all bindings for a session.

func (*ThreadBindingService) GetCapabilities added in v0.3.2

func (s *ThreadBindingService) GetCapabilities(channel, accountID string) ThreadBindingCapabilities

GetCapabilities returns the thread binding capabilities for a channel/account.

func (*ThreadBindingService) ResolvePolicy added in v0.3.2

func (s *ThreadBindingService) ResolvePolicy(channel, accountID, kind string) ThreadBindingPolicy

ResolvePolicy resolves the thread binding policy for a channel/account/kind.

func (*ThreadBindingService) Unbind added in v0.3.2

func (s *ThreadBindingService) Unbind(bindingID string) error

Unbind removes a thread binding.

type ThreadBindingStorage added in v0.3.2

type ThreadBindingStorage interface {
	// Load loads all bindings from storage.
	Load() ([]*ThreadBindingRecord, error)
	// Save saves a binding to storage.
	Save(record *ThreadBindingRecord) error
	// Delete removes a binding from storage.
	Delete(bindingID string) error
	// List returns all bindings.
	List() ([]*ThreadBindingRecord, error)
}

ThreadBindingStorage defines the interface for persistent thread binding storage.

type WSPayload

type WSPayload struct {
	Op int             `json:"op"`
	D  json.RawMessage `json:"d"`
	S  uint32          `json:"s"`
	T  string          `json:"t"`
}

WSPayload WebSocket 消息负载

type WeWorkChannel

type WeWorkChannel struct {
	*BaseChannelImpl
	// contains filtered or unexported fields
}

WeWorkChannel 企业微信通道

func NewWeWorkChannel

func NewWeWorkChannel(cfg config.WeWorkChannelConfig, bus *bus.MessageBus) (*WeWorkChannel, error)

NewWeWorkChannel 创建企业微信通道

func (*WeWorkChannel) Send

func (c *WeWorkChannel) Send(msg *bus.OutboundMessage) error

Send 发送消息

func (*WeWorkChannel) Start

func (c *WeWorkChannel) Start(ctx context.Context) error

Start 启动企业微信通道

type WhatsAppChannel

type WhatsAppChannel struct {
	*BaseChannelImpl
	// contains filtered or unexported fields
}

WhatsAppChannel WhatsApp 通道

func NewWhatsAppChannel

func NewWhatsAppChannel(cfg WhatsAppConfig, bus *bus.MessageBus) (*WhatsAppChannel, error)

NewWhatsAppChannel 创建 WhatsApp 通道

func (*WhatsAppChannel) Send

func (c *WhatsAppChannel) Send(msg *bus.OutboundMessage) error

Send 发送消息

func (*WhatsAppChannel) Start

func (c *WhatsAppChannel) Start(ctx context.Context) error

Start 启动 WhatsApp 通道

type WhatsAppConfig

type WhatsAppConfig struct {
	BaseChannelConfig
	BridgeURL string `mapstructure:"bridge_url" json:"bridge_url"`
}

WhatsAppConfig WhatsApp 配置

type WhatsAppMessage

type WhatsAppMessage struct {
	ID        string `json:"id"`
	From      string `json:"from"`
	ChatID    string `json:"chat_id"`
	Text      string `json:"text"`
	Type      string `json:"type"`
	Timestamp int64  `json:"timestamp"`
}

WhatsAppMessage WhatsApp 消息

Jump to

Keyboard shortcuts

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