diff --git a/frontend/src/api/organization/index.ts b/frontend/src/api/organization/index.ts index 41baf4e5..86ada70e 100644 --- a/frontend/src/api/organization/index.ts +++ b/frontend/src/api/organization/index.ts @@ -74,6 +74,21 @@ export interface SharedKnowledgeBase { shared_at: string } +/** When set, this KB is visible in the space via a shared agent (read-only, no direct KB share) */ +export interface SourceFromAgentInfo { + agent_id: string + agent_name: string + /** "all" | "selected" | "none" — for showing agent's KB strategy in the drawer */ + kb_selection_mode?: string +} + +/** Item from GET /organizations/:id/shared-knowledge-bases (space-scoped list including mine and agent-carried) */ +export type OrganizationSharedKnowledgeBaseItem = SharedKnowledgeBase & { + is_mine: boolean + /** Present when the KB is from a shared agent's config (not directly shared to the space) */ + source_from_agent?: SourceFromAgentInfo +} + export interface OrganizationPreview { id: string name: string @@ -245,6 +260,9 @@ export interface SharedAgentInfo { disabled_by_me?: boolean } +/** Item from GET /organizations/:id/shared-agents (space-scoped list including mine) */ +export type OrganizationSharedAgentItem = SharedAgentInfo & { is_mine: boolean } + export interface ListAgentSharesResponse { shares: AgentShareResponse[] total: number @@ -554,6 +572,18 @@ export async function listSharedKnowledgeBases(): Promise> { + try { + const response = await get(`/api/v1/organizations/${orgId}/shared-knowledge-bases`) + return response as unknown as ApiResponse + } catch (error: any) { + return { success: false, message: error.message || 'Failed to list organization shared knowledge bases' } + } +} + /** * List knowledge bases shared to a specific organization */ @@ -612,6 +642,37 @@ export async function listSharedAgents(): Promise } } +/** Response of GET /me/resource-counts: per-org counts for sidebar (one request instead of N). */ +export interface MeResourceCountsResponse { + knowledge_bases: { by_organization: Record } + agents: { by_organization: Record } +} + +/** + * Get per-organization resource counts for list sidebar (one request). + * 全部 total is not included; frontend keeps 全部 = 我的 + 他人共享给我. + */ +export async function getMeResourceCounts(): Promise> { + try { + const response = await get('/api/v1/me/resource-counts') + return response as unknown as ApiResponse + } catch (error: any) { + return { success: false, message: error.message || 'Failed to get resource counts' } + } +} + +/** + * List all agents in an organization (including those shared by current tenant), for list page when a space is selected. + */ +export async function listOrganizationSharedAgents(orgId: string): Promise> { + try { + const response = await get(`/api/v1/organizations/${orgId}/shared-agents`) + return response as unknown as ApiResponse + } catch (error: any) { + return { success: false, message: error.message || 'Failed to list organization shared agents' } + } +} + /** 设置当前用户对某共享智能体的停用状态(仅影响本人对话下拉显示) */ export async function setSharedAgentDisabledByMe( agentId: string, diff --git a/frontend/src/components/AgentShareSettings.vue b/frontend/src/components/AgentShareSettings.vue index 150c8db9..1094654b 100644 --- a/frontend/src/components/AgentShareSettings.vue +++ b/frontend/src/components/AgentShareSettings.vue @@ -51,7 +51,7 @@ {{ org.share_count ?? 0 }} - + {{ org.agent_share_count ?? 0 }} @@ -107,7 +107,7 @@ - + {{ getOrgForShare(share.organization_id)?.agent_share_count ?? 0 }} @@ -378,7 +378,8 @@ defineExpose({ loadShares }) opacity: 0.75; } .org-meta-icon-agent { - font-size: 12px; + width: 12px; + height: 12px; opacity: 0.75; } } @@ -491,7 +492,8 @@ defineExpose({ loadShares }) opacity: 0.75; } .org-meta-icon-agent { - font-size: 12px; + width: 12px; + height: 12px; opacity: 0.75; } } diff --git a/frontend/src/components/ListSpaceSidebar.vue b/frontend/src/components/ListSpaceSidebar.vue index cb88110d..891feb3b 100644 --- a/frontend/src/components/ListSpaceSidebar.vue +++ b/frontend/src/components/ListSpaceSidebar.vue @@ -7,8 +7,9 @@