Documentation
¶
Index ¶
- Variables
- func UsageRestrictionsForUserConfig(client *pluginapi.Client, cfg llm.BotConfig, requestingUserID string) error
- type AgentStore
- type Bot
- func (b *Bot) BotUserID() string
- func (b *Bot) GetConfig() llm.BotConfig
- func (b *Bot) GetMMBot() *model.Bot
- func (b *Bot) GetService() llm.ServiceConfig
- func (b *Bot) HasNativeCodeExecutionEnabled() bool
- func (b *Bot) HasNativeWebSearchEnabled() bool
- func (b *Bot) LLM() llm.LanguageModel
- func (b *Bot) ProviderServices() *llm.ProviderServices
- func (b *Bot) SandboxFileAttachmentAvailable() bool
- func (b *Bot) SetLLMForTest(llm llm.LanguageModel)
- func (b *Bot) SetProviderServicesForTest(services *llm.ProviderServices)
- func (b *Bot) SetServiceForTest(service llm.ServiceConfig)
- func (b *Bot) WithConfig(cfg llm.BotConfig) *Bot
- type Config
- type MMBots
- func (m *MMBots) CheckUsageRestrictions(requestingUserID string, bot *Bot, channel *model.Channel) error
- func (m *MMBots) CheckUsageRestrictionsForChannel(bot *Bot, channel *model.Channel) error
- func (m *MMBots) CheckUsageRestrictionsForUser(bot *Bot, requestingUserID string) error
- func (m *MMBots) CheckUsageRestrictionsForUserConfig(cfg llm.BotConfig, requestingUserID string) error
- func (b *MMBots) EnsureBots() error
- func (b *MMBots) ForceRefreshOnNextEnsure()
- func (b *MMBots) GetAllBotUserIDs() []string
- func (b *MMBots) GetAllBots() []*Bot
- func (b *MMBots) GetBotByID(botID string) *Bot
- func (b *MMBots) GetBotByUsername(botUsername string) *Bot
- func (b *MMBots) GetBotByUsernameOrFirst(botUsername string) *Bot
- func (b *MMBots) GetBotConfig(botUsername string) (llm.BotConfig, error)
- func (b *MMBots) GetBotConfigByID(botID string) (bool, int64, bool)
- func (b *MMBots) GetBotForDMChannel(channel *model.Channel) *Bot
- func (b *MMBots) GetBotMentioned(text string) *Bot
- func (b *MMBots) GetTranscribe() Transcriber
- func (b *MMBots) IsAnyBot(userID string) bool
- func (b *MMBots) SetBotsForTesting(bots []*Bot)
- type Transcriber
Constants ¶
This section is empty.
Variables ¶
var ErrUsageRestriction = errors.New("usage restriction")
Functions ¶
func UsageRestrictionsForUserConfig ¶
func UsageRestrictionsForUserConfig(client *pluginapi.Client, cfg llm.BotConfig, requestingUserID string) error
UsageRestrictionsForUserConfig returns nil if userID is allowed by cfg's UserAccessLevel / UserIDs / TeamIDs, otherwise an error wrapping ErrUsageRestriction. Callers without an MMBots instance (e.g. API code when bots may be nil) should use this with the plugin client; MMBots.CheckUsageRestrictionsForUserConfig delegates here.
Types ¶
type AgentStore ¶
AgentStore provides read access to user-created agents from the database. This is a subset of the full store.AgentStore — only read methods needed here.
type Bot ¶
type Bot struct {
// contains filtered or unexported fields
}
Bot represents an AI bot instance with its configuration and dependencies.
Source of truth for bot fields:
- cfg: The bot's configuration (name, display name, permissions, etc.)
- service: The RESOLVED service configuration (use GetService() to access). DO NOT use cfg.Service or cfg.ServiceID directly - those are internal references.
- mmBot: The Mattermost bot user
- llm: The initialized language model instance
- providerServices: resolved from the concrete client before wrapping (see llm.ProviderServices)
Bot instances should be created via EnsureBots() which properly resolves service references and initializes all fields.
func NewBot ¶
func NewBot(cfg llm.BotConfig, service llm.ServiceConfig, mmBot *model.Bot, llmInstance llm.LanguageModel) *Bot
NewBot has no provider services. Use EnsureBots for a wired bot, or WithConfig to derive one.
func (*Bot) BotUserID ¶ added in v2.7.0
BotUserID returns the Mattermost user ID of the bot's user account, or "" when no bot user exists.
func (*Bot) GetService ¶
func (b *Bot) GetService() llm.ServiceConfig
func (*Bot) HasNativeCodeExecutionEnabled ¶ added in v2.7.0
HasNativeCodeExecutionEnabled is independent of file retrieval. OpenAI can run the sandbox but cannot serve its files; use SandboxFileAttachmentAvailable for attach/prompt gating.
func (*Bot) HasNativeWebSearchEnabled ¶
HasNativeWebSearchEnabled is used to suppress Mattermost's built-in web search fallback.
func (*Bot) LLM ¶
func (b *Bot) LLM() llm.LanguageModel
func (*Bot) ProviderServices ¶ added in v2.7.0
func (b *Bot) ProviderServices() *llm.ProviderServices
ProviderServices is nil-safe; callers must tolerate nil (bots built outside EnsureBots).
func (*Bot) SandboxFileAttachmentAvailable ¶ added in v2.7.0
SandboxFileAttachmentAvailable requires both the sandbox and a retrievable file API. Prompt text and the attach path must use this so they cannot disagree.
func (*Bot) SetLLMForTest ¶
func (b *Bot) SetLLMForTest(llm llm.LanguageModel)
func (*Bot) SetProviderServicesForTest ¶ added in v2.7.0
func (b *Bot) SetProviderServicesForTest(services *llm.ProviderServices)
func (*Bot) SetServiceForTest ¶
func (b *Bot) SetServiceForTest(service llm.ServiceConfig)
type MMBots ¶
type MMBots struct {
// contains filtered or unexported fields
}
func New ¶
func New(mutexPluginAPI cluster.MutexPluginAPI, pluginAPI *pluginapi.Client, licenseChecker *enterprise.LicenseChecker, config Config, agentStore AgentStore, llmUpstreamHTTPClient *http.Client, metrics llm.MetricsObserver) *MMBots
func (*MMBots) CheckUsageRestrictions ¶
func (*MMBots) CheckUsageRestrictionsForChannel ¶ added in v2.6.0
CheckUsageRestrictionsForChannel returns nil when the bot's ChannelAccessLevel configuration allows use in the given channel, otherwise an error wrapping ErrUsageRestriction. Unlike CheckUsageRestrictions it does not consider user-scope restrictions, so callers can validate channel-level settings (e.g. auto-reply) independent of any requesting user.
func (*MMBots) CheckUsageRestrictionsForUser ¶
func (*MMBots) CheckUsageRestrictionsForUserConfig ¶
func (m *MMBots) CheckUsageRestrictionsForUserConfig(cfg llm.BotConfig, requestingUserID string) error
CheckUsageRestrictionsForUserConfig returns nil if userID is allowed by cfg's UserAccessLevel / UserIDs / TeamIDs, otherwise an error wrapping ErrUsageRestriction. This is the shared source of truth for user-scope access checks; both config-bot Bot-based callers (CheckUsageRestrictionsForUser) and DB-agent BotConfig-based callers (api.canUserAccessAgent) use it.
func (*MMBots) EnsureBots ¶
func (*MMBots) ForceRefreshOnNextEnsure ¶
func (b *MMBots) ForceRefreshOnNextEnsure()
ForceRefreshOnNextEnsure clears the optimistic ensure snapshot and sets forceRefresh so the next EnsureBots() cannot take the fast path. DB-backed agents are not part of the config-file bot slice used for botConfigsEqual, so we must invalidate when agents change.
func (*MMBots) GetAllBotUserIDs ¶
GetAllBotUserIDs returns a list of all bot user IDs
func (*MMBots) GetBotByID ¶
GetBotByID retrieves the bot associated with the given bot ID
func (*MMBots) GetBotByUsername ¶
GetBotByUsername retrieves the bot associated with the given bot username
func (*MMBots) GetBotByUsernameOrFirst ¶
GetBotByUsernameOrFirst retrieves the bot associated with the given bot username or the first bot if not found
func (*MMBots) GetBotConfig ¶
func (*MMBots) GetBotConfigByID ¶
GetBotConfigByID returns the bot's EnableVision and MaxFileSize. ok is false when botID is unknown.
func (*MMBots) GetBotForDMChannel ¶
GetBotForDMChannel returns the bot for the given DM channel.
func (*MMBots) GetBotMentioned ¶
GetBotMentioned returns the bot mentioned in the text, if any.
func (*MMBots) GetTranscribe ¶
func (b *MMBots) GetTranscribe() Transcriber
TODO: This really doesn't belong here. Figure out where to put this.
func (*MMBots) SetBotsForTesting ¶
SetBotsForTesting sets bots directly for testing purposes only