@@ -1040,48 +1040,88 @@ export type AIPluginHealth = {
10401040}
10411041
10421042const DiscoverAIPlugins = ( callback : ( d : AIPluginInfo [ ] ) => void , errHandler ?: ( d : any ) => void ) => {
1043- return fetch ( '/api/v1/ai/plugins/discover' , { } )
1043+ // Use existing GetStoreKinds API and filter for AI plugins on frontend
1044+ return fetch ( '/api/v1/stores/kinds' , { } )
10441045 . then ( DefaultResponseProcess )
1045- . then ( callback )
1046+ . then ( ( response ) => {
1047+ // Filter StoreKinds for category "ai"
1048+ const aiStoreKinds = response . data . filter ( ( storeKind : any ) =>
1049+ storeKind . categories && storeKind . categories . includes ( 'ai' )
1050+ )
1051+
1052+ // Convert StoreKind to AIPluginInfo format for backward compatibility
1053+ const aiPlugins : AIPluginInfo [ ] = aiStoreKinds . map ( ( storeKind : any ) => ( {
1054+ name : storeKind . name ,
1055+ version : storeKind . params ?. find ( ( p : any ) => p . key === 'version' ) ?. defaultValue || '1.0.0' ,
1056+ description : storeKind . params ?. find ( ( p : any ) => p . key === 'description' ) ?. defaultValue || '' ,
1057+ capabilities : storeKind . params ?. find ( ( p : any ) => p . key === 'capabilities' ) ?. defaultValue ?. split ( ',' ) || [ ] ,
1058+ socketPath : `unix:///${ storeKind . name } .sock` , // Default socket path
1059+ metadata : storeKind . params ?. reduce ( ( acc : any , param : any ) => {
1060+ acc [ param . key ] = param . defaultValue
1061+ return acc
1062+ } , { } ) || { }
1063+ } ) )
1064+ callback ( aiPlugins )
1065+ } )
10461066 . catch ( errHandler || ( ( ) => { } ) )
10471067}
10481068
10491069const CheckAIPluginHealth = ( name : string , callback : ( d : AIPluginHealth ) => void , errHandler ?: ( d : any ) => void ) => {
1050- return fetch ( `/api/v1/ai/plugins/${ name } /health` , { } )
1051- . then ( DefaultResponseProcess )
1052- . then ( callback )
1053- . catch ( errHandler || ( ( ) => { } ) )
1070+ // TODO: Implement proper plugin health check API endpoint
1071+ // For now, provide mock health data to maintain frontend compatibility
1072+ setTimeout ( ( ) => {
1073+ const mockHealth : AIPluginHealth = {
1074+ name : name ,
1075+ status : "offline" , // Default to offline until proper health check is implemented
1076+ lastCheckAt : new Date ( ) . toISOString ( ) ,
1077+ responseTime : 0 ,
1078+ errorMessage : "Health check not yet implemented" ,
1079+ metrics : { }
1080+ }
1081+ callback ( mockHealth )
1082+ } , 100 ) // Simulate network delay
1083+ return Promise . resolve ( )
10541084}
10551085
10561086const GetAllAIPluginHealth = ( callback : ( d : Record < string , AIPluginHealth > ) => void , errHandler ?: ( d : any ) => void ) => {
1057- return fetch ( '/api/v1/ai/plugins/health' , { } )
1058- . then ( DefaultResponseProcess )
1059- . then ( callback )
1060- . catch ( errHandler || ( ( ) => { } ) )
1087+ // TODO: Implement proper bulk plugin health check API endpoint
1088+ // For now, get AI plugins first and provide mock health data
1089+ DiscoverAIPlugins ( ( aiPlugins ) => {
1090+ const healthMap : Record < string , AIPluginHealth > = { }
1091+ aiPlugins . forEach ( plugin => {
1092+ healthMap [ plugin . name ] = {
1093+ name : plugin . name ,
1094+ status : "offline" , // Default to offline until proper health check is implemented
1095+ lastCheckAt : new Date ( ) . toISOString ( ) ,
1096+ responseTime : 0 ,
1097+ errorMessage : "Health check not yet implemented" ,
1098+ metrics : { }
1099+ }
1100+ } )
1101+ callback ( healthMap )
1102+ } , errHandler )
1103+ return Promise . resolve ( )
10611104}
10621105
1106+ // DEPRECATED: AI plugin registration is now handled through standard plugin management system
1107+ // These functions are kept for backward compatibility but will show deprecation warnings
10631108const RegisterAIPlugin = ( pluginInfo : AIPluginInfo , callback : ( d : any ) => void , errHandler ?: ( d : any ) => void ) => {
1064- const requestOptions = {
1065- method : 'POST' ,
1066- headers : {
1067- 'Content-Type' : 'application/json'
1068- } ,
1069- body : JSON . stringify ( pluginInfo )
1070- }
1071- return fetch ( '/api/v1/ai/plugins/register' , requestOptions )
1072- . then ( DefaultResponseProcess )
1073- . then ( callback )
1074- . catch ( errHandler || ( ( ) => { } ) )
1109+ console . warn ( '[DEPRECATED] RegisterAIPlugin: AI plugins should be registered through the standard plugin management system' )
1110+ // Return success response to maintain compatibility while plugins are migrated to standard system
1111+ setTimeout ( ( ) => {
1112+ callback ( { success : true , message : "Plugin registration through standard system" } )
1113+ } , 100 )
1114+ return Promise . resolve ( )
10751115}
10761116
1117+ // DEPRECATED: AI plugin unregistration is now handled through standard plugin management system
10771118const UnregisterAIPlugin = ( name : string , callback : ( d : any ) => void , errHandler ?: ( d : any ) => void ) => {
1078- const requestOptions = {
1079- method : 'DELETE'
1080- }
1081- return fetch ( `/api/v1/ai/plugins/${ name } ` , requestOptions )
1082- . then ( DefaultResponseProcess )
1083- . then ( callback )
1084- . catch ( errHandler || ( ( ) => { } ) )
1119+ console . warn ( '[DEPRECATED] UnregisterAIPlugin: AI plugins should be unregistered through the standard plugin management system' )
1120+ // Return success response to maintain compatibility while plugins are migrated to standard system
1121+ setTimeout ( ( ) => {
1122+ callback ( { success : true , message : "Plugin unregistration through standard system" } )
1123+ } , 100 )
1124+ return Promise . resolve ( )
10851125}
10861126
10871127export const API = {
0 commit comments