-
Notifications
You must be signed in to change notification settings - Fork 620
add Nim SDK #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jasagiri
wants to merge
1
commit into
ag-ui-protocol:main
Choose a base branch
from
jasagiri:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
add Nim SDK #29
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# CLAUDE.md | ||
|
||
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. | ||
|
||
## Build and Development Commands | ||
|
||
### Building | ||
- `nimble build` - Compiles the project to `build/ag_ui_nim` | ||
- `nimble clean` - Removes build artifacts | ||
|
||
### Testing | ||
- `nimble test` - Runs all active test suites | ||
- Individual test commands: | ||
- `nimble testTypes` - Core type system tests | ||
- `nimble testEvents` - Event handling tests | ||
- `nimble testEncoder` - Encoder tests | ||
- `nimble testAgent` - Agent implementation tests | ||
- `nimble testHttpAgent` - HTTP agent tests | ||
- `nimble testComplexValidation` - Complex validation scenarios | ||
- `nimble testStream` - Stream processing tests | ||
- `nimble testVerify` - Event verification tests | ||
- `nimble testProto` - Protocol Buffer tests | ||
|
||
### Other Commands | ||
- `nimble docs` - Generates HTML documentation | ||
- `nimble coverage` - Generates code coverage reports | ||
- `nimble lint` - Runs style checks | ||
|
||
## Architecture Overview | ||
|
||
This is an AG-UI (Agent-UI) SDK implementation in Nim that follows an event-driven architecture with Observable/reactive patterns. | ||
|
||
### Module Structure | ||
|
||
1. **Core Module** (`src/ag_ui_nim/core/`) | ||
- `types.nim`: Core data structures (Message, Thread, State, Tool definitions) | ||
- `events.nim`: Event system with 16 standard AG-UI event types | ||
- `stream.nim`: Event stream utilities and operators | ||
- `observable.nim`: RxJS-inspired Observable implementation for async event streams | ||
- `validation.nim`: Runtime type validation for JSON data | ||
|
||
2. **Client Module** (`src/ag_ui_nim/client/`) | ||
- `agent.nim`: Abstract agent base class that all agents must inherit from | ||
- `http_agent.nim`: HTTP-based agent implementation | ||
- `verify.nim`: Event verification logic | ||
- `apply.nim`: Event application to agent state | ||
- `transform/`: SSE and chunk event transformations | ||
- `run/`: HTTP request handling for agent execution | ||
|
||
3. **Encoder Module** (`src/ag_ui_nim/encoder/`) | ||
- `encoder.nim`: Base encoder abstraction | ||
- `media_type.nim`: Content type handling | ||
- `proto.nim`: Protocol Buffer encoding support | ||
|
||
### Key Patterns | ||
|
||
- **Event Pipeline**: All agent interactions are modeled as events flowing through a pipeline | ||
- **Abstract Agent**: Agents extend `AbstractAgent` and implement the `run` method returning an event stream | ||
- **State Management**: Agents maintain conversation state with messages and thread context | ||
- **Dual Encoding**: Supports both JSON/SSE and Protocol Buffer formats | ||
- **Async-First**: All I/O operations use Nim's `Future[T]` and async/await | ||
|
||
### Development Notes | ||
|
||
- When adding new event types, update both `events.nim` and corresponding validation logic | ||
- Test files mirror source structure - add tests for any new functionality | ||
- Use `Option[T]` for nullable fields in type definitions | ||
- Event streams should handle errors gracefully and propagate them as error events | ||
- HTTP agents should respect content negotiation headers for format selection |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please remove this? Also in the root would you mind adding a gitignore for this?