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
+6 -4
View File
@@ -301,12 +301,12 @@ const emit = defineEmits<{
const dropdownStyle = ref<Record<string, string>>({});
// 使用父组件传入的 agents,避免与父组件重复请求
// 父组件已按「当前租户停用」过滤,此处直接使用
const agentsList = computed(() => props.agents ?? []);
// 内置智能体(从 API 获取,对特定 ID 使用本地化名称)
const builtinAgents = computed(() => {
// 从 API 获取的内置智能体
// 从 API 获取的内置智能体(内置无 disabled 概念,全部展示)
const apiBuiltins = agentsList.value.filter(a => a.is_builtin);
// 对特定内置智能体使用本地化名称和描述
@@ -334,8 +334,10 @@ const customAgents = computed(() => {
return agentsList.value.filter(a => !a.is_builtin);
});
// 共享给我的智能体
const sharedAgentsList = computed<SharedAgentInfo[]>(() => orgStore.sharedAgents || []);
// 共享给我的智能体(仅展示当前用户未停用的)
const sharedAgentsList = computed<SharedAgentInfo[]>(() =>
(orgStore.sharedAgents || []).filter(shared => !shared.disabled_by_me)
);
// 当前选中的来源租户(共享智能体时)
const currentAgentSourceTenantId = computed(() => settingsStore.selectedAgentSourceTenantId ?? null);
+14 -5
View File
@@ -32,8 +32,10 @@ const showAgentModeSelector = ref(false);
const agentModeButtonRef = ref<HTMLElement>();
const agentModeDropdownStyle = ref<Record<string, string>>({});
// 智能体相关状态
// 智能体相关状态(完整列表供选中态解析;对话下拉用 enabledAgents)
const agents = ref<CustomAgent[]>([]);
/** 当前租户在对话下拉中停用的「我的」智能体 ID(仅影响本租户) */
const disabledOwnAgentIds = ref<string[]>([]);
const selectedAgentId = computed({
get: () => settingsStore.selectedAgentId || BUILTIN_QUICK_ANSWER_ID,
set: (val: string) => settingsStore.selectAgent(val)
@@ -478,11 +480,18 @@ const loadAgents = async () => {
listAgents(),
orgStore.fetchSharedAgents(),
]);
agents.value = agentsRes.data || [];
const res = agentsRes as { data?: CustomAgent[]; disabled_own_agent_ids?: string[] }
agents.value = res.data || []
disabledOwnAgentIds.value = res.disabled_own_agent_ids || []
} catch (error) {
console.error('Failed to load agents:', error);
console.error('Failed to load agents:', error)
}
};
}
// 对话下拉中展示的「我的」智能体(排除当前租户已停用的)
const enabledAgents = computed(() =>
agents.value.filter(a => !disabledOwnAgentIds.value.includes(a.id))
);
const loadConversationConfig = async () => {
try {
@@ -1791,7 +1800,7 @@ onBeforeRouteUpdate((to, from, next) => {
:visible="showAgentModeSelector"
:anchorEl="agentModeButtonRef"
:currentAgentId="selectedAgentId"
:agents="agents"
:agents="enabledAgents"
@close="closeAgentModeSelector"
@select="handleSelectAgent"
/>
@@ -0,0 +1,320 @@
<template>
<aside class="list-space-sidebar">
<div class="sidebar-header-row">
<span class="sidebar-title">{{ $t('listSpaceSidebar.title') }}</span>
<div v-if="$slots.actions" class="sidebar-actions">
<slot name="actions" />
</div>
</div>
<nav class="sidebar-nav">
<!-- 全部 -->
<div
class="sidebar-item"
:class="{ active: selected === 'all' }"
@click="select('all')"
>
<div class="item-left">
<t-icon name="layers" class="item-icon" />
<span class="item-label">{{ $t('listSpaceSidebar.all') }}</span>
</div>
<span v-if="countAll !== undefined" class="item-count">{{ countAll }}</span>
</div>
<!-- 资源列表模式:我的 + 空间列表 -->
<template v-if="mode === 'resource'">
<div
class="sidebar-item"
:class="{ active: selected === 'mine' }"
@click="select('mine')"
>
<div class="item-left">
<t-icon name="user" class="item-icon" />
<span class="item-label">{{ $t('listSpaceSidebar.mine') }}</span>
</div>
<span v-if="countMine !== undefined" class="item-count">{{ countMine }}</span>
</div>
<template v-if="organizations.length">
<div class="sidebar-section">
<span class="section-title">{{ $t('listSpaceSidebar.spaces') }}</span>
</div>
<div
v-for="org in organizations"
:key="org.id"
class="sidebar-item org-item"
:class="{ active: selected === org.id }"
@click="select(org.id)"
>
<div class="item-left">
<SpaceAvatar :name="org.name" :avatar="org.avatar" size="small" class="item-avatar" />
<span class="item-label" :title="org.name">{{ org.name }}</span>
</div>
<span v-if="getOrgCount(org.id) !== undefined" class="item-count">{{ getOrgCount(org.id) }}</span>
</div>
</template>
</template>
<!-- 共享空间列表模式:我创建的 + 我加入的 -->
<template v-else>
<div
class="sidebar-item"
:class="{ active: selected === 'created' }"
@click="select('created')"
>
<div class="item-left">
<t-icon name="usergroup-add" class="item-icon" />
<span class="item-label">{{ $t('organization.createdByMe') }}</span>
</div>
<span v-if="countCreated !== undefined" class="item-count">{{ countCreated }}</span>
</div>
<div
class="sidebar-item"
:class="{ active: selected === 'joined' }"
@click="select('joined')"
>
<div class="item-left">
<t-icon name="usergroup" class="item-icon" />
<span class="item-label">{{ $t('organization.joinedByMe') }}</span>
</div>
<span v-if="countJoined !== undefined" class="item-count">{{ countJoined }}</span>
</div>
</template>
</nav>
</aside>
</template>
<script setup lang="ts">
import { ref, computed, onMounted } from 'vue'
import { Icon as TIcon } from 'tdesign-vue-next'
import SpaceAvatar from './SpaceAvatar.vue'
import { useOrganizationStore } from '@/stores/organization'
const props = withDefaults(
defineProps<{
/** resource = 知识库/智能体(全部+我的+空间列表);organization = 共享空间(全部+我创建的+我加入的) */
mode?: 'resource' | 'organization'
modelValue: string
/** 全部数量(可选) */
countAll?: number
/** 我的数量(resource 模式) */
countMine?: number
/** 各空间下的数量(resource 模式),key 为 organization_id */
countByOrg?: Record<string, number>
/** 我创建的数量(organization 模式) */
countCreated?: number
/** 我加入的数量(organization 模式) */
countJoined?: number
}>(),
{ mode: 'resource', countAll: undefined, countMine: undefined, countByOrg: () => ({}), countCreated: undefined, countJoined: undefined }
)
const emit = defineEmits<{
'update:modelValue': [value: string]
}>()
const orgStore = useOrganizationStore()
const selected = computed({
get: () => props.modelValue,
set: (v: string) => emit('update:modelValue', v)
})
const organizations = computed(() => orgStore.organizations || [])
function select(value: string) {
selected.value = value
}
function getOrgCount(orgId: string): number | undefined {
const n = props.countByOrg?.[orgId]
return n === undefined ? undefined : n
}
onMounted(() => {
orgStore.fetchOrganizations()
})
</script>
<style scoped lang="less">
// 作为整体内容区左侧一栏,与主内容同属一块区域
.list-space-sidebar {
width: 176px;
flex-shrink: 0;
background: #fafbfc;
border-right: 1px solid #e7ebf0;
padding: 12px;
display: flex;
flex-direction: column;
min-height: 0;
overflow: hidden;
}
.sidebar-header-row {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
margin-bottom: 8px;
flex-shrink: 0;
min-height: 28px;
.sidebar-title {
font-size: 13px;
font-weight: 600;
line-height: 1.4;
color: #1d2129;
}
}
.sidebar-actions {
display: flex;
align-items: center;
gap: 6px;
flex-shrink: 0;
:deep(.t-button) {
padding: 0;
min-width: 24px;
width: 24px;
height: 24px;
font-size: 12px;
gap: 0;
display: inline-flex !important;
align-items: center !important;
justify-content: center !important;
background: #f2f3f5 !important;
border: 1px solid #e5e9f2 !important;
color: #4e5969;
border-radius: 6px;
cursor: pointer;
transition: background 0.2s, border-color 0.2s, color 0.2s;
&:hover {
background: #e5e9f2 !important;
border-color: #c9cdd4 !important;
color: #1d2129;
}
}
:deep(.t-button .t-button__icon),
:deep(.t-button .btn-icon-wrapper) {
display: inline-flex;
align-items: center;
justify-content: center;
}
:deep(.t-button .t-icon + .t-button__text:not(:empty)) {
margin-left: 0;
}
:deep(.sidebar-org-icon) {
width: 16px;
height: 16px;
filter: brightness(0) saturate(100%) invert(55%);
}
:deep(.t-button:hover .sidebar-org-icon) {
filter: brightness(0) saturate(100%) invert(40%);
}
}
.sidebar-nav {
display: flex;
flex-direction: column;
gap: 4px;
flex: 1;
min-height: 0;
overflow-y: auto;
overflow-x: hidden;
}
.sidebar-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 6px 8px;
border-radius: 6px;
color: #4e5969;
cursor: pointer;
transition: all 0.2s ease;
font-size: 12px;
.item-left {
display: flex;
align-items: center;
gap: 6px;
min-width: 0;
flex: 1;
}
.item-icon {
flex-shrink: 0;
color: #86909c;
font-size: 14px;
transition: color 0.2s ease;
}
.item-avatar {
flex-shrink: 0;
}
.item-label {
flex: 1;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-weight: 400;
}
.item-count {
font-size: 12px;
color: #86909c;
font-weight: 500;
padding: 2px 5px;
border-radius: 8px;
background: #f7f9fc;
margin-left: 6px;
flex-shrink: 0;
transition: all 0.2s ease;
}
&:hover {
background: #f7f9fc;
color: #1d2129;
.item-icon {
color: #4e5969;
}
.item-count {
background: #e5e9f2;
color: #4e5969;
}
}
&.active {
background: #e6f7ec;
color: #00a870;
font-weight: 500;
.item-icon {
color: #00a870;
}
.item-count {
background: #b8f0d3;
color: #00a870;
font-weight: 600;
}
&:hover {
background: #d4f4e3;
}
}
}
.sidebar-section {
padding: 8px 8px 2px;
margin-top: 2px;
border-top: 1px solid #e7ebf0;
.section-title {
font-size: 12px;
color: #86909c;
font-weight: 600;
line-height: 1.4;
}
}
</style>