Skip to content

Commit 53c894b

Browse files
viswa-uipathclaude
andauthored
feat(cli): shared host-side governance bootstrap for run and debug (#1778)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 1652241 commit 53c894b

15 files changed

Lines changed: 2629 additions & 32 deletions

File tree

packages/uipath/pyproject.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[project]
22
name = "uipath"
3-
version = "2.12.5"
3+
version = "2.12.6"
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 = [
88
"uipath-core>=0.5.26, <0.6.0",
9-
"uipath-runtime>=0.11.5, <0.12.0",
9+
"uipath-runtime>=0.11.7, <0.12.0",
1010
"uipath-platform>=0.1.89, <0.2.0",
1111
"click>=8.3.1",
1212
"httpx>=0.28.1",
@@ -24,6 +24,7 @@ dependencies = [
2424
"mermaid-builder==0.0.3",
2525
"graphtty==0.1.8",
2626
"applicationinsights>=0.11.10",
27+
"pyyaml>=6.0, <7.0",
2728
]
2829
classifiers = [
2930
"Intended Audience :: Developers",
@@ -75,6 +76,7 @@ dev = [
7576
"mkdocs-llmstxt>=0.5.0",
7677
"inflection>=0.5.1",
7778
"types-toml>=0.10.8",
79+
"types-PyYAML>=6.0",
7880
"pytest-timeout>=2.4.0",
7981
]
8082

packages/uipath/src/uipath/_cli/_evals/_telemetry.py

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,23 @@ def __init__(self) -> None:
5757
self._eval_run_info: dict[str, dict[str, Any]] = {}
5858
self._current_eval_set_run_id: str | None = None
5959
self._current_entrypoint: str | None = None
60+
self._current_agent_type: str | None = None
6061

6162
@staticmethod
62-
def _get_agent_type(entrypoint: str) -> str:
63-
"""Determine agent type from entrypoint.
64-
65-
Args:
66-
entrypoint: The entrypoint path.
67-
68-
Returns:
69-
"LowCode" if entrypoint is "agent.json", "Coded" otherwise.
63+
def _resolve_agent_type(agent_type: str | None, entrypoint: str | None) -> str:
64+
"""Emit the historical ``"LowCode"`` / ``"Coded"`` wire values.
65+
66+
Application Insights dashboards filter on those two exact strings.
67+
When the factory supplies a modern label (e.g. ``"uipath_lowcode"``,
68+
``"uipath_coded"``) we normalize; when it supplies nothing we fall
69+
back to the pre-refactor entrypoint check (``agent.json`` ⇒
70+
low-code) so no in-flight consumer breaks.
7071
"""
72+
if agent_type is not None:
73+
if "lowcode" in agent_type.lower() or "low_code" in agent_type.lower():
74+
return "LowCode"
75+
return "Coded"
76+
# Fallback: pre-refactor entrypoint-based derivation.
7177
if entrypoint == "agent.json":
7278
return "LowCode"
7379
return "Coded"
@@ -105,21 +111,25 @@ async def _on_eval_set_run_created(self, event: EvalSetRunCreatedEvent) -> None:
105111
"eval_set_id": event.eval_set_id,
106112
"eval_set_run_id": eval_set_run_id,
107113
"entrypoint": event.entrypoint,
114+
"agent_type": event.agent_type,
108115
"no_of_evals": event.no_of_evals,
109116
"evaluator_count": len(event.evaluators),
110117
}
111118

112119
# Store for child events
113120
self._current_eval_set_run_id = eval_set_run_id
114121
self._current_entrypoint = event.entrypoint
122+
self._current_agent_type = event.agent_type
115123

116124
properties: dict[str, Any] = {
117125
"EvalSetId": event.eval_set_id,
118126
"EvalSetRunId": eval_set_run_id,
119127
"Entrypoint": event.entrypoint,
120128
"EvalCount": event.no_of_evals,
121129
"EvaluatorCount": len(event.evaluators),
122-
"AgentType": self._get_agent_type(event.entrypoint),
130+
"AgentType": self._resolve_agent_type(
131+
event.agent_type, event.entrypoint
132+
),
123133
"Runtime": "URT",
124134
}
125135

@@ -156,7 +166,9 @@ async def _on_eval_run_created(self, event: EvalRunCreatedEvent) -> None:
156166
# Add entrypoint and agent type
157167
if self._current_entrypoint:
158168
properties["Entrypoint"] = self._current_entrypoint
159-
properties["AgentType"] = self._get_agent_type(self._current_entrypoint)
169+
properties["AgentType"] = self._resolve_agent_type(
170+
self._current_agent_type, self._current_entrypoint
171+
)
160172

161173
self._enrich_properties(properties)
162174

@@ -207,7 +219,9 @@ async def _on_eval_run_updated(self, event: EvalRunUpdatedEvent) -> None:
207219

208220
if self._current_entrypoint:
209221
properties["Entrypoint"] = self._current_entrypoint
210-
properties["AgentType"] = self._get_agent_type(self._current_entrypoint)
222+
properties["AgentType"] = self._resolve_agent_type(
223+
self._current_agent_type, self._current_entrypoint
224+
)
211225

212226
if trace_id:
213227
properties["TraceId"] = trace_id
@@ -271,7 +285,9 @@ async def _on_eval_set_run_updated(self, event: EvalSetRunUpdatedEvent) -> None:
271285

272286
if set_info.get("entrypoint"):
273287
properties["Entrypoint"] = set_info["entrypoint"]
274-
properties["AgentType"] = self._get_agent_type(set_info["entrypoint"])
288+
properties["AgentType"] = self._resolve_agent_type(
289+
set_info.get("agent_type"), set_info["entrypoint"]
290+
)
275291

276292
properties["Runtime"] = "URT"
277293

@@ -299,6 +315,7 @@ async def _on_eval_set_run_updated(self, event: EvalSetRunUpdatedEvent) -> None:
299315

300316
self._current_eval_set_run_id = None
301317
self._current_entrypoint = None
318+
self._current_agent_type = None
302319

303320
except Exception as e:
304321
logger.debug(f"Error tracking eval set run updated: {e}")
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""CLI-side governance helpers.
2+
3+
Host-only glue that turns provider responses into inputs the runtime
4+
consumes. Owns the YAML → :class:`PolicyIndex` compiler (the runtime
5+
layer stays format-agnostic and only accepts a compiled index).
6+
7+
Public helpers:
8+
9+
- :func:`build_policy_index_from_yaml` — parse a YAML policy pack (as
10+
returned by :meth:`GovernancePolicyProvider.get_policy_async`) into
11+
a :class:`uipath.runtime.governance.native.PolicyIndex`.
12+
"""
13+
14+
from .yaml_index import build_policy_index_from_yaml
15+
16+
__all__ = ["build_policy_index_from_yaml"]

0 commit comments

Comments
 (0)