Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[project]
name = "uipath-runtime"
version = "0.1.3"
version = "0.2.0"
description = "Runtime abstractions and interfaces for building agents and automation scripts in the UiPath ecosystem"
readme = { file = "README.md", content-type = "text/markdown" }
requires-python = ">=3.11"
dependencies = [
"uipath-core>=0.0.9, <0.1.0",
"uipath-core>=0.1.0, <0.2.0",
]
classifiers = [
"Intended Audience :: Developers",
Expand Down
10 changes: 10 additions & 0 deletions src/uipath/runtime/debug/bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ async def emit_breakpoint_hit(
"""Notify debugger that a breakpoint was hit."""
...

async def emit_execution_suspended(
self, runtime_result: UiPathRuntimeResult
) -> None:
"""Notify debugger that the execution has been suspended."""
...

async def emit_execution_resumed(self, resume_data: Any) -> None:
"""Notify debugger that the execution has resumed."""
...

async def emit_execution_completed(
self,
runtime_result: UiPathRuntimeResult,
Expand Down
38 changes: 20 additions & 18 deletions src/uipath/runtime/debug/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@
)
from uipath.runtime.resumable.protocols import UiPathResumeTriggerReaderProtocol
from uipath.runtime.resumable.runtime import UiPathResumableRuntime
from uipath.runtime.resumable.trigger import UiPathResumeTrigger
from uipath.runtime.resumable.trigger import (
UiPathResumeTrigger,
UiPathResumeTriggerType,
)
from uipath.runtime.schema import UiPathRuntimeSchema

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -181,20 +184,24 @@ async def _stream_and_debug(
and final_result.status == UiPathRuntimeStatus.SUSPENDED
and final_result.trigger
):
state_event = UiPathRuntimeStateEvent(
node_name="<suspended>",
payload={
"status": "suspended",
"trigger": final_result.trigger.model_dump(),
},
await self.debug_bridge.emit_execution_suspended(
final_result
)
await self.debug_bridge.emit_state_update(state_event)

resume_data: dict[str, Any] | None = None
try:
resume_data = await self._poll_trigger(
final_result.trigger, self.delegate.trigger_manager
)
if (
final_result.trigger.trigger_type
== UiPathResumeTriggerType.API
):
resume_data = (
await self.debug_bridge.wait_for_resume()
)
else:
resume_data = await self._poll_trigger(
final_result.trigger,
self.delegate.trigger_manager,
)
except UiPathDebugQuitError:
final_result = UiPathRuntimeResult(
status=UiPathRuntimeStatus.SUCCESSFUL,
Expand All @@ -203,14 +210,9 @@ async def _stream_and_debug(
execution_completed = True

if resume_data is not None:
resumed_event = UiPathRuntimeStateEvent(
node_name="<resumed>",
payload={
"status": "resumed",
"data": resume_data,
},
await self.debug_bridge.emit_execution_resumed(
resume_data
)
await self.debug_bridge.emit_state_update(resumed_event)

# Continue with resumed execution
current_input = resume_data
Expand Down
3 changes: 2 additions & 1 deletion src/uipath/runtime/resumable/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ async def _restore_resume_input(
Input to use for resume, either provided or from storage
"""
# If user provided explicit input, use it
if input:
if input is not None:
return input

# Otherwise, fetch from storage
Expand Down Expand Up @@ -146,6 +146,7 @@ async def _handle_suspension(

suspended_result = UiPathRuntimeResult(
status=UiPathRuntimeStatus.SUSPENDED,
output=result.output,
)

if result.output:
Expand Down
Loading