mirror of
https://github.com/hanzoai/team.git
synced 2026-09-30 01:57:35 +00:00
* Add shared AI bridge seam Co-authored-by: Nick Misasi <[email protected]> * Add AI bridge test helper API Co-authored-by: Nick Misasi <[email protected]> * Add AI bridge seam test coverage Co-authored-by: Nick Misasi <[email protected]> * Add Playwright AI bridge recap helpers Co-authored-by: Nick Misasi <[email protected]> * Fix recap channel persistence test Co-authored-by: Nick Misasi <[email protected]> * Restore bridge client compatibility shim Co-authored-by: Nick Misasi <[email protected]> * Expand recap card in Playwright spec Co-authored-by: Nick Misasi <[email protected]> * Recaps e2e test coverage (#35543) * Add Recaps Playwright page object Co-authored-by: Nick Misasi <[email protected]> * Expand AI recap Playwright coverage Co-authored-by: Nick Misasi <[email protected]> * Format recap Playwright coverage Co-authored-by: Nick Misasi <[email protected]> * Fix recap regeneration test flows Co-authored-by: Nick Misasi <[email protected]> --------- * Fix AI bridge lint and OpenAPI docs Co-authored-by: Nick Misasi <[email protected]> * Fix recap lint shadowing Co-authored-by: Nick Misasi <[email protected]> * Stabilize failed recap regeneration spec Co-authored-by: Nick Misasi <[email protected]> * Fill AI bridge i18n strings Co-authored-by: Nick Misasi <[email protected]> * Fix i18n * Add service completion bridge path and operation tracking fields Extend AgentsBridge with CompleteService for service-based completions, add ClientOperation/OperationSubType tracking to BridgeCompletionRequest, and propagate operation metadata through to the bridge client. Made-with: Cursor * Fill empty i18n translation strings for enterprise keys The previous "Fix i18n" commit added 145 i18n entries with empty translation strings, causing the i18n check to fail in CI. Fill in all translations based on the corresponding error messages in the enterprise and server source code. * Fix i18n * Fix i18n again * Rename Complete/CompleteService to AgentCompletion/ServiceCompletion Align the AgentsBridge interface method names with the underlying bridge client methods they delegate to (AgentCompletion, ServiceCompletion). Made-with: Cursor * Refactor * Add e2eAgentsBridge implementation The new file was missed from the prior refactor commit. Made-with: Cursor * Address CodeRabbit review feedback - Add 400 BadRequest response to AI bridge PUT endpoint OpenAPI spec - Add missing client_operation, operation_sub_type, service_id fields to AIBridgeTestHelperRecordedRequest schema - Deep-clone nested JSON schema values in cloneJSONOutputFormat - Populate ChannelID on recap summary bridge requests - Fix msg_count assertion to mention_count for mark-as-read verification - Make AgentCompletion/ServiceCompletion mutex usage atomic Made-with: Cursor * fix(playwright): align recaps page object with placeholder and channel menu Made-with: Cursor * fix(playwright): update recaps expectEmptyState to match RecapsList empty state After the master merge, the recaps page now renders RecapsList's "You're all caught up" empty state instead of the old placeholder. Made-with: Cursor * chore(playwright): update package-lock.json after npm install Made-with: Cursor * Revert "chore(playwright): update package-lock.json after npm install" This reverts commit 95c670863a55f1549d266baccc1e2fcf8a7cd74e. * style(playwright): fix prettier formatting in recaps page object Made-with: Cursor * fix(playwright): handle both recaps empty states correctly The recaps page has two distinct empty states: - Setup placeholder ("Set up your recap") when allRecaps is empty - RecapsList caught-up state ("You're all caught up") when the filtered tab list is empty Split expectEmptyState into expectSetupPlaceholder and expectCaughtUpEmptyState, used by the delete and bridge-unavailable tests respectively. Made-with: Cursor --------- Co-authored-by: Hanzo Dev <[email protected]>
100 lines
3.4 KiB
Go
100 lines
3.4 KiB
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
package app
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
agentclient "github.com/mattermost/mattermost-plugin-ai/public/bridgeclient"
|
|
"github.com/mattermost/mattermost/server/public/model"
|
|
"github.com/mattermost/mattermost/server/public/shared/mlog"
|
|
"github.com/mattermost/mattermost/server/public/shared/request"
|
|
)
|
|
|
|
// GetBridgeClient remains as a compatibility helper for downstream enterprise code.
|
|
// New server code should use a.ch.agentsBridge instead of relying on the concrete bridge client.
|
|
func (a *App) GetBridgeClient(userID string) *agentclient.Client {
|
|
return agentclient.NewClientFromApp(a, userID)
|
|
}
|
|
|
|
// ServiceCompletion remains as a compatibility helper for downstream enterprise
|
|
// code that needs service-based bridge completions while using the shared
|
|
// AgentsBridge abstraction.
|
|
func (a *App) ServiceCompletion(sessionUserID, serviceID string, req BridgeCompletionRequest) (string, error) {
|
|
return a.ch.agentsBridge.ServiceCompletion(sessionUserID, serviceID, req)
|
|
}
|
|
|
|
// GetAIPluginBridgeStatus checks if the mattermost-ai plugin is active and supports the bridge API (v1.5.0+)
|
|
// It returns a boolean indicating availability, and a reason string (translation ID) if unavailable.
|
|
func (a *App) GetAIPluginBridgeStatus(rctx request.CTX) (bool, string) {
|
|
return a.ch.agentsBridge.Status(rctx)
|
|
}
|
|
|
|
// GetAgents retrieves all available agents from the bridge API
|
|
func (a *App) GetAgents(rctx request.CTX, userID string) ([]model.BridgeAgentInfo, *model.AppError) {
|
|
sessionUserID := ""
|
|
if session := rctx.Session(); session != nil {
|
|
sessionUserID = session.UserId
|
|
}
|
|
|
|
agents, err := a.ch.agentsBridge.GetAgents(sessionUserID, userID)
|
|
if err != nil {
|
|
rctx.Logger().Error("Failed to get agents from bridge",
|
|
mlog.Err(err),
|
|
mlog.String("user_id", userID),
|
|
)
|
|
return nil, model.NewAppError("GetAgents", "app.agents.get_agents.bridge_call_failed", nil, err.Error(), http.StatusInternalServerError)
|
|
}
|
|
|
|
return agents, nil
|
|
}
|
|
|
|
// GetUsersForAgents retrieves the User objects for all available agents
|
|
func (a *App) GetUsersForAgents(rctx request.CTX, userID string) ([]*model.User, *model.AppError) {
|
|
agents, appErr := a.GetAgents(rctx, userID)
|
|
if appErr != nil {
|
|
return nil, appErr
|
|
}
|
|
|
|
if len(agents) == 0 {
|
|
return []*model.User{}, nil
|
|
}
|
|
|
|
users := make([]*model.User, 0, len(agents))
|
|
for _, agent := range agents {
|
|
// Agents have a username field that corresponds to the bot user's username
|
|
user, err := a.Srv().Store().User().GetByUsername(agent.Username)
|
|
if err != nil {
|
|
rctx.Logger().Warn("Failed to get user for agent",
|
|
mlog.Err(err),
|
|
mlog.String("agent_id", agent.ID),
|
|
mlog.String("username", agent.Username),
|
|
)
|
|
continue
|
|
}
|
|
users = append(users, user)
|
|
}
|
|
|
|
return users, nil
|
|
}
|
|
|
|
// GetLLMServices retrieves all available LLM services from the bridge API
|
|
func (a *App) GetLLMServices(rctx request.CTX, userID string) ([]model.BridgeServiceInfo, *model.AppError) {
|
|
sessionUserID := ""
|
|
if session := rctx.Session(); session != nil {
|
|
sessionUserID = session.UserId
|
|
}
|
|
|
|
services, err := a.ch.agentsBridge.GetServices(sessionUserID, userID)
|
|
if err != nil {
|
|
rctx.Logger().Error("Failed to get LLM services from bridge",
|
|
mlog.Err(err),
|
|
mlog.String("user_id", userID),
|
|
)
|
|
return nil, model.NewAppError("GetLLMServices", "app.agents.get_services.bridge_call_failed", nil, err.Error(), http.StatusInternalServerError)
|
|
}
|
|
|
|
return services, nil
|
|
}
|