|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +`uipath-langchain` is a Python SDK that extends UiPath's Python SDK with LangChain/LangGraph integration. It implements the UiPath Runtime Protocol to deploy LangGraph agents to UiPath Cloud Platform. Requires Python 3.11+. |
| 8 | + |
| 9 | +## Common Commands |
| 10 | + |
| 11 | +```bash |
| 12 | +# Install dependencies (uses uv) |
| 13 | +uv sync --all-extras |
| 14 | + |
| 15 | +# Run all tests |
| 16 | +uv run pytest |
| 17 | + |
| 18 | +# Run a single test file |
| 19 | +uv run pytest tests/path/to/test_file.py |
| 20 | + |
| 21 | +# Run a single test |
| 22 | +uv run pytest tests/path/to/test_file.py::test_name |
| 23 | + |
| 24 | +# Lint |
| 25 | +just lint # ruff check + httpx client lint |
| 26 | +just format # ruff format check + fix |
| 27 | + |
| 28 | +# Build |
| 29 | +uv build |
| 30 | +``` |
| 31 | + |
| 32 | +## Architecture |
| 33 | + |
| 34 | +### Package: `src/uipath_langchain/` |
| 35 | + |
| 36 | +- **`runtime/`** — `UiPathLangGraphRuntime` executes LangGraph graphs within the UiPath framework. Async execution with streaming, breakpoints, and message mapping. Registered as an entry point via `uipath_langchain.runtime:register_runtime_factory`. |
| 37 | + |
| 38 | +- **`agent/`** — Agent implementation with sub-packages: |
| 39 | + - `react/` — ReAct agent pattern (agent, LLM node, router, tool node, guardrails) |
| 40 | + - `tools/` — Structured tools: context, escalation, extraction, integration, process, MCP adapters, durable interrupts. All inherit from `BaseUiPathStructuredTool`. |
| 41 | + - `guardrails/` — Input/output validation within agent execution |
| 42 | + - `multimodal/` — Multimodal invoke support |
| 43 | + - `wrappers/` — Agent decorators and wrappers |
| 44 | + |
| 45 | +- **`chat/`** — LLM provider interfaces for OpenAI, Azure OpenAI, AWS Bedrock, Google Vertex AI. Uses **lazy imports** via `__getattr__` in `__init__.py` to keep CLI startup fast. Includes `hitl.py` with the `requires_approval` decorator for human-in-the-loop workflows. Factory pattern via `chat_model_factory.py`. |
| 46 | + |
| 47 | +- **`retrievers/`** and **`vectorstores/`** — Context grounding retrieval and vector storage. |
| 48 | + |
| 49 | +- **`guardrails/`** — Top-level guardrails with actions, enums, models, and middleware. |
| 50 | + |
| 51 | +- **`_cli/`** — CLI commands (`uipath init`, `uipath new`) with project templates. |
| 52 | + |
| 53 | +- **`_tracing/`** — OpenTelemetry instrumentation. |
| 54 | + |
| 55 | +- **`_utils/`** — Shared utilities: HTTP request mixin, settings, sleep policy, environment helpers. |
| 56 | + |
| 57 | +- **`middlewares.py`** — Entry point registered as `uipath_langchain.middlewares:register_middleware`. |
| 58 | + |
| 59 | +### Entry Points (pyproject.toml) |
| 60 | + |
| 61 | +The package registers two entry points consumed by the `uipath` CLI: |
| 62 | +- `uipath.middleware` → `uipath_langchain.middlewares:register_middleware` |
| 63 | +- `uipath.runtime_factory` → `uipath_langchain.runtime:register_runtime_factory` |
| 64 | + |
| 65 | +## Key Conventions |
| 66 | + |
| 67 | +- **httpx clients**: Always use `**get_httpx_client_kwargs()` when constructing `httpx.Client()` or `httpx.AsyncClient()`. A custom AST linter (`scripts/lint_httpx_client.py`) enforces this — it runs as part of `just lint`. |
| 68 | + |
| 69 | +- **Lazy imports**: The `chat/` module defers heavy imports (langchain_openai, openai SDK) to optimize CLI startup. Use `__getattr__` pattern in `__init__.py` when adding new chat model providers. |
| 70 | + |
| 71 | +- **Naming conventions for SDK methods**: `retrieve` (single by key), `retrieve_by_[field]` (single by other field), `list` (multiple resources). |
| 72 | + |
| 73 | +- **Testing**: pytest only (no unittest). Tests in `./tests/` mirror source structure. Use pytest-asyncio for async tests (mode: auto). A circular import test (`test_no_circular_imports.py`) auto-discovers and validates all modules. |
| 74 | + |
| 75 | +- **Type annotations**: All functions and classes require type annotations. Public APIs require Google-style docstrings. |
| 76 | + |
| 77 | +- **Linting**: Ruff with rules E, F, B, I. Line length 88. mypy with pydantic plugin for type checking. |
| 78 | + |
| 79 | +- **Bedrock/Vertex imports**: `bedrock.py` and `vertex.py` have per-file E402 ignores for conditional imports. |
0 commit comments