Documentation
¶
Index ¶
- func RegisterRoutes(router *swagger.RouteGroup, handler *Handler)
- type BotManager
- func (bm *BotManager) GetStatus() []BotStatus
- func (bm *BotManager) GetStore() *db.ImBotSettingsStore
- func (bm *BotManager) GetTBClient() tbclient.TBClient
- func (bm *BotManager) IsRunning(uuid string) bool
- func (bm *BotManager) Shutdown()
- func (bm *BotManager) StartAllEnabled(ctx context.Context) error
- func (bm *BotManager) StartBot(ctx context.Context, uuid string) error
- func (bm *BotManager) StopAll()
- func (bm *BotManager) StopBot(uuid string) error
- func (bm *BotManager) Sync(ctx context.Context) error
- type BotStatus
- type CreateRequest
- type DeleteResponse
- type Handler
- func (h *Handler) BotManager() *BotManager
- func (h *Handler) CreateSettings(c *gin.Context)
- func (h *Handler) DeleteSettings(c *gin.Context)
- func (h *Handler) GetPlatformConfig(c *gin.Context)
- func (h *Handler) GetPlatforms(c *gin.Context)
- func (h *Handler) GetSettings(c *gin.Context)
- func (h *Handler) ListSettings(c *gin.Context)
- func (h *Handler) Shutdown()
- func (h *Handler) StartAllEnabled(ctx context.Context) error
- func (h *Handler) StopAll()
- func (h *Handler) Sync(ctx context.Context) error
- func (h *Handler) ToggleSettings(c *gin.Context)
- func (h *Handler) UpdateSettings(c *gin.Context)
- type ListResponse
- type PlatformConfig
- type PlatformConfigResponse
- type PlatformsResponse
- type SettingsResponse
- type ToggleResponse
- type UpdateRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterRoutes ¶
func RegisterRoutes(router *swagger.RouteGroup, handler *Handler)
RegisterRoutes registers all ImBot settings routes with swagger documentation
Types ¶
type BotManager ¶
type BotManager struct {
// contains filtered or unexported fields
}
BotManager manages the lifecycle of ImBot instances. It encapsulates the internal bot.Manager and provides a clean interface for the imbotsettings module to control bot lifecycle.
func NewBotManager ¶
func NewBotManager(cfg *config.Config) (*BotManager, error)
NewBotManager creates a new BotManager with all required dependencies.
func (*BotManager) GetStatus ¶
func (bm *BotManager) GetStatus() []BotStatus
GetStatus returns the status of all configured bots.
func (*BotManager) GetStore ¶
func (bm *BotManager) GetStore() *db.ImBotSettingsStore
GetStore returns the underlying settings store.
func (*BotManager) GetTBClient ¶
func (bm *BotManager) GetTBClient() tbclient.TBClient
GetTBClient returns the TBClient for SmartGuide model configuration.
func (*BotManager) IsRunning ¶
func (bm *BotManager) IsRunning(uuid string) bool
IsRunning checks if a bot is currently running.
func (*BotManager) Shutdown ¶
func (bm *BotManager) Shutdown()
Shutdown stops all running bots and cleans up resources.
func (*BotManager) StartAllEnabled ¶
func (bm *BotManager) StartAllEnabled(ctx context.Context) error
StartAllEnabled starts all bots that have enabled: true in their settings. Logs errors for individual bots but continues starting others.
func (*BotManager) StartBot ¶
func (bm *BotManager) StartBot(ctx context.Context, uuid string) error
StartBot starts a single bot by UUID. If the bot is already running, this is a no-op.
func (*BotManager) StopBot ¶
func (bm *BotManager) StopBot(uuid string) error
StopBot stops a single bot by UUID. If the bot is not running, this is a no-op. Waits up to 5 seconds for the bot to fully stop before returning.
type BotStatus ¶
type BotStatus struct {
UUID string `json:"uuid"`
Name string `json:"name"`
Platform string `json:"platform"`
Running bool `json:"running"`
Error string `json:"error,omitempty"`
}
BotStatus represents the runtime status of a bot.
type CreateRequest ¶
type CreateRequest struct {
UUID string `json:"uuid,omitempty"`
Name string `json:"name,omitempty"`
Platform string `json:"platform"`
AuthType string `json:"auth_type"`
Auth map[string]string `json:"auth"`
ProxyURL string `json:"proxy_url,omitempty"`
ChatID string `json:"chat_id,omitempty"`
BashAllowlist []string `json:"bash_allowlist,omitempty"`
DefaultCwd string `json:"default_cwd,omitempty"` // Default working directory
DefaultAgent string `json:"default_agent,omitempty"` // Default Agent UUID
Enabled bool `json:"enabled"`
Token string `json:"token,omitempty"` // Legacy field
SmartGuideProvider string `json:"smartguide_provider,omitempty"` // Provider UUID
SmartGuideModel string `json:"smartguide_model,omitempty"` // Model identifier
}
CreateRequest represents the request to create ImBot settings
type DeleteResponse ¶
DeleteResponse represents the response for delete operations
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler handles ImBot settings HTTP requests
func NewHandler ¶
NewHandler creates a new ImBot settings handler
func (*Handler) BotManager ¶
func (h *Handler) BotManager() *BotManager
BotManager returns the bot manager for server integration
func (*Handler) CreateSettings ¶
CreateSettings creates a new ImBot configuration
func (*Handler) DeleteSettings ¶
DeleteSettings deletes an ImBot configuration
func (*Handler) GetPlatformConfig ¶
GetPlatformConfig returns auth configuration for a specific platform
func (*Handler) GetPlatforms ¶
GetPlatforms returns all supported ImBot platforms with their configurations
func (*Handler) GetSettings ¶
GetSettings returns a single ImBot configuration by UUID
func (*Handler) ListSettings ¶
ListSettings returns all ImBot configurations
func (*Handler) Shutdown ¶
func (h *Handler) Shutdown()
Shutdown stops all running bots and cleans up resources
func (*Handler) StartAllEnabled ¶
StartAllEnabled starts all enabled bots (delegates to BotManager)
func (*Handler) StopAll ¶
func (h *Handler) StopAll()
StopAll stops all running bots (delegates to BotManager)
func (*Handler) ToggleSettings ¶
ToggleSettings toggles the enabled status of an ImBot configuration
func (*Handler) UpdateSettings ¶
UpdateSettings updates an existing ImBot configuration
type ListResponse ¶
ListResponse represents the response for listing ImBot settings
type PlatformConfig ¶
type PlatformConfig struct {
Platform string `json:"platform"`
DisplayName string `json:"display_name"`
AuthType string `json:"auth_type"`
Category string `json:"category"`
Fields []imbot.FieldSpec `json:"fields"`
}
PlatformConfig represents a platform configuration
type PlatformConfigResponse ¶
type PlatformConfigResponse struct {
Success bool `json:"success"`
Platform PlatformConfig `json:"platform"`
}
PlatformConfigResponse represents the response for platform config
type PlatformsResponse ¶
type PlatformsResponse struct {
Success bool `json:"success"`
Platforms []PlatformConfig `json:"platforms"`
Categories gin.H `json:"categories"`
}
PlatformsResponse represents the response for listing platforms
type SettingsResponse ¶
type SettingsResponse struct {
Success bool `json:"success"`
Settings db.Settings `json:"settings"`
}
SettingsResponse represents the response for a single ImBot settings
type ToggleResponse ¶
ToggleResponse represents the response for toggling ImBot settings
type UpdateRequest ¶
type UpdateRequest struct {
Name string `json:"name,omitempty"`
Platform string `json:"platform,omitempty"`
AuthType string `json:"auth_type,omitempty"`
Auth map[string]string `json:"auth,omitempty"`
ProxyURL string `json:"proxy_url,omitempty"`
ChatID string `json:"chat_id,omitempty"`
BashAllowlist []string `json:"bash_allowlist,omitempty"`
DefaultCwd *string `json:"default_cwd,omitempty"` // Pointer for partial update
DefaultAgent *string `json:"default_agent,omitempty"` // Pointer for partial update
Enabled *bool `json:"enabled,omitempty"` // Pointer to allow partial update
Token string `json:"token,omitempty"` // Legacy field
SmartGuideProvider *string `json:"smartguide_provider,omitempty"` // Provider UUID
SmartGuideModel *string `json:"smartguide_model,omitempty"` // Model identifier
}
UpdateRequest represents the request to update ImBot settings