11"""Chat bridge implementations for conversational agents."""
22
33import asyncio
4+ import datetime
45import json
56import logging
67import os
78import uuid
9+ from datetime import timezone
810from typing import Any
911from urllib .parse import urlparse
1012
1416 UiPathConversationExchangeEvent ,
1517 UiPathConversationInterruptEvent ,
1618 UiPathConversationInterruptStartEvent ,
17- UiPathConversationMessageEvent ,
19+ UiPathConversationMessageEvent , UiPathConversationMessageStartEvent ,
1820)
1921from uipath .runtime import UiPathRuntimeResult
2022from uipath .runtime .chat import UiPathChatProtocol
@@ -244,17 +246,26 @@ async def emit_interrupt_event(self, runtime_result: UiPathRuntimeResult):
244246 try :
245247 self ._interrupt_id = str (uuid .uuid4 ())
246248
249+ value = {
250+ "toolCallId" : str (uuid .uuid4 ()),
251+ "toolName" : "test-tool" ,
252+ "inputSchema" : {"type" : "object" , "properties" : {"test-property" : {"type" :"string" }}},
253+ "inputValue" : {"test-property" : "test-input-value" },
254+ }
255+
247256 interrupt_event = UiPathConversationEvent (
248257 conversation_id = self .conversation_id ,
249258 exchange = UiPathConversationExchangeEvent (
250259 exchange_id = self .exchange_id ,
251260 message = UiPathConversationMessageEvent (
252- message_id = self ._current_message_id ,
261+ start = UiPathConversationMessageStartEvent (
262+ role = "assistant" , timestamp = (datetime .now (timezone .utc ).isoformat (timespec = "milliseconds" ).replace ("+00:00" , "Z" ))),
263+ message_id = str (uuid .uuid4 ()),
253264 interrupt = UiPathConversationInterruptEvent (
254265 interrupt_id = self ._interrupt_id ,
255266 start = UiPathConversationInterruptStartEvent (
256- type = "coded-agent-interrupt " ,
257- value = runtime_result . output ,
267+ type = "uipath_cas_tool_call_confirmation " ,
268+ value = value ,
258269 ),
259270 ),
260271 ),
@@ -278,6 +289,7 @@ async def wait_for_resume(self) -> dict[str, Any]:
278289 Returns:
279290 Resume data from the interrupt end event
280291 """
292+ #return {"decisions": [{"type": "approve"}]}
281293 return {}
282294
283295 @property
0 commit comments