Skip to content

Commit fe3eea0

Browse files
chore: init claude.md (#1449)
1 parent c95bc78 commit fe3eea0

File tree

5 files changed

+409
-1
lines changed

5 files changed

+409
-1
lines changed

CLAUDE.md

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Repository Overview
6+
7+
This is the **UiPath Python SDK** monorepo — a Python SDK and CLI for programmatic interaction with the UiPath Cloud Platform. It publishes three packages to PyPI: `uipath`, `uipath-core`, and `uipath-platform`.
8+
9+
## Monorepo Structure
10+
11+
The repo contains three packages under `packages/`, each with its own `pyproject.toml`, `src/`, and `tests/`:
12+
13+
- **`packages/uipath`** — The main SDK package. Contains the CLI (`uipath` command), agent framework, evaluation framework, tracing/telemetry, and function utilities. This is what users `uv pip install uipath`. Entry point: `src/uipath/_cli:cli`.
14+
- **`packages/uipath-core`** — Core abstractions shared across packages: tracing, serialization, events, feature flags, error types, chat models, guardrails. Depends on OpenTelemetry and Pydantic.
15+
- **`packages/uipath-platform`** — HTTP client layer for UiPath Platform APIs. Contains service classes for orchestrator resources (assets, buckets, jobs, processes, queues), action center, context grounding, documents, connections, chat, and guardrails. Depends on `uipath-core`, httpx, and tenacity.
16+
17+
Dependency chain: `uipath``uipath-platform``uipath-core`. Local editable links are configured via `[tool.uv.sources]`.
18+
19+
## Build & Development Commands
20+
21+
All packages use **uv** for dependency management and **hatch** as the build backend.
22+
23+
```bash
24+
# Install dependencies (run from each package directory)
25+
cd packages/uipath && uv sync --all-extras
26+
27+
# The main package has a justfile (run from packages/uipath/):
28+
just lint # ruff check + custom httpx linter
29+
just format # ruff format --check
30+
just validate # lint + format
31+
just build # validate + update-agents-md + uv build
32+
just install # uv sync --all-extras
33+
```
34+
35+
### Linting & Formatting
36+
37+
```bash
38+
# From any package directory:
39+
ruff check . # Lint (rules: E, F, B, I, D; Google-style docstrings)
40+
ruff format --check . # Format check
41+
ruff check --fix . # Auto-fix lint issues
42+
ruff format . # Auto-format
43+
44+
# Custom linter (packages/uipath only):
45+
python scripts/lint_httpx_client.py
46+
```
47+
48+
Ruff config: line-length 88, double quotes, space indent. Docstring rules (D) are disabled for tests. Line length (E501) is ignored globally.
49+
50+
### Type Checking
51+
52+
```bash
53+
# From any package directory:
54+
mypy src tests
55+
```
56+
57+
Uses pydantic mypy plugin. Configured in each package's `pyproject.toml`.
58+
59+
### Running Tests
60+
61+
```bash
62+
# From any package directory:
63+
pytest # Run all tests
64+
pytest tests/cli/ # Run a test subdirectory
65+
pytest tests/cli/test_pack.py # Run a specific file
66+
pytest tests/cli/test_pack.py::test_name # Run a single test
67+
pytest -x # Stop on first failure
68+
```
69+
70+
All packages use pytest with pytest-asyncio (auto mode), pytest-httpx for HTTP mocking, pytest-cov for coverage. Tests are in `tests/` within each package.
71+
72+
### Pre-commit
73+
74+
The repo has a `.pre-commit-config.yaml` with ruff hooks (check + format).
75+
76+
## Key Architecture Details
77+
78+
### Platform Services Pattern (uipath-platform)
79+
80+
Each orchestrator resource follows a two-file pattern in `packages/uipath-platform/src/uipath/platform/orchestrator/`:
81+
- `_<resource>_service.py` — Internal service class with HTTP client logic (httpx calls, URL construction, error handling)
82+
- `<resource>.py` — Public-facing wrapper that delegates to the service class
83+
84+
Service method naming convention:
85+
- `retrieve` — get a single resource by key
86+
- `retrieve_by_[field]` — get a resource by an alternate field
87+
- `list` — get multiple resources
88+
89+
### CLI Architecture (packages/uipath)
90+
91+
The CLI uses **click** and is organized as `cli_<command>.py` files in `src/uipath/_cli/`. Heavy imports are deferred (lazy-loaded) to keep startup fast — do not add top-level imports to `_cli/__init__.py`.
92+
93+
### Agent Framework
94+
95+
`src/uipath/agent/` contains the agent runtime. Agents use Pydantic models for Input/Output schemas.
96+
97+
### Evaluation Framework
98+
99+
`src/uipath/eval/` provides evaluators (ExactMatch, Contains, JsonSimilarity, LLMJudge, Trajectory, ToolCall, Classification) for testing agent quality.
100+
101+
## Code Conventions
102+
103+
- Python 3.11+ required
104+
- Always add type annotations to functions and classes
105+
- Use Google-style docstrings for public APIs
106+
- Use `httpx` for HTTP requests (never `requests`)
107+
- Use `pydantic` for data models
108+
- Tests use pytest only (no unittest module); pytest-asyncio auto mode means async tests don't need `@pytest.mark.asyncio`

packages/uipath-core/CLAUDE.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with the `uipath-core` package.
4+
5+
## Package Purpose
6+
7+
Core abstractions shared across the UiPath Python SDK. This is the lowest-level package — it has no dependency on `uipath` or `uipath-platform`. Depends on OpenTelemetry and Pydantic.
8+
9+
## Development Commands
10+
11+
```bash
12+
cd packages/uipath-core
13+
14+
uv sync --all-extras # Install dependencies
15+
pytest # Run all tests
16+
pytest tests/tracing/ # Run a test subdirectory
17+
pytest tests/tracing/test_traced.py::test_name # Single test
18+
ruff check . # Lint
19+
ruff format --check . # Format check
20+
mypy src tests # Type check
21+
```
22+
23+
No justfile exists for this package — run commands directly.
24+
25+
## Modules
26+
27+
### `chat/` — Conversation Protocol Models
28+
Pydantic models for a hierarchical conversation event protocol (sessions, exchanges, messages, tool calls, citations, interrupts, content parts, async streams). ~45 exported classes. This defines the wire format between UI clients and agents/LLMs.
29+
30+
### `tracing/` — OpenTelemetry Instrumentation
31+
- `@traced` decorator — instruments sync/async functions with OpenTelemetry spans. Supports `recording=False` for non-recording spans, custom `input_processor`/`output_processor`, and span context propagation.
32+
- `UiPathTraceManager` — central management of tracer providers, span processors, and exporters.
33+
- `UiPathSpanUtils` — span registry and utilities.
34+
- `UiPathTraceSettings` — settings with optional `span_filter` callable.
35+
36+
### `guardrails/` — Deterministic Validation Rules
37+
Rule engine for validating input/output data with `WordRule`, `NumberRule`, `BooleanRule`, `UniversalRule`. `DeterministicGuardrailsService` evaluates rules pre- and post-execution (skipping output-dependent rules during pre-execution).
38+
39+
### `serialization/` — JSON Serialization
40+
`serialize_json()`, `serialize_object()`, `serialize_defaults()` — handles Pydantic v1/v2, dataclasses, enums, datetime, namedtuples, sets.
41+
42+
### `events/` — Event Bus
43+
`EventBus` — simple async pub/sub with `subscribe()`, `unsubscribe()`, `publish()`.
44+
45+
### `feature_flags/` — Feature Flag Registry
46+
`FeatureFlags` singleton. Sources: programmatic config (takes precedence) + `UIPATH_FEATURE_*` env vars. Supports structured types via JSON parsing.
47+
48+
### `errors/` — Exception Types
49+
`UiPathFaultedTriggerError`, `UiPathPendingTriggerError`, `ErrorCategory` enum (DEPLOYMENT, SYSTEM, UNKNOWN, USER).
50+
51+
### `triggers/` — Resume Trigger Models
52+
`UiPathResumeTrigger`, `UiPathApiTrigger`, and trigger type/name enums. Pydantic models with camelCase aliases.
53+
54+
## Test Structure
55+
56+
Tests mirror the module structure under `tests/`. The `tracing/` subdirectory has the most tests (8 files covering decorator behavior, span nesting, registry, filtering, serialization, external integration).
57+
58+
### Key Test Fixture
59+
60+
`conftest.py` provides a session-scoped `span_capture` fixture using `InMemorySpanExporter`. An autouse fixture `clear_spans_between_tests` resets it before each test. Use `span_capture.get_spans()` to assert on traced function behavior.

packages/uipath-platform/CLAUDE.md

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with the `uipath-platform` package.
4+
5+
## Package Purpose
6+
7+
HTTP client layer for UiPath Platform APIs. Provides typed service classes for all orchestrator and platform resources. Depends on `uipath-core`, httpx, tenacity, and pydantic.
8+
9+
## Development Commands
10+
11+
```bash
12+
cd packages/uipath-platform
13+
14+
uv sync --all-extras # Install dependencies
15+
pytest # Run all tests
16+
pytest tests/services/test_assets_service.py # Single test file
17+
ruff check . # Lint
18+
ruff format --check . # Format check
19+
mypy src tests # Type check
20+
```
21+
22+
No justfile exists for this package — run commands directly.
23+
24+
## Entry Point: `UiPath` Class
25+
26+
`_uipath.py` defines the main `UiPath` class that exposes all services as properties:
27+
28+
```python
29+
from uipath.platform import UiPath
30+
sdk = UiPath()
31+
sdk.assets # AssetsService
32+
sdk.attachments # AttachmentsService
33+
sdk.processes # ProcessesService
34+
sdk.buckets # BucketsService
35+
sdk.queues # QueuesService
36+
sdk.jobs # JobsService
37+
sdk.folders # FolderService
38+
sdk.tasks # TasksService (Action Center)
39+
sdk.connections # ConnectionsService
40+
sdk.context_grounding # ContextGroundingService
41+
sdk.documents # DocumentsService
42+
sdk.entities # EntitiesService
43+
sdk.llm # UiPathLlmChatService
44+
sdk.llm_openai # UiPathOpenAIService
45+
sdk.conversational # ConversationsService
46+
sdk.guardrails # GuardrailsService
47+
sdk.agenthub # AgentHubService
48+
sdk.mcp # McpService
49+
sdk.resource_catalog # ResourceCatalogService
50+
sdk.automation_tracker # AutomationTrackerService
51+
```
52+
53+
### Authentication
54+
55+
Credentials can be provided via constructor parameters or environment variables (`UIPATH_URL`, `UIPATH_ACCESS_TOKEN`). Two auth modes are supported:
56+
57+
- **User authentication** — provide `base_url` and `secret` (access token), or set them via env vars
58+
- **S2S (service-to-service)** — provide `client_id` and `client_secret` (both required together), optionally with `scope`; uses `ExternalApplicationService` internally to exchange for an access token
59+
60+
Configuration is validated with Pydantic; missing `base_url` raises `BaseUrlMissingError`, missing `secret` raises `SecretMissingError`.
61+
62+
## Service Architecture
63+
64+
### Two-File Pattern (orchestrator/)
65+
66+
Each orchestrator resource uses two files:
67+
- **`_<resource>_service.py`** — Internal service class extending `BaseService` and `FolderContext`. Contains HTTP logic (httpx calls, URL construction, retry, error handling). Methods decorated with `@traced` and `@resource_override`.
68+
- **`<resource>.py`** — Public Pydantic models for the resource.
69+
70+
### BaseService (`common/_base_service.py`)
71+
72+
All services inherit from `BaseService` which provides:
73+
- `request()` / `request_async()` — HTTP methods with tenacity-based retry (exponential backoff)
74+
- Automatic exception enrichment via `EnrichedException`
75+
- User-agent tracking and span utilities
76+
77+
### FolderContext (`common/_folder_context.py`)
78+
79+
Manages folder scoping (by `folder_key` or `folder_path`) for orchestrator operations.
80+
81+
### Method Naming Convention
82+
83+
- `retrieve` — get single resource by key
84+
- `retrieve_by_[field]` — get by alternate field
85+
- `list` — get multiple resources
86+
87+
### Sync + Async
88+
89+
Services provide both sync and async variants (e.g., `.invoke()` and `.invoke_async()`).
90+
91+
## Modules Beyond Orchestrator
92+
93+
| Module | Purpose |
94+
|--------|---------|
95+
| `action_center/` | Task management for human-in-the-loop workflows |
96+
| `agenthub/` | System agents and LLM model discovery |
97+
| `automation_tracker/` | Business Transaction Service (BTS) for Process Mining |
98+
| `chat/` | LLM gateway, conversations, throttling |
99+
| `connections/` | External connection management |
100+
| `context_grounding/` | RAG services (DeepRAG, batch RAG, ephemeral indexes) |
101+
| `documents/` | Document Understanding (IXP) |
102+
| `entities/` | Data Service entity management |
103+
| `guardrails/` | LLM output guardrails |
104+
| `resource_catalog/` | Resource discovery and metadata |
105+
| `resume_triggers/` | HITL trigger creation/reading protocols |
106+
| `common/` | Shared base classes, config, auth, retry, paging, validation |
107+
| `errors/` | Custom exceptions (`EnrichedException`, `FolderNotFoundException`, `BaseUrlMissingError`, etc.) |
108+
109+
## Test Structure
110+
111+
All tests are under `tests/services/` with one test file per service. Tests use `pytest-httpx` for HTTP mocking.
112+
113+
### Key Test Fixtures (`tests/services/conftest.py`)
114+
115+
- `base_url` — returns `"https://test.uipath.com"`
116+
- `config``UiPathApiConfig` instance
117+
- `execution_context``UiPathExecutionContext` with mocked `UIPATH_ROBOT_KEY`
118+
- `mock_env_vars` — standard mock env vars (URL, tokens, IDs)
119+
- Service-specific fixtures (e.g., `jobs_service`) built from config + execution_context

0 commit comments

Comments
 (0)