|
8 | 8 | const taskPauseButton = document.getElementById("taskPauseButton"); |
9 | 9 | const taskAgentsButton = document.getElementById("taskAgentsButton"); |
10 | 10 | const taskWokFlowButton = document.getElementById("taskWokFlowButton"); |
11 | | - const taskMessageTextarea=document.getElementById("taskMessageTextarea"); |
| 11 | + const taskMessageTextarea = document.getElementById("taskMessageTextarea"); |
12 | 12 | const taskMessageAddButton = document.getElementById("taskMessageAddButton"); |
13 | 13 | const taskMessages = document.getElementById("taskMessages"); |
14 | 14 | const taskDetailsAgents = document.getElementById("taskDetailsAgents"); |
|
64 | 64 | let agentIcon = ""; |
65 | 65 |
|
66 | 66 | switch (agentName) { |
67 | | - case "MarketingAgent": |
| 67 | + case "Marketing_Agent": |
68 | 68 | agentIcon = "unknown"; |
69 | 69 | break; |
70 | | - case "HrAgent": |
| 70 | + case "Hr_Agent": |
71 | 71 | agentIcon = "hr_agent"; |
72 | 72 | break; |
73 | | - case "ExpenseBillingAgent": |
| 73 | + case "Expense_Billing_Agent": |
74 | 74 | agentIcon = "expense_billing_agent"; |
75 | 75 | break; |
76 | | - case "InvoiceReconciliationAgent": |
| 76 | + case "Invoice_Reconciliation_Agent": |
77 | 77 | agentIcon = "invoice_reconciliation_agent"; |
78 | 78 | break; |
79 | | - case "TechSupportAgent": |
| 79 | + case "Tech_Support_Agent": |
80 | 80 | agentIcon = "tech_agent"; |
81 | 81 | break; |
82 | | - case "ProcurementAgent": |
| 82 | + case "Procurement_Agent": |
83 | 83 | agentIcon = "procurement_agent"; |
84 | 84 | break; |
85 | | - case "ProductAgent": |
| 85 | + case "Product_Agent": |
86 | 86 | agentIcon = "product_agent"; |
87 | 87 | break; |
88 | | - case "GroupChatManager": |
| 88 | + case "Group_Chat_Manager": |
89 | 89 | agentIcon = "manager"; |
90 | 90 | break; |
91 | | - case "GenericAgent": |
| 91 | + case "Generic_Agent": |
92 | 92 | agentIcon = "manager"; |
93 | 93 | break; |
94 | | - case "HumanAgent": |
| 94 | + case "Human_Agent": |
95 | 95 | let userNumber = getStoredData("userNumber"); |
96 | 96 | if (userNumber == null) { |
97 | 97 | // Generate a random number between 0 and 6 |
|
116 | 116 | // Handle ISO date string format (e.g., 2025-04-25T03:01:13.093260) |
117 | 117 | // instead of Unix timestamp |
118 | 118 | const date = new Date(timestamp); |
119 | | - |
| 119 | + |
120 | 120 | // Check if date is valid |
121 | 121 | if (isNaN(date.getTime())) { |
122 | 122 | console.warn("Invalid date format:", timestamp); |
123 | 123 | return "Invalid date"; |
124 | 124 | } |
125 | | - |
| 125 | + |
126 | 126 | const options = { month: "short", day: "numeric" }; |
127 | 127 | const timeOptions = { hour: "numeric", minute: "numeric", hour12: true }; |
128 | 128 | return `${date.toLocaleDateString( |
|
136 | 136 | }; |
137 | 137 |
|
138 | 138 | const handleDisableOfActions = (status) => { |
139 | | - if(status === "completed"){ |
140 | | - taskPauseButton.disabled=true; |
141 | | - taskCancelButton.disabled=true; |
| 139 | + if (status === "completed") { |
| 140 | + taskPauseButton.disabled = true; |
| 141 | + taskCancelButton.disabled = true; |
142 | 142 | } else { |
143 | | - taskPauseButton.disabled=false; |
144 | | - taskCancelButton.disabled=false; |
| 143 | + taskPauseButton.disabled = false; |
| 144 | + taskCancelButton.disabled = false; |
145 | 145 | } |
146 | 146 | } |
147 | 147 |
|
|
173 | 173 | const apiTaskStore = JSON.parse(getStoredData("apiTask")); |
174 | 174 | handleDisableOfActions("completed") |
175 | 175 |
|
176 | | - // Explicitly disable chatbox and message button |
177 | | - taskMessageTextarea.disabled = true; |
178 | | - taskMessageTextarea.style.backgroundColor = "#efefef"; |
179 | | - taskMessageTextarea.style.cursor = 'not-allowed'; |
180 | | - |
181 | | - taskMessageAddButton.disabled = true; |
182 | | - taskMessageAddButton.style.cursor = 'not-allowed'; |
183 | | - |
184 | | - const textInputContainer = document.getElementsByClassName("text-input-container"); |
185 | | - if (textInputContainer[0]) { |
186 | | - textInputContainer[0].style.backgroundColor = '#efefef'; |
187 | | - textInputContainer[0].style.cursor = 'not-allowed'; |
188 | | - } |
189 | | - |
| 176 | + // Explicitly disable chatbox and message button |
| 177 | + taskMessageTextarea.disabled = true; |
| 178 | + taskMessageTextarea.style.backgroundColor = "#efefef"; |
| 179 | + taskMessageTextarea.style.cursor = 'not-allowed'; |
| 180 | + |
| 181 | + taskMessageAddButton.disabled = true; |
| 182 | + taskMessageAddButton.style.cursor = 'not-allowed'; |
| 183 | + |
| 184 | + const textInputContainer = document.getElementsByClassName("text-input-container"); |
| 185 | + if (textInputContainer[0]) { |
| 186 | + textInputContainer[0].style.backgroundColor = '#efefef'; |
| 187 | + textInputContainer[0].style.cursor = 'not-allowed'; |
| 188 | + } |
| 189 | + |
190 | 190 | actionStages(apiTaskStore, false); |
191 | 191 | }); |
192 | 192 | } |
|
197 | 197 | taskAgentsVsHumans = []; |
198 | 198 |
|
199 | 199 | agents.forEach((agent) => { |
200 | | - const isAvatar = agent === "HumanAgent" ? "is-human" : "is-avatar"; |
| 200 | + const isAvatar = agent === "Human_Agent" ? "is-human" : "is-avatar"; |
201 | 201 |
|
202 | 202 | taskDetailsAgents.innerHTML += ` |
203 | 203 | <figure class="image is-agent ${isAvatar} is-rounded is-32x32 m-1 has-status has-status-active"> |
204 | 204 | ${agentToIcon(agent)} |
205 | 205 | </figure> |
206 | 206 | `; |
207 | 207 |
|
208 | | - agent === "HumanAgent" |
| 208 | + agent === "Human_Agent" |
209 | 209 | ? taskAgentsVsHumans.push("Human") |
210 | 210 | : taskAgentsVsHumans.push("Agent"); |
211 | 211 | }); |
|
244 | 244 | setStoredData("apiTask", JSON.stringify(data[0])); |
245 | 245 | //const isHumanClarificationRequestNull = data?.[0]?.human_clarification_request === null |
246 | 246 | const isHumanClarificationResponseNotNull = data?.[0]?.human_clarification_response !== null; |
247 | | - const taskMessageTextareaElement =document.getElementById("taskMessageTextarea"); |
| 247 | + const taskMessageTextareaElement = document.getElementById("taskMessageTextarea"); |
248 | 248 | const taskMessageAddButton = document.getElementById("taskMessageAddButton"); |
249 | 249 | const textInputContainer = document.getElementsByClassName("text-input-container"); |
250 | | - |
| 250 | + |
251 | 251 | if (isHumanClarificationResponseNotNull) { |
252 | 252 | // Update the local state to set human_clarification_request to null |
253 | 253 | data[0].human_clarification_request = null; |
254 | 254 | console.log("Human clarification request set to null locally."); |
255 | 255 | } |
256 | 256 |
|
257 | 257 | const isHumanClarificationRequestNull = data?.[0]?.human_clarification_request === null |
258 | | - |
259 | | - if(isHumanClarificationRequestNull && taskMessageTextareaElement){ |
| 258 | + |
| 259 | + if (isHumanClarificationRequestNull && taskMessageTextareaElement) { |
260 | 260 | taskMessageTextareaElement.setAttribute('disabled', true) |
261 | 261 | taskMessageTextareaElement.style.backgroundColor = "#efefef"; |
262 | 262 | taskMessageTextareaElement.style.cursor = 'not-allowed'; |
263 | | - } |
264 | | - |
265 | | - if(isHumanClarificationRequestNull && taskMessageAddButton){ |
| 263 | + } |
| 264 | + |
| 265 | + if (isHumanClarificationRequestNull && taskMessageAddButton) { |
266 | 266 | taskMessageAddButton.setAttribute('disabled', true) |
267 | 267 | taskMessageAddButton.style.cursor = 'not-allowed'; |
268 | | - } |
269 | | - |
270 | | - if(isHumanClarificationRequestNull && textInputContainer[0]){ |
| 268 | + } |
| 269 | + |
| 270 | + if (isHumanClarificationRequestNull && textInputContainer[0]) { |
271 | 271 | textInputContainer[0].style.backgroundColor = '#efefef'; |
272 | 272 | textInputContainer[0].style.cursor = 'not-allowed'; |
273 | | - } |
274 | | - |
| 273 | + } |
| 274 | + |
275 | 275 | }) |
276 | 276 | .catch((error) => { |
277 | 277 | console.error("Error:", error); |
|
343 | 343 | `; |
344 | 344 |
|
345 | 345 | stageItem.innerHTML = ` |
346 | | - <a class="menu-stage ${ |
347 | | - stage.status |
348 | | - } ${stageRejected}" data-id="${ |
349 | | - stage.id |
350 | | - }" title="Status: ${stage.status}, Id: ${stage.id}"> |
| 346 | + <a class="menu-stage ${stage.status |
| 347 | + } ${stageRejected}" data-id="${stage.id |
| 348 | + }" title="Status: ${stage.status}, Id: ${stage.id}"> |
351 | 349 | ${stageStatusIcon} |
352 | | - <span>${taskStageCount + 1}. ${ |
353 | | - stage.action |
354 | | - }</span> |
| 350 | + <span>${taskStageCount + 1}. ${stage.action |
| 351 | + }</span> |
355 | 352 | ${stageActions} |
356 | 353 | </a> |
357 | 354 | `; |
|
422 | 419 | .then((response) => response.json()) |
423 | 420 | .then((data) => { |
424 | 421 | const toAgentName = (str) => { |
425 | | - return str.replace(/([a-z])([A-Z])/g, "$1 $2"); |
| 422 | + console.log("toAgentName", str); |
| 423 | + let new_name = str.replace(/_/g, " "); |
| 424 | + console.log("toAgentName", new_name); |
| 425 | + return new_name; |
426 | 426 | }; |
427 | 427 |
|
428 | 428 | const groupByStepId = (messages) => { |
|
444 | 444 |
|
445 | 445 | messages.forEach((message) => { |
446 | 446 | if ( |
447 | | - message.source !== "PlannerAgent" && |
448 | | - message.source !== "GroupChatManager" |
| 447 | + message.source !== "Planner_Agent" && |
| 448 | + message.source !== "Group_Chat_Manager" |
449 | 449 | ) { |
450 | 450 | filteredMessages.push(message); |
451 | 451 | } |
|
493 | 493 |
|
494 | 494 | messageItem.classList.add("media"); |
495 | 495 | const isAvatar = |
496 | | - message.source === "HumanAgent" ? "is-human" : "is-avatar"; |
| 496 | + message.source === "Human_Agent" ? "is-human" : "is-avatar"; |
497 | 497 | const isActive = |
498 | | - message.source === "PlannerAgent" |
| 498 | + message.source === "Planner_Agent" |
499 | 499 | ? "has-status-busy" |
500 | 500 | : "has-status-active"; |
501 | 501 |
|
|
519 | 519 | <div class="content"> |
520 | 520 | <div class="is-size-7 has-text-weight-medium has-text-grey is-flex"> |
521 | 521 | ${toAgentName( |
522 | | - message.source |
523 | | - )} • ${toDateTime( |
| 522 | + message.source |
| 523 | + )} • ${toDateTime( |
524 | 524 | message.timestamp |
525 | 525 | )} AI-generated content may be incorrect |
526 | 526 | </div> |
527 | 527 | <div class="notification is-light mt-1"> |
528 | 528 | ${markdownConverter.makeHtml( |
529 | | - message.content |
530 | | - )} ${approveAllStagesButton} |
| 529 | + message.content |
| 530 | + )} ${approveAllStagesButton} |
531 | 531 | </div> |
532 | 532 | </div> |
533 | 533 | </div> |
|
540 | 540 | </div> |
541 | 541 | <div class="notification is-info is-light mt-1 is-pulled-right"> |
542 | 542 | ${markdownConverter.makeHtml( |
543 | | - message.content |
544 | | - )} |
| 543 | + message.content |
| 544 | + )} |
545 | 545 | </div> |
546 | 546 | </div> |
547 | 547 | </div> |
|
554 | 554 | `; |
555 | 555 |
|
556 | 556 | const messageTemplate = |
557 | | - message.source === "HumanAgent" ? messageRight : messageLeft; |
| 557 | + message.source === "Human_Agent" ? messageRight : messageLeft; |
558 | 558 | messageItem.innerHTML = messageTemplate; |
559 | 559 | taskMessages.appendChild(messageItem); |
560 | 560 |
|
|
643 | 643 | removeClassesExcept(taskStatusTag, "tag"); |
644 | 644 | taskStatusTag.classList.add("is-info"); |
645 | 645 | const iconElement = taskPauseButton.querySelector("i"); |
646 | | - if (iconElement.classList.contains("fa-circle-play")) { |
647 | | - iconElement.classList.remove("fa-circle-play"); |
648 | | - iconElement.classList.add("fa-circle-pause"); |
649 | | - } |
| 646 | + if (iconElement.classList.contains("fa-circle-play")) { |
| 647 | + iconElement.classList.remove("fa-circle-play"); |
| 648 | + iconElement.classList.add("fa-circle-pause"); |
| 649 | + } |
650 | 650 |
|
651 | 651 | } |
652 | 652 | handleDisableOfActions(task.overall_status) |
|
797 | 797 | // Update the lastDataHash to the new hash |
798 | 798 | lastDataHash = newDataHash; |
799 | 799 |
|
800 | | - |
| 800 | + |
801 | 801 | } catch (error) { |
802 | 802 | console.error("Error in fetchLoop:", error); |
803 | 803 | } |
|
854 | 854 | charCount.textContent = "0"; |
855 | 855 | } |
856 | 856 | updateButtonImage(); |
857 | | - |
| 857 | + |
858 | 858 | notyf.success("Additional details registered in plan."); |
859 | 859 | }) |
860 | 860 | .catch((error) => { |
|
0 commit comments