feat(channels): add WebSocket channel for local web-based chat
This commit is contained in:
parent
5cc3aca898
commit
ae24334459
4 changed files with 81 additions and 12 deletions
|
|
@ -98,5 +98,47 @@ func statusCmd() {
|
||||||
fmt.Printf(" %s (%s): %s\n", provider, cred.AuthMethod, status)
|
fmt.Printf(" %s (%s): %s\n", provider, cred.AuthMethod, status)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Display enabled channels
|
||||||
|
fmt.Println("\nChannels:")
|
||||||
|
if cfg.Channels.WebSocket.Enabled {
|
||||||
|
fmt.Printf(" WebSocket: ✓ http://%s:%d\n", cfg.Channels.WebSocket.Host, cfg.Channels.WebSocket.Port)
|
||||||
|
}
|
||||||
|
if cfg.Channels.Telegram.Enabled {
|
||||||
|
fmt.Println(" Telegram: ✓")
|
||||||
|
}
|
||||||
|
if cfg.Channels.Discord.Enabled {
|
||||||
|
fmt.Println(" Discord: ✓")
|
||||||
|
}
|
||||||
|
if cfg.Channels.Slack.Enabled {
|
||||||
|
fmt.Println(" Slack: ✓")
|
||||||
|
}
|
||||||
|
if cfg.Channels.QQ.Enabled {
|
||||||
|
fmt.Println(" QQ: ✓")
|
||||||
|
}
|
||||||
|
if cfg.Channels.Feishu.Enabled {
|
||||||
|
fmt.Println(" Feishu: ✓")
|
||||||
|
}
|
||||||
|
if cfg.Channels.DingTalk.Enabled {
|
||||||
|
fmt.Println(" DingTalk: ✓")
|
||||||
|
}
|
||||||
|
if cfg.Channels.LINE.Enabled {
|
||||||
|
fmt.Println(" LINE: ✓")
|
||||||
|
}
|
||||||
|
if cfg.Channels.WeCom.Enabled {
|
||||||
|
fmt.Println(" WeCom: ✓")
|
||||||
|
}
|
||||||
|
if cfg.Channels.WeComApp.Enabled {
|
||||||
|
fmt.Println(" WeCom App: ✓")
|
||||||
|
}
|
||||||
|
if cfg.Channels.WhatsApp.Enabled {
|
||||||
|
fmt.Println(" WhatsApp: ✓")
|
||||||
|
}
|
||||||
|
if cfg.Channels.OneBot.Enabled {
|
||||||
|
fmt.Println(" OneBot: ✓")
|
||||||
|
}
|
||||||
|
if cfg.Channels.MaixCam.Enabled {
|
||||||
|
fmt.Println(" MaixCam: ✓")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -202,6 +202,19 @@ func (m *Manager) initChannels() error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if m.config.Channels.WebSocket.Enabled {
|
||||||
|
logger.DebugC("channels", "Attempting to initialize WebSocket channel")
|
||||||
|
websocket, err := NewWebSocketChannel(m.config.Channels.WebSocket, m.bus)
|
||||||
|
if err != nil {
|
||||||
|
logger.ErrorCF("channels", "Failed to initialize WebSocket channel", map[string]any{
|
||||||
|
"error": err.Error(),
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
m.channels["websocket"] = websocket
|
||||||
|
logger.InfoC("channels", "WebSocket channel enabled successfully")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
logger.InfoCF("channels", "Channel initialization completed", map[string]any{
|
logger.InfoCF("channels", "Channel initialization completed", map[string]any{
|
||||||
"enabled_channels": len(m.channels),
|
"enabled_channels": len(m.channels),
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -192,6 +192,7 @@ type ChannelsConfig struct {
|
||||||
OneBot OneBotConfig `json:"onebot"`
|
OneBot OneBotConfig `json:"onebot"`
|
||||||
WeCom WeComConfig `json:"wecom"`
|
WeCom WeComConfig `json:"wecom"`
|
||||||
WeComApp WeComAppConfig `json:"wecom_app"`
|
WeComApp WeComAppConfig `json:"wecom_app"`
|
||||||
|
WebSocket WebSocketConfig `json:"websocket"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type WhatsAppConfig struct {
|
type WhatsAppConfig struct {
|
||||||
|
|
@ -296,6 +297,13 @@ type WeComAppConfig struct {
|
||||||
ReplyTimeout int `json:"reply_timeout" env:"PICOCLAW_CHANNELS_WECOM_APP_REPLY_TIMEOUT"`
|
ReplyTimeout int `json:"reply_timeout" env:"PICOCLAW_CHANNELS_WECOM_APP_REPLY_TIMEOUT"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type WebSocketConfig struct {
|
||||||
|
Enabled bool `json:"enabled" env:"PICOCLAW_CHANNELS_WEBSOCKET_ENABLED"`
|
||||||
|
Host string `json:"host" env:"PICOCLAW_CHANNELS_WEBSOCKET_HOST"`
|
||||||
|
Port int `json:"port" env:"PICOCLAW_CHANNELS_WEBSOCKET_PORT"`
|
||||||
|
AllowFrom FlexibleStringSlice `json:"allow_from" env:"PICOCLAW_CHANNELS_WEBSOCKET_ALLOW_FROM"`
|
||||||
|
}
|
||||||
|
|
||||||
type HeartbeatConfig struct {
|
type HeartbeatConfig struct {
|
||||||
Enabled bool `json:"enabled" env:"PICOCLAW_HEARTBEAT_ENABLED"`
|
Enabled bool `json:"enabled" env:"PICOCLAW_HEARTBEAT_ENABLED"`
|
||||||
Interval int `json:"interval" env:"PICOCLAW_HEARTBEAT_INTERVAL"` // minutes, min 5
|
Interval int `json:"interval" env:"PICOCLAW_HEARTBEAT_INTERVAL"` // minutes, min 5
|
||||||
|
|
|
||||||
|
|
@ -113,6 +113,12 @@ func DefaultConfig() *Config {
|
||||||
AllowFrom: FlexibleStringSlice{},
|
AllowFrom: FlexibleStringSlice{},
|
||||||
ReplyTimeout: 5,
|
ReplyTimeout: 5,
|
||||||
},
|
},
|
||||||
|
WebSocket: WebSocketConfig{
|
||||||
|
Enabled: false,
|
||||||
|
Host: "0.0.0.0",
|
||||||
|
Port: 8080,
|
||||||
|
AllowFrom: FlexibleStringSlice{},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Providers: ProvidersConfig{
|
Providers: ProvidersConfig{
|
||||||
OpenAI: OpenAIProviderConfig{WebSearch: true},
|
OpenAI: OpenAIProviderConfig{WebSearch: true},
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue