|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Common Development Commands |
| 6 | + |
| 7 | +### TypeScript SDK (Main Development) |
| 8 | +```bash |
| 9 | +# Navigate to typescript-sdk directory for all TypeScript work |
| 10 | +cd typescript-sdk |
| 11 | + |
| 12 | +# Install dependencies (using pnpm) |
| 13 | +pnpm install |
| 14 | + |
| 15 | +# Build all packages |
| 16 | +pnpm build |
| 17 | + |
| 18 | +# Run development mode |
| 19 | +pnpm dev |
| 20 | + |
| 21 | +# Run linting |
| 22 | +pnpm lint |
| 23 | + |
| 24 | +# Run type checking |
| 25 | +pnpm check-types |
| 26 | + |
| 27 | +# Run tests |
| 28 | +pnpm test |
| 29 | + |
| 30 | +# Format code |
| 31 | +pnpm format |
| 32 | + |
| 33 | +# Clean build artifacts |
| 34 | +pnpm clean |
| 35 | + |
| 36 | +# Full clean build |
| 37 | +pnpm build:clean |
| 38 | +``` |
| 39 | + |
| 40 | +### Python SDK |
| 41 | +```bash |
| 42 | +# Navigate to python-sdk directory |
| 43 | +cd python-sdk |
| 44 | + |
| 45 | +# Install dependencies (using poetry) |
| 46 | +poetry install |
| 47 | + |
| 48 | +# Run tests |
| 49 | +poetry run pytest |
| 50 | + |
| 51 | +# Build distribution |
| 52 | +poetry build |
| 53 | +``` |
| 54 | + |
| 55 | +### Running Specific Integration Tests |
| 56 | +```bash |
| 57 | +# For TypeScript packages/integrations |
| 58 | +cd typescript-sdk/packages/<package-name> |
| 59 | +pnpm test |
| 60 | + |
| 61 | +# For running a single test file |
| 62 | +pnpm test path/to/test.spec.ts |
| 63 | +``` |
| 64 | + |
| 65 | +## High-Level Architecture |
| 66 | + |
| 67 | +AG-UI is an event-based protocol that standardizes agent-user interactions. The codebase is organized as a monorepo with the following structure: |
| 68 | + |
| 69 | +### Core Protocol Architecture |
| 70 | +- **Event-Driven Communication**: All agent-UI communication happens through typed events (BaseEvent and its subtypes) |
| 71 | +- **Transport Agnostic**: Protocol supports SSE, WebSockets, HTTP binary, and custom transports |
| 72 | +- **Observable Pattern**: Uses RxJS Observables for streaming agent responses |
| 73 | + |
| 74 | +### Key Abstractions |
| 75 | +1. **AbstractAgent**: Base class that all agents must implement with a `run(input: RunAgentInput) -> Observable<BaseEvent>` method |
| 76 | +2. **HttpAgent**: Standard HTTP client supporting SSE and binary protocols for connecting to agent endpoints |
| 77 | +3. **Event Types**: Lifecycle events (RUN_STARTED/FINISHED), message events (TEXT_MESSAGE_*), tool events (TOOL_CALL_*), and state management events (STATE_SNAPSHOT/DELTA) |
| 78 | + |
| 79 | +### Repository Structure |
| 80 | +- `/typescript-sdk/`: Main TypeScript implementation |
| 81 | + - `/packages/`: Core protocol packages (@ag-ui/core, @ag-ui/client, @ag-ui/encoder, @ag-ui/proto) |
| 82 | + - `/integrations/`: Framework integrations (langgraph, mastra, crewai, etc.) |
| 83 | + - `/apps/`: Example applications including the AG-UI Dojo demo viewer |
| 84 | +- `/python-sdk/`: Python implementation of the protocol |
| 85 | +- `/docs/`: Documentation site content |
| 86 | + |
| 87 | +### Integration Pattern |
| 88 | +Each framework integration follows a similar pattern: |
| 89 | +1. Implements the AbstractAgent interface |
| 90 | +2. Translates framework-specific events to AG-UI protocol events |
| 91 | +3. Provides both TypeScript client and Python server implementations |
| 92 | +4. Includes examples demonstrating key AG-UI features (agentic chat, generative UI, human-in-the-loop, etc.) |
| 93 | + |
| 94 | +### State Management |
| 95 | +- Uses STATE_SNAPSHOT for complete state representations |
| 96 | +- Uses STATE_DELTA with JSON Patch (RFC 6902) for efficient incremental updates |
| 97 | +- MESSAGES_SNAPSHOT provides conversation history |
| 98 | + |
| 99 | +### Development Workflow |
| 100 | +- Turbo is used for monorepo build orchestration |
| 101 | +- Each package has independent versioning |
| 102 | +- Integration tests demonstrate protocol compliance |
| 103 | +- The AG-UI Dojo app showcases all protocol features with live examples |
0 commit comments