1- // 计算某个资源(事项/记忆档案、笔记库、知识库、存储)被频道 / 会话档案 / 智能体引用的情况 ,
1+ // 计算配置资源被频道、 会话档案、会话及其他配置资源引用的情况 ,
22// 供各资源页复刻 AgentsView 的「被引用情况」展示(见 ResourceRefs.vue)。
33import { ref } from 'vue'
44import { apiFetch } from '@/shared/api'
@@ -10,6 +10,7 @@ interface ProfileLite {
1010 name : string
1111 agentId : string | null
1212 saver : string | null
13+ intentModel : string | null
1314 notes : string | null // JSON 字符串
1415 wikis : string | null // JSON 字符串
1516 memory : string | null
@@ -31,6 +32,7 @@ interface SessionLite {
3132 autoSessionName : string
3233 agentId : string | null
3334 saver : string | null
35+ intentModel : string | null
3436 notes : string [ ] | null
3537 wikis : string [ ] | null
3638 memory : string | null
@@ -40,12 +42,16 @@ interface SessionLite {
4042/** 单个引用方。 */
4143export interface RefItem { id : string | number ; name : string ; sessionCount ?: number }
4244
43- /** 某资源的全部引用方,分频道 / 会话档案 / 会话 / 智能体四类 。 */
45+ /** 某资源的全部引用方,按引用方类型分类 。 */
4446export interface ResourceRefsValue {
4547 channels : RefItem [ ]
4648 profiles : RefItem [ ]
4749 sessions : RefItem [ ]
4850 agents : RefItem [ ]
51+ memoryProfiles : RefItem [ ]
52+ agendaProfiles : RefItem [ ]
53+ notes : RefItem [ ]
54+ wikis : RefItem [ ]
4955 total : number
5056}
5157
@@ -59,6 +65,10 @@ export interface RefMatchers {
5965 profile : ( p : ProfileLite , id : string ) => boolean
6066 session ?: ( s : SessionLite , id : string ) => boolean
6167 agent ?: ( a : any , id : string ) => boolean
68+ memoryProfile ?: ( p : any , id : string ) => boolean
69+ agendaProfile ?: ( p : any , id : string ) => boolean
70+ note ?: ( n : any , id : string ) => boolean
71+ wiki ?: ( w : any , id : string ) => boolean
6272}
6373
6474/** 会话档案的 notes/wikis 是 JSON 字符串,解析为 string[](同 SessionProfilesView 的 parseList)。 */
@@ -105,9 +115,30 @@ export function useResourceRefs() {
105115 . filter ( ( [ , a ] ) => matchers . agent ! ( a as any , id ) )
106116 . map ( ( [ aid , a ] ) => ( { id : aid , name : ( a as any ) . name || aid } ) )
107117 : [ ]
118+ const memoryProfiles = matchers . memoryProfile
119+ ? Object . entries ( store . settings . memoryProfiles || { } )
120+ . filter ( ( [ , p ] ) => matchers . memoryProfile ! ( p as any , id ) )
121+ . map ( ( [ pid , p ] ) => ( { id : pid , name : ( p as any ) . name || pid } ) )
122+ : [ ]
123+ const agendaProfiles = matchers . agendaProfile
124+ ? Object . entries ( store . settings . agendaProfiles || { } )
125+ . filter ( ( [ , p ] ) => matchers . agendaProfile ! ( p as any , id ) )
126+ . map ( ( [ pid , p ] ) => ( { id : pid , name : ( p as any ) . name || pid } ) )
127+ : [ ]
128+ const notes = matchers . note
129+ ? Object . entries ( store . settings . notes || { } )
130+ . filter ( ( [ , n ] ) => matchers . note ! ( n as any , id ) )
131+ . map ( ( [ nid , n ] ) => ( { id : nid , name : ( n as any ) . name || nid } ) )
132+ : [ ]
133+ const wikis = matchers . wiki
134+ ? Object . entries ( store . settings . wikis || { } )
135+ . filter ( ( [ , w ] ) => matchers . wiki ! ( w as any , id ) )
136+ . map ( ( [ wid , w ] ) => ( { id : wid , name : ( w as any ) . name || wid } ) )
137+ : [ ]
108138 return {
109- channels, profiles, sessions, agents,
110- total : channels . length + profiles . length + sessions . length + agents . length ,
139+ channels, profiles, sessions, agents, memoryProfiles, agendaProfiles, notes, wikis,
140+ total : channels . length + profiles . length + sessions . length + agents . length
141+ + memoryProfiles . length + agendaProfiles . length + notes . length + wikis . length ,
111142 }
112143 }
113144 }
0 commit comments