Skip to content

Commit 0982f26

Browse files
feat: update runtime version
1 parent b6dfbd2 commit 0982f26

File tree

6 files changed

+90
-14
lines changed

6 files changed

+90
-14
lines changed

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[project]
22
name = "uipath"
3-
version = "2.2.35"
3+
version = "2.3.0"
44
description = "Python SDK and CLI for UiPath Platform, enabling programmatic interaction with automation services, process management, and deployment tools."
55
readme = { file = "README.md", content-type = "text/markdown" }
66
requires-python = ">=3.11"
77
dependencies = [
8-
"uipath-runtime>=0.2.7, <0.3.0",
8+
"uipath-runtime>=0.3.0, <0.4.0",
99
"uipath-core>=0.1.4, <0.2.0",
1010
"click>=8.3.1",
1111
"httpx>=0.28.1",

src/uipath/_cli/_chat/_bridge.py

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import asyncio
44
import logging
55
import os
6+
import uuid
67
from typing import Any
78
from urllib.parse import urlparse
89

@@ -12,7 +13,11 @@
1213
UiPathConversationEvent,
1314
UiPathConversationExchangeEndEvent,
1415
UiPathConversationExchangeEvent,
16+
UiPathConversationInterruptEvent,
17+
UiPathConversationInterruptStartEvent,
18+
UiPathConversationMessageEvent,
1519
)
20+
from uipath.runtime import UiPathRuntimeResult
1621
from uipath.runtime.chat import UiPathChatProtocol
1722
from uipath.runtime.context import UiPathRuntimeContext
1823

@@ -187,10 +192,81 @@ async def emit_message_event(self, message_event: Any) -> None:
187192
await self._client.emit("ConversationEvent", event_data)
188193
logger.debug("Conversation event sent successfully")
189194

195+
# Store the current message ID, used for emitting interrupt events.
196+
self._current_message_id = message_event.message_id
197+
190198
except Exception as e:
191199
logger.error(f"Error sending conversation event to WebSocket: {e}")
192200
raise RuntimeError(f"Failed to send conversation event: {e}") from e
193201

202+
async def emit_exchange_end_event(self) -> None:
203+
"""Send an exchange end event.
204+
205+
Raises:
206+
RuntimeError: If client is not connected
207+
"""
208+
if self._client is None:
209+
raise RuntimeError("WebSocket client not connected. Call connect() first.")
210+
211+
if not self._connected_event.is_set():
212+
raise RuntimeError("WebSocket client not in connected state")
213+
214+
try:
215+
exchange_end_event = UiPathConversationEvent(
216+
conversation_id=self.conversation_id,
217+
exchange=UiPathConversationExchangeEvent(
218+
exchange_id=self.exchange_id,
219+
end=UiPathConversationExchangeEndEvent(),
220+
),
221+
)
222+
223+
event_data = exchange_end_event.model_dump(
224+
mode="json", exclude_none=True, by_alias=True
225+
)
226+
227+
await self._client.emit("ConversationEvent", event_data)
228+
229+
except Exception as e:
230+
logger.error(f"Error sending conversation event to WebSocket: {e}")
231+
raise RuntimeError(f"Failed to send conversation event: {e}") from e
232+
233+
async def emit_interrupt_event(self, runtime_result: UiPathRuntimeResult):
234+
if self._client and self._connected_event.is_set():
235+
try:
236+
self._interrupt_id = str(uuid.uuid4())
237+
238+
interrupt_event = UiPathConversationEvent(
239+
conversation_id=self.conversation_id,
240+
exchange=UiPathConversationExchangeEvent(
241+
exchange_id=self.exchange_id,
242+
message=UiPathConversationMessageEvent(
243+
message_id=self._current_message_id,
244+
interrupt=UiPathConversationInterruptEvent(
245+
interrupt_id=self._interrupt_id,
246+
start=UiPathConversationInterruptStartEvent(
247+
type="coded-agent-interrupt",
248+
value=runtime_result.output,
249+
),
250+
),
251+
),
252+
),
253+
)
254+
event_data = interrupt_event.model_dump(
255+
mode="json", exclude_none=True, by_alias=True
256+
)
257+
await self._client.emit("ConversationEvent", event_data)
258+
logger.info("Interrupt event sent")
259+
except Exception as e:
260+
logger.warning(f"Error sending interrupt event: {e}")
261+
262+
async def wait_for_resume(self) -> dict[str, Any]:
263+
"""Wait for the interrupt_end event to be received.
264+
265+
Returns:
266+
Resume data from the interrupt end event
267+
"""
268+
pass
269+
194270
@property
195271
def is_connected(self) -> bool:
196272
"""Check if the WebSocket is currently connected.

src/uipath/_cli/_debug/_bridge.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
UiPathRuntimeResult,
1919
UiPathRuntimeStatus,
2020
)
21-
from uipath.runtime.debug import UiPathDebugBridgeProtocol, UiPathDebugQuitError
21+
from uipath.runtime.debug import UiPathDebugProtocol, UiPathDebugQuitError
2222
from uipath.runtime.events import UiPathRuntimeStateEvent
2323
from uipath.runtime.resumable import UiPathResumeTriggerType
2424

@@ -846,7 +846,7 @@ async def _handle_error(self, error: Any) -> None:
846846
logger.error(f"SignalR error: {error}")
847847

848848

849-
def get_remote_debug_bridge(context: UiPathRuntimeContext) -> UiPathDebugBridgeProtocol:
849+
def get_remote_debug_bridge(context: UiPathRuntimeContext) -> UiPathDebugProtocol:
850850
"""Factory to get SignalR debug bridge for remote debugging."""
851851
uipath_url = os.environ.get("UIPATH_URL")
852852
if not uipath_url or not context.job_id:
@@ -869,7 +869,7 @@ def get_remote_debug_bridge(context: UiPathRuntimeContext) -> UiPathDebugBridgeP
869869

870870
def get_debug_bridge(
871871
context: UiPathRuntimeContext, verbose: bool = True
872-
) -> UiPathDebugBridgeProtocol:
872+
) -> UiPathDebugProtocol:
873873
"""Factory to get appropriate debug bridge based on context.
874874
875875
Args:

src/uipath/_cli/cli_debug.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
UiPathRuntimeProtocol,
1111
)
1212
from uipath.runtime.chat import UiPathChatProtocol, UiPathChatRuntime
13-
from uipath.runtime.debug import UiPathDebugBridgeProtocol, UiPathDebugRuntime
13+
from uipath.runtime.debug import UiPathDebugProtocol, UiPathDebugRuntime
1414

1515
from uipath._cli._chat._bridge import get_chat_bridge
1616
from uipath._cli._debug._bridge import get_debug_bridge
@@ -136,7 +136,7 @@ async def execute_debug_runtime():
136136
delegate=runtime, chat_bridge=chat_bridge
137137
)
138138

139-
debug_bridge: UiPathDebugBridgeProtocol = get_debug_bridge(ctx)
139+
debug_bridge: UiPathDebugProtocol = get_debug_bridge(ctx)
140140

141141
debug_runtime = UiPathDebugRuntime(
142142
delegate=chat_runtime or runtime,

src/uipath/_cli/cli_run.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
)
1313
from uipath.runtime.chat import UiPathChatProtocol, UiPathChatRuntime
1414
from uipath.runtime.context import UiPathRuntimeContext
15-
from uipath.runtime.debug import UiPathDebugBridgeProtocol
15+
from uipath.runtime.debug import UiPathDebugProtocol
1616
from uipath.runtime.errors import UiPathRuntimeError
1717
from uipath.runtime.events import UiPathRuntimeStateEvent
1818

@@ -123,7 +123,7 @@ async def execute_runtime(
123123
async def debug_runtime(
124124
ctx: UiPathRuntimeContext, runtime: UiPathRuntimeProtocol
125125
) -> UiPathRuntimeResult | None:
126-
debug_bridge: UiPathDebugBridgeProtocol = ConsoleDebugBridge()
126+
debug_bridge: UiPathDebugProtocol = ConsoleDebugBridge()
127127

128128
await debug_bridge.emit_execution_started()
129129
options = UiPathStreamOptions(resume=resume)

uv.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)