-
Notifications
You must be signed in to change notification settings - Fork 799
Expand file tree
/
Copy pathenums.tsx
More file actions
264 lines (228 loc) · 7.71 KB
/
Copy pathenums.tsx
File metadata and controls
264 lines (228 loc) · 7.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
/**
* Enumerations used throughout the application
*/
/**
* Enumeration of agent types.
* This includes common/default agent types, but the system supports dynamic agent types from JSON uploads.
*/
export enum AgentType {
// Legacy/System agent types
HUMAN = "Human_Agent",
HR = "Hr_Agent",
MARKETING = "Marketing_Agent",
PROCUREMENT = "Procurement_Agent",
PRODUCT = "Product_Agent",
GENERIC = "Generic_Agent",
TECH_SUPPORT = "Tech_Support_Agent",
GROUP_CHAT_MANAGER = "Group_Chat_Manager",
PLANNER = "Planner_Agent",
// Common uploadable agent types
MAGENTIC_ONE = "MagenticOne",
CUSTOM = "Custom",
RAG = "RAG",
// Specific agent names (can be any name with any type)
CODER = "Coder",
EXECUTOR = "Executor",
FILE_SURFER = "FileSurfer",
WEB_SURFER = "WebSurfer",
SENSOR_SENTINEL = "SensorSentinel",
MAINTENANCE_KB_AGENT = "MaintanceKBAgent",
}
/**
* Utility functions for working with agent types
*/
export class AgentTypeUtils {
/**
* Get display name for an agent type
*/
static getDisplayName(agentType: AgentType): string {
// Convert to string first
const typeStr = String(agentType);
// Handle specific formatting for known patterns
if (typeStr.includes('_Agent')) {
return typeStr.replace('_Agent', '').replace('_', ' ');
}
// Handle camelCase and PascalCase names
return typeStr.replace(/([A-Z])/g, ' $1').replace(/^./, str => str.toUpperCase()).trim();
}
/**
* Check if an agent type is a known/default type
*/
static isKnownType(agentType: AgentType): boolean {
return Object.values(AgentType).includes(agentType);
}
/**
* Get agent type from string, with fallback to the original string
*/
static fromString(type: string): AgentType {
// First check if it's a known enum value
const enumValue = Object.values(AgentType).find(value => value === type);
if (enumValue) {
return enumValue;
}
// Return the custom type as-is
return AgentType.CUSTOM;
}
/**
* Get agent type category
*/
static getAgentCategory(agentType: AgentType): 'system' | 'magentic-one' | 'custom' | 'rag' | 'unknown' {
const typeStr = String(agentType);
// System/Legacy agents
if ([
'Human_Agent', 'Hr_Agent', 'Marketing_Agent', 'Procurement_Agent',
'Product_Agent', 'Generic_Agent', 'Tech_Support_Agent',
'Group_Chat_Manager', 'Planner_Agent'
].includes(typeStr)) {
return 'system';
}
// MagenticOne framework agents
if (typeStr === 'MagenticOne' || [
'Coder', 'Executor', 'FileSurfer', 'WebSurfer'
].includes(typeStr)) {
return 'magentic-one';
}
// RAG agents
if (typeStr === 'RAG' || typeStr.toLowerCase().includes('rag') || typeStr.toLowerCase().includes('kb')) {
return 'rag';
}
// Custom agents
if (typeStr === 'Custom') {
return 'custom';
}
return 'unknown';
}
/**
* Get icon for agent type based on category and name
*/
static getAgentIcon(agentType: AgentType, providedIcon?: string): string {
// If icon is explicitly provided, use it
if (providedIcon && providedIcon.trim()) {
return providedIcon;
}
const category = this.getAgentCategory(agentType);
const typeStr = String(agentType);
// Specific agent name mappings
const iconMap: Record<string, string> = {
'Coder': 'Terminal',
'Executor': 'MonitorCog',
'FileSurfer': 'File',
'WebSurfer': 'Globe',
'SensorSentinel': 'BookMarked',
'MaintanceKBAgent': 'Search',
};
if (iconMap[typeStr]) {
return iconMap[typeStr];
}
// Category-based defaults
switch (category) {
case 'system':
return 'Person';
case 'magentic-one':
return 'BrainCircuit';
case 'rag':
return 'Search';
case 'custom':
return 'Wrench';
default:
return 'Robot';
}
}
/**
* Validate agent configuration
*/
static validateAgent(agent: any): { isValid: boolean; errors: string[] } {
const errors: string[] = [];
if (!agent || typeof agent !== 'object') {
errors.push('Agent must be a valid object');
return { isValid: false, errors };
}
// Required fields
if (!agent.input_key || typeof agent.input_key !== 'string' || agent.input_key.trim() === '') {
errors.push('Agent input_key is required and cannot be empty');
}
if (!agent.type || typeof agent.type !== 'string' || agent.type.trim() === '') {
errors.push('Agent type is required and cannot be empty');
}
if (!agent.name || typeof agent.name !== 'string' || agent.name.trim() === '') {
errors.push('Agent name is required and cannot be empty');
}
// Optional fields validation
const optionalStringFields = ['system_message', 'description', 'icon', 'index_name'];
optionalStringFields.forEach(field => {
if (agent[field] !== undefined && typeof agent[field] !== 'string') {
errors.push(`Agent ${field} must be a string if provided`);
}
});
// Special validation for RAG agents
if (agent.type === 'RAG' && (!agent.index_name || agent.index_name.trim() === '')) {
errors.push('RAG agents must have a valid index_name specified');
}
return { isValid: errors.length === 0, errors };
}
/**
* Get all available agent types (both enum and common custom types)
*/
static getAllAvailableTypes(): AgentType[] {
return [
...Object.values(AgentType),
// Add other common types that might come from JSON uploads
];
}
}
export enum role {
user = "user",
assistant = "assistant"
}
/**
* Enumeration of possible statuses for a step.
*/
export enum StepStatus {
PLANNED = "planned",
AWAITING_FEEDBACK = "awaiting_feedback",
APPROVED = "approved",
REJECTED = "rejected",
ACTION_REQUESTED = "action_requested",
COMPLETED = "completed",
FAILED = "failed"
}
/**
* Enumeration of possible statuses for a plan.
*/
export enum PlanStatus {
CREATED = "created",
IN_PROGRESS = "in_progress",
COMPLETED = "completed",
FAILED = "failed",
CANCELED = "canceled",
APPROVED = "approved"
}
/**
* Enumeration of human feedback statuses.
*/
export enum HumanFeedbackStatus {
REQUESTED = "requested",
ACCEPTED = "accepted",
REJECTED = "rejected"
}
export enum WebsocketMessageType {
SYSTEM_MESSAGE = "system_message",
AGENT_MESSAGE = "agent_message",
AGENT_STREAM_START = "agent_stream_start",
AGENT_STREAM_END = "agent_stream_end",
AGENT_MESSAGE_STREAMING = "agent_message_streaming",
AGENT_TOOL_MESSAGE = "agent_tool_message",
PLAN_APPROVAL_REQUEST = "plan_approval_request",
PLAN_APPROVAL_RESPONSE = "plan_approval_response",
REPLAN_APPROVAL_REQUEST = "replan_approval_request",
REPLAN_APPROVAL_RESPONSE = "replan_approval_response",
USER_CLARIFICATION_REQUEST = "user_clarification_request",
USER_CLARIFICATION_RESPONSE = "user_clarification_response",
FINAL_RESULT_MESSAGE = "final_result_message",
ERROR_MESSAGE = 'error_message'
}
export enum AgentMessageType {
HUMAN_AGENT = "Human_Agent",
AI_AGENT = "AI_Agent",
SYSTEM_AGENT = "SYSTEM_AGENT"
}