@@ -17,12 +17,12 @@ export enum AgentType {
1717 TECH_SUPPORT = "Tech_Support_Agent" ,
1818 GROUP_CHAT_MANAGER = "Group_Chat_Manager" ,
1919 PLANNER = "Planner_Agent" ,
20-
20+
2121 // Common uploadable agent types
2222 MAGENTIC_ONE = "MagenticOne" ,
2323 CUSTOM = "Custom" ,
2424 RAG = "RAG" ,
25-
25+
2626 // Specific agent names (can be any name with any type)
2727 CODER = "Coder" ,
2828 EXECUTOR = "Executor" ,
@@ -32,10 +32,6 @@ export enum AgentType {
3232 MAINTENANCE_KB_AGENT = "MaintanceKBAgent" ,
3333}
3434
35- /**
36- * Type representing any agent type - either from the enum or a custom string
37- */
38- export type AgentTypeString = AgentType | string ;
3935
4036/**
4137 * Utility functions for working with agent types
@@ -44,46 +40,46 @@ export class AgentTypeUtils {
4440 /**
4541 * Get display name for an agent type
4642 */
47- static getDisplayName ( agentType : AgentTypeString ) : string {
43+ static getDisplayName ( agentType : AgentType ) : string {
4844 // Convert to string first
4945 const typeStr = String ( agentType ) ;
50-
46+
5147 // Handle specific formatting for known patterns
5248 if ( typeStr . includes ( '_Agent' ) ) {
5349 return typeStr . replace ( '_Agent' , '' ) . replace ( '_' , ' ' ) ;
5450 }
55-
51+
5652 // Handle camelCase and PascalCase names
5753 return typeStr . replace ( / ( [ A - Z ] ) / g, ' $1' ) . replace ( / ^ ./ , str => str . toUpperCase ( ) ) . trim ( ) ;
5854 }
5955
6056 /**
6157 * Check if an agent type is a known/default type
6258 */
63- static isKnownType ( agentType : AgentTypeString ) : boolean {
64- return Object . values ( AgentType ) . includes ( agentType as AgentType ) ;
59+ static isKnownType ( agentType : AgentType ) : boolean {
60+ return Object . values ( AgentType ) . includes ( agentType ) ;
6561 }
6662
6763 /**
6864 * Get agent type from string, with fallback to the original string
6965 */
70- static fromString ( type : string ) : AgentTypeString {
66+ static fromString ( type : string ) : AgentType {
7167 // First check if it's a known enum value
7268 const enumValue = Object . values ( AgentType ) . find ( value => value === type ) ;
7369 if ( enumValue ) {
7470 return enumValue ;
7571 }
76-
72+
7773 // Return the custom type as-is
78- return type ;
74+ return AgentType . CUSTOM ;
7975 }
8076
8177 /**
8278 * Get agent type category
8379 */
84- static getAgentCategory ( agentType : AgentTypeString ) : 'system' | 'magentic-one' | 'custom' | 'rag' | 'unknown' {
80+ static getAgentCategory ( agentType : AgentType ) : 'system' | 'magentic-one' | 'custom' | 'rag' | 'unknown' {
8581 const typeStr = String ( agentType ) ;
86-
82+
8783 // System/Legacy agents
8884 if ( [
8985 'Human_Agent' , 'Hr_Agent' , 'Marketing_Agent' , 'Procurement_Agent' ,
@@ -92,39 +88,39 @@ export class AgentTypeUtils {
9288 ] . includes ( typeStr ) ) {
9389 return 'system' ;
9490 }
95-
91+
9692 // MagenticOne framework agents
9793 if ( typeStr === 'MagenticOne' || [
9894 'Coder' , 'Executor' , 'FileSurfer' , 'WebSurfer'
9995 ] . includes ( typeStr ) ) {
10096 return 'magentic-one' ;
10197 }
102-
98+
10399 // RAG agents
104100 if ( typeStr === 'RAG' || typeStr . toLowerCase ( ) . includes ( 'rag' ) || typeStr . toLowerCase ( ) . includes ( 'kb' ) ) {
105101 return 'rag' ;
106102 }
107-
103+
108104 // Custom agents
109105 if ( typeStr === 'Custom' ) {
110106 return 'custom' ;
111107 }
112-
108+
113109 return 'unknown' ;
114110 }
115111
116112 /**
117113 * Get icon for agent type based on category and name
118114 */
119- static getAgentIcon ( agentType : AgentTypeString , providedIcon ?: string ) : string {
115+ static getAgentIcon ( agentType : AgentType , providedIcon ?: string ) : string {
120116 // If icon is explicitly provided, use it
121117 if ( providedIcon && providedIcon . trim ( ) ) {
122118 return providedIcon ;
123119 }
124-
120+
125121 const category = this . getAgentCategory ( agentType ) ;
126122 const typeStr = String ( agentType ) ;
127-
123+
128124 // Specific agent name mappings
129125 const iconMap : Record < string , string > = {
130126 'Coder' : 'Terminal' ,
@@ -134,11 +130,11 @@ export class AgentTypeUtils {
134130 'SensorSentinel' : 'BookMarked' ,
135131 'MaintanceKBAgent' : 'Search' ,
136132 } ;
137-
133+
138134 if ( iconMap [ typeStr ] ) {
139135 return iconMap [ typeStr ] ;
140136 }
141-
137+
142138 // Category-based defaults
143139 switch ( category ) {
144140 case 'system' :
@@ -159,45 +155,45 @@ export class AgentTypeUtils {
159155 */
160156 static validateAgent ( agent : any ) : { isValid : boolean ; errors : string [ ] } {
161157 const errors : string [ ] = [ ] ;
162-
158+
163159 if ( ! agent || typeof agent !== 'object' ) {
164160 errors . push ( 'Agent must be a valid object' ) ;
165161 return { isValid : false , errors } ;
166162 }
167-
163+
168164 // Required fields
169165 if ( ! agent . input_key || typeof agent . input_key !== 'string' || agent . input_key . trim ( ) === '' ) {
170166 errors . push ( 'Agent input_key is required and cannot be empty' ) ;
171167 }
172-
168+
173169 if ( ! agent . type || typeof agent . type !== 'string' || agent . type . trim ( ) === '' ) {
174170 errors . push ( 'Agent type is required and cannot be empty' ) ;
175171 }
176-
172+
177173 if ( ! agent . name || typeof agent . name !== 'string' || agent . name . trim ( ) === '' ) {
178174 errors . push ( 'Agent name is required and cannot be empty' ) ;
179175 }
180-
176+
181177 // Optional fields validation
182178 const optionalStringFields = [ 'system_message' , 'description' , 'icon' , 'index_name' ] ;
183179 optionalStringFields . forEach ( field => {
184180 if ( agent [ field ] !== undefined && typeof agent [ field ] !== 'string' ) {
185181 errors . push ( `Agent ${ field } must be a string if provided` ) ;
186182 }
187183 } ) ;
188-
184+
189185 // Special validation for RAG agents
190186 if ( agent . type === 'RAG' && ( ! agent . index_name || agent . index_name . trim ( ) === '' ) ) {
191187 errors . push ( 'RAG agents must have a valid index_name specified' ) ;
192188 }
193-
189+
194190 return { isValid : errors . length === 0 , errors } ;
195191 }
196192
197193 /**
198194 * Get all available agent types (both enum and common custom types)
199195 */
200- static getAllAvailableTypes ( ) : AgentTypeString [ ] {
196+ static getAllAvailableTypes ( ) : AgentType [ ] {
201197 return [
202198 ...Object . values ( AgentType ) ,
203199 // Add other common types that might come from JSON uploads
0 commit comments