api

package
v2.14.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: Apache-2.0 Imports: 71 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	ContextPostKey    = "post"
	ContextChannelKey = "channel"
	ContextBotKey     = "bot"
)
View Source
const (
	TitleSummarizeUnreads = "Summarize Unreads"
	TitleSummarizeChannel = "Summarize Channel"
)
View Source
const (
	TitleThreadSummary     = "Thread Summary"
	TitleFindActionItems   = "Action Items"
	TitleFindOpenQuestions = "Open Questions"
)
View Source
const (
	// Config.
	AuditEventSaveConfig         = "saveConfig"
	AuditEventSaveSettingsAccess = "saveSettingsAccess"

	// Admin operations.
	AuditEventReindexPosts          = "reindexPosts"
	AuditEventCancelReindexJob      = "cancelReindexJob"
	AuditEventCatchUpReindex        = "catchUpReindex"
	AuditEventRebuildVectorIndex    = "rebuildVectorIndex"
	AuditEventClearMCPToolsCache    = "clearMCPToolsCache"
	AuditEventUpdateMCPPluginServer = "updateMCPPluginServer"

	// Agent CRUD.
	AuditEventCreateAgent       = "createAgent"
	AuditEventUpdateAgent       = "updateAgent"
	AuditEventDeleteAgent       = "deleteAgent"
	AuditEventUpdateAgentAvatar = "updateAgentAvatar"

	// Agent versioning. Listing and viewing versions are read-only and are not audited.
	AuditEventRestoreAgentVersion = "restoreAgentVersion"
	AuditEventDeleteAgentVersions = "deleteAgentVersions"

	// Custom prompts.
	AuditEventCreateCustomPrompt = "createCustomPrompt"
	AuditEventUpdateCustomPrompt = "updateCustomPrompt"
	AuditEventDeleteCustomPrompt = "deleteCustomPrompt"

	// Channel configuration.
	AuditEventUpdateChannelAutoReply = "updateChannelAutoReply"

	// Conversation management by its owner.
	AuditEventRenameConversation  = "renameConversation"
	AuditEventArchiveConversation = "archiveConversation"

	// Credentials: third-party MCP OAuth grant/revocation and per-user tool
	// provider preferences.
	AuditEventMCPOAuthStart            = "mcpOAuthStart"
	AuditEventMCPOAuthCallback         = "mcpOAuthCallback"
	AuditEventMCPOAuthDisconnect       = "mcpOAuthDisconnect"
	AuditEventUpdateMCPUserPreferences = "updateMCPUserPreferences"

	// Inter-plugin MCP server registration (bridge routes).
	AuditEventRegisterMCPPluginServer   = "registerMCPPluginServer"
	AuditEventUnregisterMCPPluginServer = "unregisterMCPPluginServer"

	// In-channel tool approval: the human decision the server cannot see.
	AuditEventToolCallApproval   = "toolCallApproval"
	AuditEventToolResultApproval = "toolResultApproval"

	// wait_for_async_work controls: the requester ending or canceling a pause.
	AuditEventWaitCheckNow = "waitCheckNow"
	AuditEventWaitCancel   = "waitCancel"

	// MCP session grant: an external MCP client obtained a dedicated session
	// holding API access as the user. Not a gin route — emitted directly by
	// delegateToMCPHandler when a session is newly created, so it has no
	// registry entry below.
	AuditEventMCPSessionGrant = "mcpSessionGrant"

	// Access-policy authoring. GET is read-only and is not audited.
	AuditEventPutAgentPolicy      = "putAgentAccessPolicy"
	AuditEventDeleteAgentPolicy   = "deleteAgentAccessPolicy"
	AuditEventPutServicePolicy    = "putServiceAccessPolicy"
	AuditEventDeleteServicePolicy = "deleteServiceAccessPolicy"
	AuditEventPutMCPPolicy        = "putMCPAccessPolicy"
	AuditEventDeleteMCPPolicy     = "deleteMCPAccessPolicy"

	// Dictation: minting a provider session billed to the organization.
	AuditEventCreateDictationSession = "createDictationSession"
	AuditEventEndDictationSession    = "endDictationSession"
)

Audit event names for every state-changing operation in the plugin: 38 routed events plus the non-gin MCP session grant. All are declared here, including ones whose instrumentation lands in later changes, so call sites never use inline string literals; new state-changing routes add their names here rather than inline.

The server stamps the plugin ID into every record's parameters when it is logged, so the names stay unprefixed.

View Source
const AgentActiveCountHeader = "X-Agent-Active-Count"

AgentActiveCountHeader is returned on GET /agents when agents are capped so the webapp can gate creation against the server-wide combined pool (not the access-filtered list).

View Source
const MaxAgentRequestBodyBytes = 2 << 20 // 2 MiB

MaxAgentRequestBodyBytes caps agent create/update JSON bodies. It must comfortably exceed the worst-case encoded size of llm.MaxCustomInstructionsRunes plus the remaining payload.

View Source
const MaxConversationTitleLength = 256

MaxConversationTitleLength bounds a user-set conversation title, in runes. Generated titles are capped at 25 tokens, far below this.

View Source
const WebsocketEventBotsInvalidate = "bots_invalidate"

WebsocketEventBotsInvalidate is the event name for PublishWebSocketEvent (webapp: custom_mattermost-ai_<name>).

View Source
const WebsocketEventChannelAutoReplyUpdated = "channel_autoreply_updated"

WebsocketEventChannelAutoReplyUpdated is the event name for PublishWebSocketEvent (webapp: custom_mattermost-ai_<name>).

View Source
const WebsocketEventDictationAvailabilityChanged = "dictation_availability_changed"

WebsocketEventDictationAvailabilityChanged tells clients to refetch GET /dictation/availability (webapp: custom_mattermost-ai_<name>).

View Source
const WebsocketEventDictationSessionEnded = "dictation_session_ended"

WebsocketEventDictationSessionEnded tells the user the server ended one of their dictation sessions (webapp: custom_mattermost-ai_<name>).

View Source
const WebsocketEventMCPConnectionUpdated = "mcp_connection_updated"

WebsocketEventMCPConnectionUpdated is the event name for user-scoped MCP OAuth connection updates (webapp: custom_mattermost-ai_<name>).

Variables

This section is empty.

Functions

This section is empty.

Types

type ABACStatusResponse added in v2.8.0

type ABACStatusResponse struct {
	Available bool `json:"available"`
}

type AIBotInfo

type AIBotInfo struct {
	ID                    string                 `json:"id"`
	DisplayName           string                 `json:"displayName"`
	Username              string                 `json:"username"`
	LastIconUpdate        int64                  `json:"lastIconUpdate"`
	DMChannelID           string                 `json:"dmChannelID"`
	ChannelAccessLevel    llm.ChannelAccessLevel `json:"channelAccessLevel"`
	ChannelIDs            []string               `json:"channelIDs"`
	UserAccessLevel       llm.UserAccessLevel    `json:"userAccessLevel"`
	UserIDs               []string               `json:"userIDs"`
	EnabledMCPTools       []llm.EnabledMCPTool   `json:"enabledMCPTools"`
	AutoEnableNewMCPTools bool                   `json:"autoEnableNewMCPTools"`
	// UseServiceAccountAuth is the effective mode, not the raw agent flag: it is
	// false when the server is not licensed for remote MCP.
	UseServiceAccountAuth bool `json:"useServiceAccountAuth"`
	IsDefault             bool `json:"isDefault,omitempty"`
	// IsCreator reports whether the requesting user created the agent.
	IsCreator bool `json:"isCreator"`
	// HasChats reports whether the requesting user has a chat with the agent
	// in their DM, regardless of how many other chats they have.
	HasChats bool `json:"hasChats"`
}

type AIBotsResponse

type AIBotsResponse struct {
	Bots             []AIBotInfo `json:"bots"`
	SearchEnabled    bool        `json:"searchEnabled"`
	AllowUnsafeLinks bool        `json:"allowUnsafeLinks"`
	// LinkPolicy is what the webapp enforces; AllowUnsafeLinks is kept for
	// API compatibility.
	LinkPolicy           config.LinkPolicy `json:"linkPolicy"`
	HTMLArtifactsEnabled bool              `json:"htmlArtifactsEnabled"`
}

type API

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

API represents the HTTP API functionality for the plugin

func New

func New(
	bots *bots.MMBots,
	conversationsService *conversations.Conversations,
	meetingsService *meetings.Service,
	indexerService *indexer.Indexer,
	searchService *search.Search,
	pluginAPI *pluginapi.Client,
	metricsService metrics.Metrics,
	llmContextBuilder *llmcontext.Builder,
	config Config,
	prompts *llm.Prompts,
	mmClient mmapi.Client,
	dbClient *mmapi.DBClient,
	licenseChecker *enterprise.LicenseChecker,
	streamingService streaming.Service,
	i18nBundle *i18n.Bundle,
	mcpClientManager MCPClientManager,
	mcpHandlers *mcpserver.PluginMCPHandlers,
	llmUpstreamHTTPClient *http.Client,
	configStore ConfigStore,
	agentStore AgentStore,
	configUpdater ConfigUpdater,
	clusterNotifier ClusterNotifier,
	clusterAgentNotifier ClusterAgentNotifier,
	mcpOAuthNotifier MCPOAuthClusterNotifier,
	streamStopNotifier StreamStopClusterNotifier,
	conversationStore ConversationStore,
	getSearchInitError func() string,
	customPromptsStore *customprompts.Store,
	autoReplyStore ChannelAutoReplyStore,
	accessChecker *accesscontrol.Checker,
) *API

New creates a new API instance

func (*API) MattermostAuthorizationRequired

func (a *API) MattermostAuthorizationRequired(c *gin.Context)

func (*API) ServeHTTP

func (a *API) ServeHTTP(c *plugin.Context, w http.ResponseWriter, r *http.Request)

ServeHTTP handles HTTP requests to the plugin

func (*API) ServeMetrics

func (a *API) ServeMetrics(c *plugin.Context, w http.ResponseWriter, r *http.Request)

ServeMetrics serves the metrics endpoint

func (*API) SetConversationService

func (a *API) SetConversationService(svc *conversation.Service)

SetConversationService sets the conversation entity service for channel analysis.

func (*API) SetDictationService added in v2.14.0

func (a *API) SetDictationService(svc *dictation.Service)

SetDictationService sets the service behind the /dictation routes. Without one, both routes report dictation as unavailable.

func (*API) SetExternalRebuilderForTest

func (a *API) SetExternalRebuilderForTest(rb externalServerRebuilder)

SetExternalRebuilderForTest installs a test-only externalServerRebuilder.

type ActiveWaitResponse added in v2.12.0

type ActiveWaitResponse struct {
	PostID          string `json:"post_id"`
	RequesterUserID string `json:"requester_user_id"`
	ScheduledAt     int64  `json:"scheduled_at"`
	ResumeAt        int64  `json:"resume_at"`
	DurationMinutes int    `json:"duration_minutes"`
}

ActiveWaitResponse describes a pending wait_for_async_work pause. Times are unix millis. RequesterUserID is the only user allowed to check-now or cancel the wait; the webapp also uses it to pick the owner vs onlooker rendering.

type AgentRequestFields added in v2.8.0

type AgentRequestFields struct {
	DisplayName           string               `json:"displayName" binding:"required"`
	ServiceID             string               `json:"serviceID" binding:"required"`
	CustomInstructions    string               `json:"customInstructions"`
	ChannelAccessLevel    int                  `json:"channelAccessLevel"`
	ChannelIDs            []string             `json:"channelIDs"`
	UserAccessLevel       int                  `json:"userAccessLevel"`
	UserIDs               []string             `json:"userIDs"`
	TeamIDs               []string             `json:"teamIDs"`
	AdminUserIDs          []string             `json:"adminUserIDs"`
	EnabledMCPTools       []llm.EnabledMCPTool `json:"enabledMCPTools"`
	AutoEnableNewMCPTools bool                 `json:"autoEnableNewMCPTools"`
	MCPDynamicToolLoading bool                 `json:"mcpDynamicToolLoading"`
	UseServiceAccountAuth bool                 `json:"useServiceAccountAuth"`
	Model                 string               `json:"model"`
	EnableVision          bool                 `json:"enableVision"`
	DisableTools          bool                 `json:"disableTools"`
	EnabledNativeTools    []string             `json:"enabledNativeTools"`
	ReasoningEnabled      bool                 `json:"reasoningEnabled"`
	ReasoningEffort       string               `json:"reasoningEffort"`
	ThinkingBudget        int                  `json:"thinkingBudget"`
	// StructuredOutputEnabled is deprecated: it is accepted and persisted for
	// compatibility with existing callers, but ignored at runtime. Structured
	// output is a per-service policy (ServiceConfig.StructuredOutputPolicy).
	StructuredOutputEnabled bool             `json:"structuredOutputEnabled"`
	MaxToolTurns            int              `json:"maxToolTurns"`
	Skills                  llm.SkillsConfig `json:"skills"`
}

AgentRequestFields are the request fields common to agent create and update. Field values are stored as given (no server-side fill-in). MCP tool access is controlled by two independent fields:

  • autoEnableNewMCPTools=true gives the agent every currently configured MCP tool and any added later.
  • Otherwise, the agent gets only the tools listed in enabledMCPTools (empty/missing = no MCP tools).

type AgentStore

type AgentStore interface {
	// CreateAgent and UpdateAgent record every write as a new agent version.
	CreateAgent(cfg *llm.BotConfig, meta store.AgentVersionMeta) error
	GetAgent(id string) (*llm.BotConfig, error)
	ListAgents() ([]*llm.BotConfig, error)
	ListAgentsByCreator(creatorID string) ([]*llm.BotConfig, error)
	CountActiveAgents() (int, error)
	UpdateAgent(cfg *llm.BotConfig, meta store.AgentVersionMeta) error
	DeleteAgent(id string) error

	// ListAgentVersions returns up to limit versions older than before (no
	// upper bound when before is 0), newest first.
	ListAgentVersions(agentID string, before, limit int) (store.AgentVersionPage, error)
	// GetAgentVersion returns nil, nil when the version does not exist.
	GetAgentVersion(agentID string, version int) (*store.AgentVersionDetail, error)
	// DeleteAgentVersions deletes the given versions; it returns
	// store.ErrCurrentAgentVersion, deleting nothing, when they include the current one.
	DeleteAgentVersions(agentID string, versions []int) (int64, error)
	// DeletePreviousAgentVersions deletes every version but the current one.
	DeletePreviousAgentVersions(agentID string) (int64, error)
}

AgentStore provides CRUD access to user-created agents in the database.

type ChannelAutoReply added in v2.6.0

type ChannelAutoReply struct {
	BotID        string `json:"bot_id"`
	Mode         string `json:"mode"`
	Instructions string `json:"instructions,omitempty"`
}

ChannelAutoReply is the request and response payload for GET/PUT /channel/{channelid}/autoreply.

type ChannelAutoReplyStore added in v2.6.0

type ChannelAutoReplyStore interface {
	Get(channelID string) (*autoreply.Setting, error)
	Set(setting autoreply.Setting) (*autoreply.Setting, error)
	Delete(channelID string) error
}

ChannelAutoReplyStore provides read/write access to per-channel auto-reply settings. Implemented by *autoreply.Service (Phase 1). Get reads the database so API reads are read-your-writes across cluster nodes; Set/Delete validate, persist, and handle cluster cache invalidation internally.

type ClearMCPToolsCacheResponse

type ClearMCPToolsCacheResponse struct {
	ClearedServers int    `json:"cleared_servers"`
	Message        string `json:"message"`
}

ClearMCPToolsCacheResponse represents the response for clearing the cache

type ClusterAgentNotifier

type ClusterAgentNotifier interface {
	PublishAgentUpdate(agentID string) error
}

ClusterAgentNotifier broadcasts agent update events to other cluster nodes. agentID names a renamed agent that peers refresh individually first; it is empty when no single agent needs that.

type ClusterNotifier

type ClusterNotifier interface {
	PublishConfigUpdate() error
}

ClusterNotifier broadcasts config update events to other cluster nodes.

type Config

type Config interface {
	GetDefaultBotUserID() string
	// GetDefaultBotName is the legacy username reference, used only when no
	// default bot user ID is set.
	GetDefaultBotName() string
	MCP() mcp.Config
	AllowUnsafeLinks() bool
	LinkPolicy() config.LinkPolicy
	EnableHTMLArtifacts() bool
	EmbeddingSearchConfig() embeddings.EmbeddingSearchConfig
	EnableChannelMentionToolCalling() bool
	EnableAmbientAutoReply() bool

	// GetServices returns a snapshot of the stored service configurations, in
	// configuration order. The bridge service endpoints operate on this
	// snapshot directly rather than going through an agent.
	GetServices() []llm.ServiceConfig

	// SettingsAccess returns the users delegated access to the plugin
	// configuration besides system admins.
	SettingsAccess() config.SettingsAccess
}

type ConfigStore

type ConfigStore interface {
	GetConfig() (*config.Config, error)
	SaveConfig(cfg config.Config) error
	// UpdateConfig atomically reads the active config, applies transform, and
	// persists the result under the config advisory lock. A transform error
	// aborts the update and is returned as-is.
	UpdateConfig(transform func(prev *config.Config) (config.Config, error)) (config.Config, error)
	// UpdateConfigWithOutcome is UpdateConfig returning the persisted config
	// and any DB-backed agent IDs atomically remapped inside the transaction.
	UpdateConfigWithOutcome(transform func(prev *config.Config) (config.Config, error)) (store.ConfigUpdateOutcome, error)
}

ConfigStore provides read/write access to the plugin configuration in the database.

type ConfigUpdater

type ConfigUpdater interface {
	Update(cfg *config.Config)
}

ConfigUpdater updates the in-memory plugin configuration.

type ConversationResponse

type ConversationResponse struct {
	ID         string         `json:"id"`
	UserID     string         `json:"user_id"`
	BotID      string         `json:"bot_id"`
	ChannelID  *string        `json:"channel_id"`
	RootPostID *string        `json:"root_post_id"`
	Title      string         `json:"title"`
	Operation  string         `json:"operation"`
	Turns      []TurnResponse `json:"turns"`

	// ActiveWait is set only while a wait_for_async_work pause is pending in
	// this conversation's thread, so the webapp can render a live countdown.
	ActiveWait *ActiveWaitResponse `json:"active_wait,omitempty"`
}

ConversationResponse is the JSON shape returned by GET /conversations/{id}.

type ConversationStore

type ConversationStore interface {
	GetConversation(id string) (*store.Conversation, error)
	GetTurnsForConversation(conversationID string) ([]store.Turn, error)
	GetTurnByPostID(postID string) (*store.Turn, error)
	UpdateTurnContent(id string, content json.RawMessage) error
	GetConversationIncludingArchived(id string) (*store.Conversation, error)
	GetBotDMConversationSummariesForUser(userID string, limit, offset int) ([]store.ConversationSummary, error)
	GetBotDMBotIDsForUser(userID string) ([]string, error)
	RenameConversation(id, title string) (bool, error)
	ArchiveConversation(id string, archivedAt int64) error
}

ConversationStore provides read/write access to conversation and turn data.

type CreateAgentRequest

type CreateAgentRequest struct {
	AgentRequestFields
	Username string `json:"username" binding:"required"`
}

CreateAgentRequest is the JSON body for POST /agents.

type DeleteAgentVersionsRequest added in v2.11.0

type DeleteAgentVersionsRequest struct {
	Versions []int `json:"versions"`
	All      bool  `json:"all"`
}

DeleteAgentVersionsRequest is the JSON body for DELETE /agents/:agentid/versions: either the versions to delete, or all to delete every version but the current one.

type FetchModelsForServiceRequest

type FetchModelsForServiceRequest struct {
	ServiceID string `json:"serviceID" binding:"required"`
}

FetchModelsForServiceRequest is the JSON body for POST /agents/models/fetch.

type FetchModelsRequest

type FetchModelsRequest struct {
	ServiceType string `json:"serviceType"`
	APIKey      string `json:"apiKey"`
	APIURL      string `json:"apiURL"`
	OrgID       string `json:"orgID"`

	// ServiceID names an already saved service whose credentials are read from
	// the stored configuration. A service the admin is still entering has no
	// stored counterpart and supplies its credentials in this request instead.
	ServiceID string `json:"serviceID"`

	// Region applies to providers that require it for model listing (Vertex AI).
	Region string `json:"region"`

	// Vertex AI credentials. VertexAuthCredentials may be empty to signal ADC.
	VertexProjectID       string `json:"vertexProjectID"`
	VertexProjectNumber   string `json:"vertexProjectNumber"`
	VertexAuthCredentials string `json:"vertexAuthCredentials"`
}

type MCPClientManager

type MCPClientManager interface {
	GetOAuthManager() *mcp.OAuthManager
	GetToolsCache() *mcp.ToolsCache
	GetHTTPClient() *http.Client
	ProcessOAuthCallback(ctx context.Context, loggedInUserID, state, code, iss string) (*mcp.OAuthSession, error)
	DisconnectUserOAuth(ctx context.Context, userID, serverName string) error
	MarkOAuthNeeded(userID, serverName, authURL string) error
	GetEmbeddedServer() mcp.EmbeddedMCPServer
	EnsureMCPSessionID(userID string) (sessionID string, created bool, err error)
	GetCatalogAccess(ctx context.Context, req mcp.CatalogRequest) mcp.CatalogAccess
	RefreshCatalogAccess(ctx context.Context, req mcp.CatalogRequest) (mcp.CatalogAccess, error)
	GetConfig() mcp.Config

	RegisterPluginServer(cfg mcp.PluginServerConfig)
	UpdatePluginServerAdminFields(pluginID string, enabled bool, toolConfigs []mcp.ToolConfig) (mcp.PluginServerConfig, bool)
	UnregisterPluginServer(pluginID string)
	ListPluginServers() []mcp.PluginServerConfig
	GetPluginServer(pluginID string) (mcp.PluginServerConfig, bool)

	DiscoverPluginServerTools(ctx context.Context, userID string, cfg mcp.PluginServerConfig) ([]mcp.ToolInfo, error)
}

type MCPOAuthClusterNotifier

type MCPOAuthClusterNotifier interface {
	PublishMCPOAuthUpdate(userID string) error
}

MCPOAuthClusterNotifier broadcasts MCP OAuth updates to other cluster nodes.

type MCPServerInfo

type MCPServerInfo struct {
	Name       string        `json:"name"`
	URL        string        `json:"url"`
	Tools      []MCPToolInfo `json:"tools"`
	NeedsOAuth bool          `json:"needsOAuth"`
	OAuthURL   string        `json:"oauthURL,omitempty"` // URL to redirect for OAuth if needed
	Error      *string       `json:"error"`

	// ServerType is one of "embedded", "remote", or "plugin".
	ServerType string `json:"serverType"`
	Enabled    bool   `json:"enabled"`
	// ToolConfigs is populated for plugin rows only.
	ToolConfigs []mcp.ToolConfig `json:"toolConfigs,omitempty"`
	// ID is the stable ABAC policy identity when present.
	ID string `json:"id,omitempty"`
}

MCPServerInfo represents a server and its tools for API response

type MCPSuggestedDescriptionResponse added in v2.10.0

type MCPSuggestedDescriptionResponse struct {
	Description string `json:"description"`
	Source      string `json:"source"`
	NeedsOAuth  bool   `json:"needsOAuth"`
	AuthURL     string `json:"authURL,omitempty"`
}

MCPSuggestedDescriptionResponse is a draft description for a remote MCP server, taken from how the server describes itself to the requesting admin. When the admin must sign in to the server first, NeedsOAuth is set and AuthURL starts that flow.

type MCPToolInfo

type MCPToolInfo struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	InputSchema any    `json:"inputSchema"`
	// ReadOnlyHint is the server's readOnlyHint annotation for the tool.
	ReadOnlyHint bool `json:"readOnlyHint"`
	// DefaultPolicy is the policy the tool runs with while it has no stored
	// policy (mcp.EffectiveDefaultToolPolicy).
	DefaultPolicy string `json:"defaultPolicy"`
	// SuggestedPolicy is the policy the System Console pre-selects when an
	// admin reviews the tool (mcp.SuggestedToolPolicy). It has no effect
	// until the admin saves it.
	SuggestedPolicy string `json:"suggestedPolicy"`
}

MCPToolInfo represents a tool from an MCP server for API response

type MCPToolsResponse

type MCPToolsResponse struct {
	Servers []MCPServerInfo `json:"servers"`
}

MCPToolsResponse represents the response structure for MCP tools endpoint

type RawFileContentRequest

type RawFileContentRequest struct {
	FileID string `json:"file_id"`
	Offset int    `json:"offset,omitempty"`
	Limit  int    `json:"limit,omitempty"`
}

RawFileContentRequest is the request body for the raw file content endpoint.

type RawFileContentResponse

type RawFileContentResponse struct {
	Name       string `json:"name"`
	MimeType   string `json:"mime_type"`
	TotalRunes int    `json:"total_runes"`
	Offset     int    `json:"offset"`
	Returned   int    `json:"returned"`
	HasMore    bool   `json:"has_more"`
	HasText    bool   `json:"has_text"`
	Text       string `json:"text"`
}

RawFileContentResponse is the response body for the raw file content endpoint.

type RawSearchRequest

type RawSearchRequest struct {
	Query     string `json:"query"`
	TeamID    string `json:"team_id,omitempty"`
	ChannelID string `json:"channel_id,omitempty"`
	Limit     int    `json:"limit,omitempty"`
	Offset    int    `json:"offset,omitempty"`
}

RawSearchRequest represents the request body for the raw semantic search endpoint

type RawSearchResponse

type RawSearchResponse struct {
	Results []RawSearchResult `json:"results"`
}

RawSearchResponse represents the response body for the raw semantic search endpoint

type RawSearchResult

type RawSearchResult struct {
	PostID      string  `json:"post_id"`
	ChannelID   string  `json:"channel_id"`
	ChannelName string  `json:"channel_name"`
	UserID      string  `json:"user_id"`
	Username    string  `json:"username"`
	Content     string  `json:"content"`
	Score       float32 `json:"score"`
	CreateAt    int64   `json:"create_at"` // Post creation timestamp (Unix millis)
}

RawSearchResult represents a single raw semantic search result

type ReindexRequest

type ReindexRequest struct {
	ClearIndex *bool `json:"clearIndex"`
}

ReindexRequest represents the request body for reindexing

type RenderRequest

type RenderRequest struct {
	ChannelID string `json:"channel_id"`
	// BotID is the agent's bot user ID; it takes precedence over BotUsername.
	BotID string `json:"bot_id"`
	// BotUsername is deprecated: it selects only the agent whose account
	// currently holds the name.
	BotUsername string `json:"bot_username"`
}

RenderRequest represents the request body for rendering a custom prompt template.

type SearchRequest

type SearchRequest struct {
	Query string `json:"query"`
	// TeamID is the user's current team, used for citation links.
	TeamID string `json:"teamId"`
	// ChannelID is the channel the agent searches first.
	ChannelID string `json:"channelId"`
}

SearchRequest is a search started from the search bar or /ask-channel.

type ServiceInfo

type ServiceInfo struct {
	ID               string `json:"id"`
	Name             string `json:"name"`
	Type             string `json:"type"`
	DefaultModel     string `json:"defaultModel"`
	OutputTokenLimit int    `json:"outputTokenLimit"`
	UseResponsesAPI  bool   `json:"useResponsesAPI"`
}

ServiceInfo is a client-safe view of an AI service (no secrets).

type SetPinRequest

type SetPinRequest struct {
	PromptID string `json:"prompt_id"`
	Pinned   bool   `json:"pinned"`
}

SetPinRequest represents the request body for pinning/unpinning a prompt.

type StreamStopClusterNotifier

type StreamStopClusterNotifier interface {
	PublishStreamStop(postID string) error
}

StreamStopClusterNotifier broadcasts a stop-streaming request to peer nodes so HA deployments without sticky sessions can cancel an in-flight LLM stream no matter which node handles the /stop request.

type TurnResponse

type TurnResponse struct {
	ID        string          `json:"id"`
	PostID    *string         `json:"post_id"`
	Role      string          `json:"role"`
	Content   json.RawMessage `json:"content"`
	TokensIn  int64           `json:"tokens_in"`
	TokensOut int64           `json:"tokens_out"`
	Sequence  int             `json:"sequence"`
	// ApprovalState is set only on post-anchor assistant turns (those with
	// a non-nil PostID). One of "call" | "result" | "done". Computed by the
	// server so the webapp renders approval UI from a single source of truth.
	ApprovalState string `json:"approval_state,omitempty"`
	// Status is the turn lifecycle state: "streaming" while a response is
	// being generated, then "complete" or "interrupted".
	Status string `json:"status"`
	// RunPostID is the response post whose run wrote a tool-round turn. While
	// that response streams, its anchor sits before these turns, so the
	// webapp matches them by this ID.
	RunPostID *string `json:"run_post_id,omitempty"`
}

TurnResponse is the JSON shape for a single turn within a conversation response.

type UpdateAgentRequest

type UpdateAgentRequest struct {
	AgentRequestFields
	Username string `json:"username"`
	// contains filtered or unexported fields
}

UpdateAgentRequest is the JSON body for PUT /agents/:agentid (full document replace, same shape as create). Omitting username keeps the current one.

func (*UpdateAgentRequest) UnmarshalJSON

func (r *UpdateAgentRequest) UnmarshalJSON(data []byte) error

type UpdatePluginServerRequest

type UpdatePluginServerRequest struct {
	Enabled     *bool             `json:"enabled,omitempty"`
	ToolConfigs *[]mcp.ToolConfig `json:"tool_configs,omitempty"`
}

UpdatePluginServerRequest is the body shape for PUT /admin/mcp/plugin-servers/:pluginID. Pointer fields use partial-update semantics: nil means unchanged.

type UserMCPServerInfo

type UserMCPServerInfo struct {
	Name                     string            `json:"name"`
	ServerOrigin             string            `json:"serverOrigin"`
	Kind                     string            `json:"kind"`
	Authenticated            bool              `json:"authenticated"`
	NeedsOAuth               bool              `json:"needsOAuth"`
	AuthEmail                string            `json:"authEmail,omitempty"`
	AuthURL                  string            `json:"authURL,omitempty"`
	ServiceAccountConfigured bool              `json:"serviceAccountConfigured"`
	Tools                    []UserMCPToolInfo `json:"tools"`
}

UserMCPServerInfo describes a single MCP server and its visible tools.

type UserMCPToolInfo

type UserMCPToolInfo struct {
	Name         string `json:"name"`
	Description  string `json:"description"`
	Enabled      bool   `json:"enabled"`
	Policy       string `json:"policy"`
	InputSchema  any    `json:"inputSchema,omitempty"`
	ReadOnlyHint bool   `json:"readOnlyHint,omitempty"`
}

UserMCPToolInfo describes a single tool within a server response.

type UserMCPToolsResponse

type UserMCPToolsResponse struct {
	Servers []UserMCPServerInfo `json:"servers"`
}

UserMCPToolsResponse is the top-level response for GET /mcp/tools.

Jump to

Keyboard shortcuts

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