feat(chat): 应用目录只配置成聚合应用
This commit is contained in:
1 parent
5bef77f86c
commit
dab04d4c3e
28 files changed
+797
-138
No files matched your search
@@ -76,7 +76,7 @@ const {
|
||||
const tableHeaderColumns = computed(() => [
|
||||
{ key: 'name', label: t('admin.agent.headers.name'), align: 'left' as const },
|
||||
{ key: 'type', label: t('admin.agent.headers.type'), align: 'left' as const },
|
||||
{ key: 'category', label: t('admin.agent.headers.category'), align: 'left' as const },
|
||||
{ key: 'aggregation', label: t('admin.agent.headers.aggregation'), align: 'left' as const },
|
||||
{ key: 'config', label: t('admin.agent.headers.config'), align: 'left' as const },
|
||||
{ key: 'status', label: t('admin.agent.headers.status'), align: 'left' as const },
|
||||
{ key: 'actions', label: t('admin.agent.headers.actions'), align: 'right' as const },
|
||||
@@ -84,16 +84,14 @@ const tableHeaderColumns = computed(() => [
|
||||
|
||||
const formatAgentCode = (agent: AgentRow) => agent.agent_code || 'generic';
|
||||
|
||||
/** 分类主行:一级分类 */
|
||||
const formatAgentCategoryPrimary = (agent: AgentRow) => {
|
||||
const category = String(agent.category || '').trim();
|
||||
return category || '—';
|
||||
};
|
||||
const formatAgentAggregationPrimary = (agent: AgentRow) => (
|
||||
agent.is_aggregate ? t('admin.agent.directory.aggregateMode') : t('admin.agent.directory.normalMode')
|
||||
);
|
||||
|
||||
/** 分类副行:二级分类 */
|
||||
const formatAgentCategorySecondary = (agent: AgentRow) => {
|
||||
const subCategory = String(agent.sub_category || '').trim();
|
||||
return subCategory || '—';
|
||||
const formatAgentAggregationSecondary = (agent: AgentRow) => {
|
||||
const memberCount = Number(agent.directory_member_count || agent.directory_members?.length || 0);
|
||||
if (agent.is_aggregate) return t('admin.agent.directory.memberCount', { count: memberCount });
|
||||
return t('admin.agent.directory.normalListHint');
|
||||
};
|
||||
|
||||
/** 配置列主行:Dify App ID 或 Iframe URL 摘要。 */
|
||||
@@ -251,11 +249,15 @@ onMounted(() => {
|
||||
</td>
|
||||
<td class="px-4 py-4 align-middle">
|
||||
<div class="agent-list-cell">
|
||||
<p class="truncate text-sm text-secondary" :title="formatAgentCategoryPrimary(agent)">
|
||||
{{ formatAgentCategoryPrimary(agent) }}
|
||||
<p
|
||||
class="truncate text-sm font-medium"
|
||||
:class="agent.is_aggregate ? 'text-brand-700' : 'text-secondary'"
|
||||
:title="formatAgentAggregationPrimary(agent)"
|
||||
>
|
||||
{{ formatAgentAggregationPrimary(agent) }}
|
||||
</p>
|
||||
<p class="truncate text-xs text-muted" :title="formatAgentCategorySecondary(agent)">
|
||||
{{ formatAgentCategorySecondary(agent) }}
|
||||
<p class="truncate text-xs text-muted" :title="formatAgentAggregationSecondary(agent)">
|
||||
{{ formatAgentAggregationSecondary(agent) }}
|
||||
</p>
|
||||
</div>
|
||||
</td>
|
||||
@@ -348,6 +350,7 @@ onMounted(() => {
|
||||
:content-profile-options="contentProfileOptions"
|
||||
:runtime-providers="runtimeProviders"
|
||||
:conversation-modes="conversationModes"
|
||||
:agent-options="agents"
|
||||
:sync-content-profile-from-intent-routes="syncContentProfileFromIntentRoutes"
|
||||
@close="showFormDialog = false"
|
||||
@save="saveAgentForm"
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { ChevronDown, FileDown, Plus, Search, Trash2, X } from 'lucide-vue-next';
|
||||
import { ChevronDown, FileDown, FolderTree, Plus, Search, Trash2, X } from 'lucide-vue-next';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import type { AgentFormState, AgentGuideSummary } from '@/features/admin/types/agent.types';
|
||||
import type { AgentFormState, AgentGuideSummary, AgentRow } from '@/features/admin/types/agent.types';
|
||||
import type { ScheduleTask } from '@/shared/types/schedule.types';
|
||||
import type { AgentTypeCatalogEntry, IntentRouteOption } from '../composables/useAgentsAdminRegistry';
|
||||
import type { AdminContentProfileOption } from '@/features/admin/api/admin.api';
|
||||
@@ -38,6 +38,7 @@ const props = defineProps<{
|
||||
contentProfileOptions: AdminContentProfileOption[];
|
||||
runtimeProviders: string[];
|
||||
conversationModes: string[];
|
||||
agentOptions: AgentRow[];
|
||||
syncContentProfileFromIntentRoutes: (form: AgentFormState) => Promise<void>;
|
||||
}>();
|
||||
|
||||
@@ -57,6 +58,7 @@ const { t } = useI18n();
|
||||
const optionLabels = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');
|
||||
const advancedOpen = ref(false);
|
||||
const intentRouteSearch = ref('');
|
||||
const directoryMemberSearch = ref('');
|
||||
|
||||
const showDifyFields = computed(() => props.form.runtime_provider === 'dify' || props.form.runtime_provider === 'hybrid');
|
||||
const showIframeFields = computed(() => props.form.runtime_provider === 'iframe');
|
||||
@@ -99,6 +101,49 @@ const filteredIntentRouteOptions = computed(() => {
|
||||
));
|
||||
});
|
||||
|
||||
const directoryMemberOptions = computed(() => {
|
||||
const currentId = Number(props.form.id || 0);
|
||||
const keyword = directoryMemberSearch.value.trim().toLowerCase();
|
||||
return props.agentOptions
|
||||
.filter((agent) => Number(agent.id) !== currentId)
|
||||
.filter((agent) => {
|
||||
if (!keyword) return true;
|
||||
return [
|
||||
agent.name,
|
||||
agent.description,
|
||||
agent.category,
|
||||
agent.sub_category,
|
||||
agent.agent_code,
|
||||
].some((value) => String(value || '').toLowerCase().includes(keyword));
|
||||
});
|
||||
});
|
||||
|
||||
const selectedDirectoryMembers = computed(() => (
|
||||
props.form.directory_member_ids
|
||||
.map((id) => props.agentOptions.find((agent) => agent.id === id))
|
||||
.filter(Boolean) as AgentRow[]
|
||||
));
|
||||
|
||||
const setAggregateMode = (enabled: boolean) => {
|
||||
props.form.is_aggregate = enabled;
|
||||
if (!enabled) {
|
||||
props.form.directory_member_ids = [];
|
||||
directoryMemberSearch.value = '';
|
||||
}
|
||||
};
|
||||
|
||||
const toggleDirectoryMember = (agentId: number, checked: boolean) => {
|
||||
const current = new Set(props.form.directory_member_ids);
|
||||
if (checked) {
|
||||
current.add(agentId);
|
||||
} else {
|
||||
current.delete(agentId);
|
||||
}
|
||||
props.form.directory_member_ids = props.agentOptions
|
||||
.map((agent) => agent.id)
|
||||
.filter((id) => current.has(id) && id !== props.form.id);
|
||||
};
|
||||
|
||||
/**
|
||||
* 切换 intent_route 勾选状态。
|
||||
*/
|
||||
@@ -153,6 +198,16 @@ watch(
|
||||
},
|
||||
);
|
||||
|
||||
watch(
|
||||
() => props.form.is_aggregate,
|
||||
(enabled) => {
|
||||
if (!enabled) {
|
||||
props.form.directory_member_ids = [];
|
||||
directoryMemberSearch.value = '';
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
/**
|
||||
* 用户切换应用类型时应用 Catalog 默认值。
|
||||
*/
|
||||
@@ -297,38 +352,86 @@ const handleTrainingQuestionTypeChange = (form: AgentFormState, index: number) =
|
||||
</div>
|
||||
|
||||
<div class="col-span-1 md:col-span-2 rounded-2xl border border-default bg-surface-soft/40 p-4">
|
||||
<div class="mb-4 text-xs font-bold uppercase tracking-wider text-muted">{{ t('admin.agent.sections.category') }}</div>
|
||||
<div class="grid grid-cols-1 gap-4 md:grid-cols-3">
|
||||
<div class="space-y-2">
|
||||
<label class="text-xs font-semibold text-secondary">{{ t('admin.agent.fields.category') }}</label>
|
||||
<input
|
||||
v-model="form.category"
|
||||
type="text"
|
||||
class="w-full input-field text-sm"
|
||||
:placeholder="t('admin.agent.fields.categoryPlaceholder')"
|
||||
/>
|
||||
</div>
|
||||
<div class="space-y-2">
|
||||
<label class="text-xs font-semibold text-secondary">{{ t('admin.agent.fields.subCategory') }}</label>
|
||||
<input
|
||||
v-model="form.sub_category"
|
||||
type="text"
|
||||
class="w-full input-field text-sm"
|
||||
:placeholder="t('admin.agent.fields.subCategoryPlaceholder')"
|
||||
/>
|
||||
</div>
|
||||
<div class="space-y-2">
|
||||
<label class="text-xs font-semibold text-secondary">{{ t('admin.agent.fields.sortOrder') }}</label>
|
||||
<input
|
||||
v-model.number="form.sort_order"
|
||||
type="number"
|
||||
min="0"
|
||||
step="1"
|
||||
class="w-full input-field text-sm"
|
||||
:placeholder="t('admin.agent.fields.sortOrderPlaceholder')"
|
||||
/>
|
||||
<div class="flex flex-col gap-3 md:flex-row md:items-start md:justify-between">
|
||||
<div>
|
||||
<div class="flex items-center gap-2 text-xs font-bold uppercase tracking-wider text-muted">
|
||||
<FolderTree class="h-4 w-4" />
|
||||
{{ t('admin.agent.directory.title') }}
|
||||
</div>
|
||||
<p class="mt-1 text-sm leading-6 text-secondary">{{ t('admin.agent.directory.subtitle') }}</p>
|
||||
</div>
|
||||
<span class="rounded-full bg-white px-3 py-1 text-xs font-medium text-secondary">
|
||||
{{ t('admin.agent.directory.selectedCount', { count: selectedDirectoryMembers.length }) }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="mt-4 grid grid-cols-1 gap-3 md:grid-cols-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-xl border px-4 py-3 text-left transition"
|
||||
:class="!form.is_aggregate ? 'border-brand-500 bg-brand-50 text-brand-700' : 'border-default bg-white text-secondary hover:bg-surface-soft'"
|
||||
@click="setAggregateMode(false)"
|
||||
>
|
||||
<span class="block text-sm font-semibold">{{ t('admin.agent.directory.normalMode') }}</span>
|
||||
<span class="mt-1 block text-xs leading-5">{{ t('admin.agent.directory.normalModeHint') }}</span>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-xl border px-4 py-3 text-left transition"
|
||||
:class="form.is_aggregate ? 'border-brand-500 bg-brand-50 text-brand-700' : 'border-default bg-white text-secondary hover:bg-surface-soft'"
|
||||
@click="setAggregateMode(true)"
|
||||
>
|
||||
<span class="block text-sm font-semibold">{{ t('admin.agent.directory.aggregateMode') }}</span>
|
||||
<span class="mt-1 block text-xs leading-5">{{ t('admin.agent.directory.aggregateModeHint') }}</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<template v-if="form.is_aggregate">
|
||||
<div class="mt-4 flex items-center gap-2 rounded-xl border border-default bg-white px-3 py-2">
|
||||
<Search class="h-4 w-4 text-muted" />
|
||||
<input
|
||||
v-model="directoryMemberSearch"
|
||||
type="search"
|
||||
class="w-full bg-transparent text-sm outline-none"
|
||||
:placeholder="t('admin.agent.directory.searchPlaceholder')"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div v-if="selectedDirectoryMembers.length" class="mt-3 flex flex-wrap gap-2">
|
||||
<span
|
||||
v-for="member in selectedDirectoryMembers"
|
||||
:key="member.id"
|
||||
class="inline-flex items-center gap-1 rounded-full bg-white px-2.5 py-1 text-xs text-secondary"
|
||||
>
|
||||
{{ member.name }}
|
||||
<button type="button" @click="toggleDirectoryMember(member.id, false)">
|
||||
<X class="h-3 w-3" />
|
||||
</button>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="mt-3 max-h-64 overflow-y-auto rounded-xl border border-default bg-white p-3">
|
||||
<div v-if="directoryMemberOptions.length === 0" class="px-3 py-4 text-center text-sm text-muted">
|
||||
{{ t('admin.agent.directory.emptyOptions') }}
|
||||
</div>
|
||||
<div v-else class="grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-3">
|
||||
<label
|
||||
v-for="agent in directoryMemberOptions"
|
||||
:key="agent.id"
|
||||
class="flex cursor-pointer items-center gap-2.5 rounded-lg border border-default px-3 py-2 text-sm hover:bg-surface-soft"
|
||||
:class="form.directory_member_ids.includes(agent.id) ? 'border-brand-400 bg-brand-50' : 'bg-white'"
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
class="shrink-0 accent-brand-600"
|
||||
:checked="form.directory_member_ids.includes(agent.id)"
|
||||
@change="toggleDirectoryMember(agent.id, ($event.target as HTMLInputElement).checked)"
|
||||
/>
|
||||
<span class="min-w-0 truncate font-medium text-primary">{{ agent.name }}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<div
|
||||
|
||||
@@ -408,6 +408,7 @@ export function mapAgentRowToForm(
|
||||
welcome_message: String(agent.welcome_message || ''),
|
||||
|
||||
is_active: agent.is_active,
|
||||
is_aggregate: agent.is_aggregate === true,
|
||||
|
||||
category: String(agent.category || ''),
|
||||
|
||||
@@ -440,6 +441,9 @@ export function mapAgentRowToForm(
|
||||
tool_run_progress_enabled: agent.capabilities?.task_progress === true,
|
||||
|
||||
schedule_task_id: agent.bound_schedule_task_id ?? null,
|
||||
directory_member_ids: Array.isArray(agent.directory_members)
|
||||
? agent.directory_members.map((item) => Number(item.id)).filter((id) => Number.isInteger(id) && id > 0)
|
||||
: [],
|
||||
|
||||
};
|
||||
|
||||
@@ -518,6 +522,7 @@ export function buildAgentRegistryPayload(
|
||||
description: form.description,
|
||||
|
||||
is_active: form.is_active,
|
||||
is_aggregate: form.is_aggregate,
|
||||
|
||||
type: legacyType,
|
||||
|
||||
@@ -569,6 +574,7 @@ export function buildAgentRegistryPayload(
|
||||
handler_config,
|
||||
|
||||
extra_config,
|
||||
directory_member_ids: form.is_aggregate ? [...form.directory_member_ids] : [],
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ export interface AgentRow {
|
||||
dify_api_key?: string;
|
||||
dify_api_key_masked?: string;
|
||||
is_active: boolean;
|
||||
is_aggregate?: boolean;
|
||||
description?: string;
|
||||
type: 'api' | 'iframe';
|
||||
agent_code?: string;
|
||||
@@ -43,6 +44,18 @@ export interface AgentRow {
|
||||
bound_schedule_task_id?: number | null;
|
||||
handler_config?: Record<string, unknown> | null;
|
||||
extra_config?: Record<string, unknown>;
|
||||
directory_members?: AgentDirectoryMember[];
|
||||
directory_member_count?: number;
|
||||
}
|
||||
|
||||
export interface AgentDirectoryMember {
|
||||
id: number;
|
||||
name: string;
|
||||
description?: string | null;
|
||||
agent_code?: string | null;
|
||||
dify_app_id?: string | null;
|
||||
category?: string | null;
|
||||
sub_category?: string | null;
|
||||
}
|
||||
|
||||
export interface AgentSuggestedQuestionItem {
|
||||
@@ -94,6 +107,7 @@ export interface AgentFormState {
|
||||
suggested_questions_style: 'plain' | 'styled';
|
||||
suggested_questions: AgentSuggestedQuestionItem[];
|
||||
is_active: boolean;
|
||||
is_aggregate: boolean;
|
||||
category: string;
|
||||
sub_category: string;
|
||||
sort_order: number;
|
||||
@@ -110,6 +124,7 @@ export interface AgentFormState {
|
||||
training_summary_points_text: string;
|
||||
training_summary_checklist_text: string;
|
||||
training_question_bank: AgentTrainingQuestionFormItem[];
|
||||
directory_member_ids: number[];
|
||||
}
|
||||
|
||||
export const createEmptyTrainingQuestionForm = (): AgentTrainingQuestionFormItem => ({
|
||||
@@ -139,6 +154,7 @@ export const createEmptyAgentForm = (
|
||||
suggested_questions_style: 'plain',
|
||||
suggested_questions: [],
|
||||
is_active: true,
|
||||
is_aggregate: false,
|
||||
category: '',
|
||||
sub_category: '',
|
||||
sort_order: 0,
|
||||
@@ -164,4 +180,5 @@ export const createEmptyAgentForm = (
|
||||
training_summary_points_text: '',
|
||||
training_summary_checklist_text: '',
|
||||
training_question_bank: [],
|
||||
directory_member_ids: [],
|
||||
});
|
||||
@@ -70,6 +70,16 @@ export function useChatAgent(options: UseChatAgentOptions) {
|
||||
category?: string | null;
|
||||
sub_category?: string | null;
|
||||
sort_order?: number;
|
||||
is_aggregate?: boolean;
|
||||
directory_members?: Array<AgentRegistryFields & {
|
||||
id: number;
|
||||
name: string;
|
||||
description?: string | null;
|
||||
icon_url?: string;
|
||||
category?: string | null;
|
||||
sub_category?: string | null;
|
||||
sort_order?: number;
|
||||
}>;
|
||||
}>>([]);
|
||||
const showAgentPanel = ref(true);
|
||||
const selectedKb = ref(DEFAULT_KB);
|
||||
|
||||
@@ -32,6 +32,8 @@ export interface WorkspaceAgent {
|
||||
category?: string | null;
|
||||
sub_category?: string | null;
|
||||
sort_order?: number;
|
||||
is_aggregate?: boolean;
|
||||
directory_members?: WorkspaceAgent[];
|
||||
}
|
||||
|
||||
export interface WorkspaceQuickQuestion {
|
||||
|
||||
Reference in new issue
Block a user