Skip to content
Open
2 changes: 1 addition & 1 deletion packages/uipath-core/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "uipath-core"
version = "0.5.22"
version = "0.5.23"
Comment thread
viswa-uipath marked this conversation as resolved.
description = "UiPath Core abstractions"
readme = { file = "README.md", content-type = "text/markdown" }
requires-python = ">=3.11"
Expand Down
27 changes: 6 additions & 21 deletions packages/uipath-core/src/uipath/core/adapters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,19 @@

This package holds only the abstract contracts — concrete adapter
implementations live in framework-specific plugin packages (e.g.
``uipath-langchain``, ``uipath-openai``) that target the framework they
integrate with. Plugin packages register their concrete adapters with
the global :class:`AdapterRegistry` via the
``uipath.governance.adapters`` entry-point group.
``uipath-langchain``, ``uipath-openai``). A framework plugin is the one
that knows its own native wiring seam (callback handler list, hook
registry, …) and installs governance there directly; uipath-core only
defines the protocol an evaluator must satisfy.

Public surface:

- :class:`BaseAdapter` – abstract base every adapter inherits from.
- :class:`GovernedAgentBase` – proxy base for governed agent wrappers.
- :class:`EvaluatorProtocol` – structural protocol the adapter expects
from any policy evaluator.
- :class:`AdapterRegistry` – ordered list of adapters that resolves
the first match for a given agent.
- :class:`EvaluatorProtocol` – structural protocol the framework
plugin expects from any policy evaluator.
"""

from .base import BaseAdapter, GovernedAgentBase
from .evaluator import EvaluatorProtocol
from .registry import (
AdapterRegistry,
get_adapter_registry,
reset_adapter_registry,
)

__all__ = [
"BaseAdapter",
"GovernedAgentBase",
"EvaluatorProtocol",
"AdapterRegistry",
"get_adapter_registry",
"reset_adapter_registry",
]
116 changes: 0 additions & 116 deletions packages/uipath-core/src/uipath/core/adapters/base.py

This file was deleted.

31 changes: 17 additions & 14 deletions packages/uipath-core/src/uipath/core/adapters/evaluator.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""Structural contract for the policy evaluator an adapter talks to.
"""Structural contract for the policy evaluator a framework plugin talks to.

Framework adapters call into a policy evaluator at each lifecycle hook.
Framework plugins call into a policy evaluator at each lifecycle hook.
Concrete evaluator implementations (the native runtime evaluator, a
Microsoft AGT bridge, a composite, …) live in packages outside
``uipath-core`` — adapters depend only on this structural protocol so
``uipath-core`` — plugins depend only on this structural protocol so
they can be swapped against any of them without code change.

``EvaluatorProtocol`` is a :class:`typing.Protocol` so any class whose
Expand All @@ -15,15 +15,18 @@

from typing import Any, Protocol, runtime_checkable

from uipath.core.governance.models import AuditRecord


@runtime_checkable
class EvaluatorProtocol(Protocol):
"""Structural protocol an adapter expects from a policy evaluator.
"""Structural protocol a framework plugin expects from a policy evaluator.

Return types are intentionally :class:`typing.Any`: the concrete
audit record shape lives in the plugin package that owns the
evaluator and the policy model. Adapters in that package cast the
return value back to the concrete type they know.
Every ``evaluate_*`` method returns an :class:`AuditRecord` — the
per-hook audit envelope holding the per-rule
:class:`RuleEvaluation` list, the final action, and the trace /
agent metadata. Callers get a typed result; no downcasting is
required.
"""

def evaluate_before_agent(
Expand All @@ -34,7 +37,7 @@ def evaluate_before_agent(
trace_id: str,
model_name: str = "",
**kwargs: Any,
) -> Any:
) -> AuditRecord:
"""Evaluate BEFORE_AGENT rules."""
...

Expand All @@ -45,7 +48,7 @@ def evaluate_after_agent(
runtime_id: str,
trace_id: str,
**kwargs: Any,
) -> Any:
) -> AuditRecord:
"""Evaluate AFTER_AGENT rules."""
...

Expand All @@ -58,7 +61,7 @@ def evaluate_before_model(
messages: list[dict[str, Any]] | None = None,
model_name: str = "",
**kwargs: Any,
) -> Any:
) -> AuditRecord:
"""Evaluate BEFORE_MODEL rules."""
...

Expand All @@ -69,7 +72,7 @@ def evaluate_after_model(
runtime_id: str,
trace_id: str,
**kwargs: Any,
) -> Any:
) -> AuditRecord:
"""Evaluate AFTER_MODEL rules."""
...

Expand All @@ -82,7 +85,7 @@ def evaluate_tool_call(
trace_id: str,
session_state: dict[str, Any] | None = None,
**kwargs: Any,
) -> Any:
) -> AuditRecord:
"""Evaluate TOOL_CALL rules."""
...

Expand All @@ -94,6 +97,6 @@ def evaluate_after_tool(
runtime_id: str,
trace_id: str,
**kwargs: Any,
) -> Any:
) -> AuditRecord:
"""Evaluate AFTER_TOOL rules."""
...
Loading