feat(agent): enhance agent sharing and selection features

- Updated the AgentSelector component to improve agent selection logic, ensuring accurate representation of selected agents.
- Introduced new AgentShareSettings component for managing agent sharing with organizations, including UI for selecting organizations and displaying shared agents.
- Enhanced API interactions for sharing agents, including new methods for listing and managing agent shares.
- Improved localization support for agent sharing features across multiple languages.
- Updated various components to reflect changes in agent capabilities and sharing status, enhancing user experience and clarity.

This update strengthens the agent management features, providing users with better tools for sharing and selecting agents within organizations.
This commit is contained in:
wizardchen
2026-02-04 20:12:29 +08:00
committed by lyingbug
parent faa4e9e7b5
commit dfaf862bc0
45 changed files with 3606 additions and 477 deletions
+33 -12
View File
@@ -1,8 +1,11 @@
import { get, post, put, del, postUpload, getDown } from "../../utils/request";
// 知识库管理 API(列表、创建、获取、更新、删除、复制)
export function listKnowledgeBases() {
return get(`/api/v1/knowledge-bases`);
export function listKnowledgeBases(params?: { agent_id?: string }) {
const query = new URLSearchParams();
if (params?.agent_id) query.set('agent_id', params.agent_id);
const qs = query.toString();
return get(qs ? `/api/v1/knowledge-bases?${qs}` : '/api/v1/knowledge-bases');
}
export function createKnowledgeBase(data: {
@@ -23,8 +26,11 @@ export function createKnowledgeBase(data: {
return post(`/api/v1/knowledge-bases`, data);
}
export function getKnowledgeBaseById(id: string) {
return get(`/api/v1/knowledge-bases/${id}`);
export function getKnowledgeBaseById(id: string, options?: { agent_id?: string }) {
const query = new URLSearchParams();
if (options?.agent_id) query.set('agent_id', options.agent_id);
const qs = query.toString();
return get(qs ? `/api/v1/knowledge-bases/${id}?${qs}` : `/api/v1/knowledge-bases/${id}`);
}
export function updateKnowledgeBase(id: string, data: { name: string; description?: string; config: any }) {
@@ -81,8 +87,11 @@ export function listKnowledgeFiles(
return get(`/api/v1/knowledge-bases/${kbId}/knowledge?${qs}`);
}
export function getKnowledgeDetails(id: string) {
return get(`/api/v1/knowledge/${id}`);
export function getKnowledgeDetails(id: string, options?: { agent_id?: string }) {
const query = new URLSearchParams();
if (options?.agent_id) query.set('agent_id', options.agent_id);
const qs = query.toString();
return get(qs ? `/api/v1/knowledge/${id}?${qs}` : `/api/v1/knowledge/${id}`);
}
export function updateManualKnowledge(id: string, data: { title: string; content: string; status: string }) {
@@ -98,8 +107,10 @@ export function downKnowledgeDetails(id: string) {
}
/** @param idsQueryString - query string with ids (e.g. ids=xxx&ids=yyy) */
export function batchQueryKnowledge(idsQueryString: string, kbId?: string) {
const qs = kbId ? `${idsQueryString}&kb_id=${encodeURIComponent(kbId)}` : idsQueryString;
export function batchQueryKnowledge(idsQueryString: string, kbId?: string, agentId?: string) {
let qs = idsQueryString;
if (kbId) qs += `&kb_id=${encodeURIComponent(kbId)}`;
if (agentId) qs += `&agent_id=${encodeURIComponent(agentId)}`;
return get(`/api/v1/knowledge/batch?${qs}`);
}
@@ -267,10 +278,20 @@ export function updateFAQImportResultDisplayStatus(knowledgeBaseId: string, disp
});
}
export function searchKnowledge(keyword: string, offset = 0, limit = 20, fileTypes?: string[]) {
let url = `/api/v1/knowledge/search?keyword=${encodeURIComponent(keyword)}&offset=${offset}&limit=${limit}`;
export function searchKnowledge(
keyword: string,
offset = 0,
limit = 20,
fileTypes?: string[],
options?: { agent_id?: string }
) {
const query = new URLSearchParams();
query.set('keyword', keyword);
query.set('offset', String(offset));
query.set('limit', String(limit));
if (fileTypes && fileTypes.length > 0) {
url += `&file_types=${encodeURIComponent(fileTypes.join(','))}`;
query.set('file_types', fileTypes.join(','));
}
return get(url);
if (options?.agent_id) query.set('agent_id', options.agent_id);
return get(`/api/v1/knowledge/search?${query.toString()}`);
}