mirror of
https://github.com/langchain-ai/langgraphjs.git
synced 2026-07-21 16:45:24 -04:00
d88f29ba25
Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Christian Bromann <christian-bromann@users.noreply.github.com> Co-authored-by: Hunter Lovell <40191806+hntrl@users.noreply.github.com>
1.9 KiB
1.9 KiB
LangGraphJS Development Guide
Build & Test Commands
- Build:
pnpm build - Lint:
pnpm lint(fix withpnpm lint:fix) — uses oxlint - Format:
pnpm format(check withpnpm format:check) — uses oxfmt - Test:
pnpm test(single test:pnpm test:single /path/to/yourtest.test.ts) - Integration tests:
pnpm test:int(start deps:pnpm test:int:deps, stop:pnpm test:int:deps:down)
Code Style Guidelines
- TypeScript: Target ES2021, NodeNext modules, strict typing enabled
- Formatting: 2-space indentation, 80 char width, double quotes, semicolons required
- Naming: camelCase (variables/functions), CamelCase (classes), UPPER_CASE (constants)
- Files: lowercase .ts, tests use .test.ts or .int.test.ts for integration
- Error Handling: Custom error classes that extend BaseLangGraphError
- Imports: ES modules with file extensions, order: external deps → internal modules → types
- Project Structure: Monorepo with pnpm workspaces, libs/ for packages, examples/ for demos
- New Features: Match patterns of existing code, ensure proper testing, discuss major abstractions in issues
Library Architecture
System Layers
- Channels Layer: Base communication & state management (BaseChannel, LastValue, Topic)
- Checkpointer Layer: Persistence and state serialization across backends
- Pregel Layer: Message passing execution engine with superstep-based computation
- Graph Layer: High-level APIs for workflow definition (Graph, StateGraph)
Key Dependencies
- Channels provide state management primitives used by Pregel nodes
- Checkpointer enables persistence, serialization, and time-travel debugging
- Pregel implements the execution engine using channels for communication
- Graph builds on Pregel adding workflow semantics and node/edge definitions
- StateGraph extends Graph with shared state management capabilities