feat(agent): enhance agent and skill management features

- Updated the API to include disabled agent IDs for better management of user-specific agent visibility.
- Introduced a new function to set the disabled state for shared agents, allowing users to manage their shared agent preferences.
- Added a new Skills API to retrieve available skills, enhancing the overall agent capabilities.
- Improved the AgentSelector and related components to filter out disabled agents, ensuring a cleaner user experience.
- Updated localization strings to reflect new features and improve clarity in agent and skill management.

This update enhances the user experience by providing better control over agent visibility and introducing new skill management functionalities.
This commit is contained in:
wizardchen
2026-02-05 16:29:56 +08:00
committed by lyingbug
parent 5ab20a9148
commit c806eaf7f9
22 changed files with 1668 additions and 964 deletions
+13
View File
@@ -135,10 +135,14 @@ type AgentShareService interface {
ListSharesByAgent(ctx context.Context, agentID string) ([]*types.AgentShare, error)
ListSharesByOrganization(ctx context.Context, orgID string) ([]*types.AgentShare, error)
ListSharedAgents(ctx context.Context, userID string, currentTenantID uint64) ([]*types.SharedAgentInfo, error)
// SetSharedAgentDisabledByMe sets whether the current tenant has "disabled" this shared agent for their conversation dropdown (per-user preference).
SetSharedAgentDisabledByMe(ctx context.Context, tenantID uint64, agentID string, sourceTenantID uint64, disabled bool) error
// GetSharedAgentForUser returns the shared agent by agentID if the user has access (source tenant is resolved from share); used to resolve KB scope for @ mention.
GetSharedAgentForUser(ctx context.Context, userID string, currentTenantID uint64, agentID string) (*types.CustomAgent, error)
GetShare(ctx context.Context, shareID string) (*types.AgentShare, error)
GetShareByAgentAndOrg(ctx context.Context, agentID string, orgID string) (*types.AgentShare, error)
// GetShareByAgentIDForUser returns one share for the given agentID that the user can access, excluding source_tenant_id == excludeTenantID (e.g. current tenant to get shared-from-other only).
GetShareByAgentIDForUser(ctx context.Context, userID, agentID string, excludeTenantID uint64) (*types.AgentShare, error)
}
// AgentShareRepository defines the agent sharing repository interface
@@ -156,3 +160,12 @@ type AgentShareRepository interface {
// GetShareByAgentIDForUser returns one share for the given agentID that the user can access (user in org), excluding source_tenant_id == excludeTenantID.
GetShareByAgentIDForUser(ctx context.Context, userID, agentID string, excludeTenantID uint64) (*types.AgentShare, error)
}
// TenantDisabledSharedAgentRepository stores per-tenant "disabled" agents (hidden from conversation dropdown; own and shared)
type TenantDisabledSharedAgentRepository interface {
ListByTenantID(ctx context.Context, tenantID uint64) ([]*types.TenantDisabledSharedAgent, error)
// ListDisabledOwnAgentIDs returns agent IDs that this tenant has disabled for their own agents (source_tenant_id = tenant_id)
ListDisabledOwnAgentIDs(ctx context.Context, tenantID uint64) ([]string, error)
Add(ctx context.Context, tenantID uint64, agentID string, sourceTenantID uint64) error
Remove(ctx context.Context, tenantID uint64, agentID string, sourceTenantID uint64) error
}
+15
View File
@@ -241,6 +241,21 @@ type SharedAgentInfo struct {
SharedAt time.Time `json:"shared_at"`
SharedByUserID string `json:"shared_by_user_id,omitempty"`
SharedByUsername string `json:"shared_by_username,omitempty"`
// DisabledByMe: current tenant has hidden this shared agent from their conversation dropdown (per-user preference)
DisabledByMe bool `json:"disabled_by_me"`
}
// TenantDisabledSharedAgent records that a tenant has "disabled" a shared agent for their own dropdown
type TenantDisabledSharedAgent struct {
TenantID uint64 `json:"tenant_id" gorm:"primaryKey"`
AgentID string `json:"agent_id" gorm:"type:varchar(36);primaryKey"`
SourceTenantID uint64 `json:"source_tenant_id" gorm:"primaryKey"`
CreatedAt time.Time `json:"created_at"`
}
// TableName returns the table name for GORM
func (TenantDisabledSharedAgent) TableName() string {
return "tenant_disabled_shared_agents"
}
// ----------------------