Documentation
¶
Index ¶
- func CheckCapability(capabilities ChannelCapabilities, capability CapabilityType, ctx ChatContext) bool
- func FormatThreadBindingDisabledError(channel, accountID, kind string) string
- func FormatThreadBindingSpawnDisabledError(channel, accountID, kind string) string
- func IsCapabilityEnabled(capabilities ChannelCapabilities, capability CapabilityType, ...) bool
- func ResolveThreadBindingIdleTimeoutMsForChannel(cfg *config.Config, channel, accountID string) int
- func ResolveThreadBindingIntroText(agentID, label string, idleTimeoutMs, maxAgeMs int, sessionCwd string, ...) string
- func ResolveThreadBindingMaxAgeMsForChannel(cfg *config.Config, channel, accountID string) int
- func ResolveThreadBindingThreadName(agentID, label string) string
- type ATMessageEventData
- type AcpSessionRouter
- type BaseChannel
- type BaseChannelConfig
- type BaseChannelImpl
- func (c *BaseChannelImpl) AccountID() string
- func (c *BaseChannelImpl) IsAllowed(senderID string) bool
- func (c *BaseChannelImpl) IsRunning() bool
- func (c *BaseChannelImpl) Name() string
- func (c *BaseChannelImpl) PublishInbound(ctx context.Context, msg *bus.InboundMessage) error
- func (c *BaseChannelImpl) SendStream(chatID string, stream <-chan *bus.StreamMessage) error
- func (c *BaseChannelImpl) Start(ctx context.Context) error
- func (c *BaseChannelImpl) Stop() error
- func (c *BaseChannelImpl) WaitForStop() <-chan struct{}
- type BindInput
- type C2CMessageEventData
- type CapabilityScope
- type CapabilityType
- type ChannelCapabilities
- type ChannelCapabilityConfig
- type ChatContext
- type DingTalkChannel
- func (c *DingTalkChannel) Send(msg *bus.OutboundMessage) error
- func (c *DingTalkChannel) SendDirectReply(sessionWebhook, content string) error
- func (c *DingTalkChannel) SendStream(chatID string, stream <-chan *bus.StreamMessage) error
- func (c *DingTalkChannel) Start(ctx context.Context) error
- func (c *DingTalkChannel) Stop() error
- type DiscordChannel
- func (c *DiscordChannel) AddReaction(channelID, messageID, emoji string) error
- func (c *DiscordChannel) GetReactions(channelID, messageID string, limit int) (map[string]*DiscordReactionDetail, error)
- func (c *DiscordChannel) RemoveOwnReactions(channelID, messageID string) ([]string, error)
- func (c *DiscordChannel) RemoveReaction(channelID, messageID, emoji string) error
- func (c *DiscordChannel) Send(msg *bus.OutboundMessage) error
- func (c *DiscordChannel) SendStream(chatID string, stream <-chan *bus.StreamMessage) error
- func (c *DiscordChannel) Start(ctx context.Context) error
- func (c *DiscordChannel) Stop() error
- type DiscordConfig
- type DiscordReaction
- type DiscordReactionDetail
- type DiscordReactionUser
- type FeishuChannel
- type GoogleChatChannel
- func (c *GoogleChatChannel) HandleWebhook(ctx context.Context, event *chat.DeprecatedEvent) error
- func (c *GoogleChatChannel) InitService(ctx context.Context) error
- func (c *GoogleChatChannel) Send(msg *bus.OutboundMessage) error
- func (c *GoogleChatChannel) SendWithWebhook(webhookURL string, msg *bus.OutboundMessage) error
- func (c *GoogleChatChannel) Start(ctx context.Context) error
- func (c *GoogleChatChannel) Stop() error
- type GoogleChatConfig
- type GroupATMessageEventData
- type HelloData
- type InfoflowChannel
- type InfoflowConfig
- type JSONFileStorage
- func (s *JSONFileStorage) CleanupExpired() error
- func (s *JSONFileStorage) Delete(bindingID string) error
- func (s *JSONFileStorage) List() ([]*ThreadBindingRecord, error)
- func (s *JSONFileStorage) Load() ([]*ThreadBindingRecord, error)
- func (s *JSONFileStorage) Save(record *ThreadBindingRecord) error
- type Manager
- func (m *Manager) DispatchOutbound(ctx context.Context) error
- func (m *Manager) Get(name string) (BaseChannel, bool)
- func (m *Manager) IsACPThreadBinding(channel, accountID, conversationID string) bool
- func (m *Manager) List() []string
- func (m *Manager) Register(channel BaseChannel) error
- func (m *Manager) RegisterWithName(channel BaseChannel, name string) error
- func (m *Manager) RouteToAcpSession(channel, accountID, conversationID string) string
- func (m *Manager) SetAcpRouter(router AcpSessionRouter)
- func (m *Manager) SetThreadBindingService(service *ThreadBindingService)
- func (m *Manager) SetupFromConfig(cfg *config.Config) error
- func (m *Manager) Start(ctx context.Context) error
- func (m *Manager) Status(name string) (map[string]interface{}, error)
- func (m *Manager) Stop() error
- type PreparedAcpThreadBinding
- type QQChannel
- type ReadyData
- type SlackChannel
- type SlackConfig
- type TeamsActor
- type TeamsAttachment
- type TeamsChannel
- func (c *TeamsChannel) HandleWebhook(ctx context.Context, webhookMsg *TeamsWebhookMessage) error
- func (c *TeamsChannel) Send(msg *bus.OutboundMessage) error
- func (c *TeamsChannel) SendAdaptiveCard(msg *bus.OutboundMessage, card map[string]interface{}) error
- func (c *TeamsChannel) SendWithWebhook(webhookURL string, msg *bus.OutboundMessage) error
- func (c *TeamsChannel) Start(ctx context.Context) error
- func (c *TeamsChannel) Stop() error
- type TeamsConfig
- type TeamsConversation
- type TeamsEntity
- type TeamsWebhookMessage
- type TelegramChannel
- func (c *TelegramChannel) AnswerCallbackQuery(callbackQueryID string, text string, showAlert bool) error
- func (c *TelegramChannel) EditMessageReplyMarkup(chatID int64, messageID int, keyboard [][]TelegramInlineButton) error
- func (c *TelegramChannel) IsInlineButtonsEnabled(chatType string, chatID string) bool
- func (c *TelegramChannel) Send(msg *bus.OutboundMessage) error
- func (c *TelegramChannel) SendMessageWithButtons(chatID int64, text string, keyboard [][]TelegramInlineButton, parseMode string) error
- func (c *TelegramChannel) SendStream(chatID string, stream <-chan *bus.StreamMessage) error
- func (c *TelegramChannel) SendTypingIndicator(chatID int64) error
- func (c *TelegramChannel) Start(ctx context.Context) error
- type TelegramConfig
- type TelegramInlineButton
- type TelegramInlineButtonsScope
- type TelegramInlineKeyboardRow
- type ThreadBindingCapabilities
- type ThreadBindingConversation
- type ThreadBindingMetadata
- type ThreadBindingPolicy
- type ThreadBindingRecord
- type ThreadBindingService
- func (s *ThreadBindingService) Bind(input BindInput) (*ThreadBindingRecord, error)
- func (s *ThreadBindingService) CleanupExpired() int
- func (s *ThreadBindingService) Get(bindingID string) *ThreadBindingRecord
- func (s *ThreadBindingService) GetByConversation(channel, accountID, conversationID string) *ThreadBindingRecord
- func (s *ThreadBindingService) GetBySession(sessionKey string) []*ThreadBindingRecord
- func (s *ThreadBindingService) GetCapabilities(channel, accountID string) ThreadBindingCapabilities
- func (s *ThreadBindingService) ResolvePolicy(channel, accountID, kind string) ThreadBindingPolicy
- func (s *ThreadBindingService) Unbind(bindingID string) error
- type ThreadBindingStorage
- type WSPayload
- type WeWorkChannel
- type WhatsAppChannel
- type WhatsAppConfig
- type WhatsAppMessage
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
FormatThreadBindingDisabledError formats an error message for disabled thread bindings.
func FormatThreadBindingSpawnDisabledError ¶ added in v0.3.2
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
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
ResolveThreadBindingMaxAgeMsForChannel returns the max age for a channel.
func ResolveThreadBindingThreadName ¶ added in v0.3.2
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) IsAllowed ¶
func (c *BaseChannelImpl) IsAllowed(senderID string) bool
IsAllowed 检查发送者是否允许
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) 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 不支持,收集后一次性发送)
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)
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 创建飞书通道
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 ¶
func (c *GoogleChatChannel) Send(msg *bus.OutboundMessage) error
Send 发送消息
func (*GoogleChatChannel) SendWithWebhook ¶
func (c *GoogleChatChannel) SendWithWebhook(webhookURL string, msg *bus.OutboundMessage) error
SendWithWebhook 使用 webhook 发送消息 (推荐方式)
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 发送流式消息(如流不支持,使用普通发送)
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 (*Manager) DispatchOutbound ¶
DispatchOutbound 分发出站消息
func (*Manager) IsACPThreadBinding ¶ added in v0.3.2
IsACPThreadBinding checks if a conversation has an active ACP thread binding.
func (*Manager) RegisterWithName ¶
func (m *Manager) RegisterWithName(channel BaseChannel, name string) error
RegisterWithName 使用指定名称注册通道
func (*Manager) RouteToAcpSession ¶ added in v0.3.2
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 ¶
SetupFromConfig 从配置设置通道
type PreparedAcpThreadBinding ¶ added in v0.3.2
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 ¶
HandleWebhook 处理 QQ Webhook 回调(WebSocket 模式下不使用)
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) 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)
type SlackConfig ¶
type SlackConfig struct {
BaseChannelConfig
Token string `mapstructure:"token" json:"token"`
SigningSecret string `mapstructure:"signing_secret" json:"signing_secret"`
}
SlackConfig Slack 配置
type TeamsActor ¶
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) 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)
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 ¶
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 发送正在输入指示器
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 (s *ThreadBindingService) Bind(input BindInput) (*ThreadBindingRecord, error)
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 创建企业微信通道
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 发送消息
type WhatsAppConfig ¶
type WhatsAppConfig struct {
BaseChannelConfig
BridgeURL string `mapstructure:"bridge_url" json:"bridge_url"`
}
WhatsAppConfig WhatsApp 配置