Skip to content

Commit 36e1690

Browse files
mattsp1290claude
andcommitted
docs(dart): align package with Dart documentation best practices
- Add comprehensive CHANGELOG.md following Keep a Changelog format - Restructure README.md with improved sections and formatting - Add badges for GitHub, Dart SDK, and protocol - Simplify section headers and streamline content - Remove duplicate content between sections - Enhance pubspec.yaml metadata - Add repository, issue tracker, and documentation links - Add topics for better package discoverability - Update minimum SDK version to 3.3.0 - Add dartdoc comments to all public APIs - Document main library with features and examples - Add class-level documentation for client, config, and types - Include method documentation with parameters and return values - Add usage examples in documentation comments 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent dece994 commit 36e1690

File tree

10 files changed

+236
-127
lines changed

10 files changed

+236
-127
lines changed

sdks/community/dart/CHANGELOG.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Changelog
2+
3+
All notable changes to the AG-UI Dart SDK will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [0.1.0] - 2025-01-21
9+
10+
### Added
11+
- Initial release of the AG-UI Dart SDK
12+
- Core protocol implementation with full event type support
13+
- HTTP client with Server-Sent Events (SSE) streaming
14+
- Strongly-typed models for all AG-UI protocol entities
15+
- Support for tool interactions and generative UI
16+
- State management with snapshots and JSON Patch deltas (RFC 6902)
17+
- Message history tracking across multiple runs
18+
- Comprehensive error handling with typed exceptions
19+
- Cancel token support for aborting long-running operations
20+
- Environment variable configuration support
21+
- Example CLI application demonstrating key features
22+
- Integration tests validating protocol compliance
23+
24+
### Features
25+
- `AgUiClient` - Main client for AG-UI server interactions
26+
- `SimpleRunAgentInput` - Simplified input structure for common use cases
27+
- Event streaming with backpressure handling
28+
- Tool call processing and result handling
29+
- State synchronization across agent runs
30+
- Message accumulation and conversation context
31+
32+
### Known Limitations
33+
- WebSocket transport not yet implemented
34+
- Binary protocol encoding/decoding not yet supported
35+
- Advanced retry strategies planned for future release
36+
- Event caching and offline support planned for future release
37+
38+
[0.1.0]: https://github.com/mattsp1290/ag-ui/releases/tag/dart-v0.1.0

sdks/community/dart/README.md

Lines changed: 15 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
A strongly-typed Dart implementation of the AG-UI protocol for standardizing agent-user interactions through event-based communication.
44

5+
[![GitHub](https://img.shields.io/badge/GitHub-ag--ui-blue)](https://github.com/mattsp1290/ag-ui)
6+
[![Dart SDK](https://img.shields.io/badge/dart-%3E%3D3.0.0-blue)](https://dart.dev)
7+
[![Protocol](https://img.shields.io/badge/protocol-AG--UI-green)](https://github.com/mattsp1290/ag-ui/blob/main/docs/specification.md)
8+
59
## Features
610

711
### ✅ Implemented
@@ -54,8 +58,7 @@ Then run:
5458
dart pub get
5559
```
5660

57-
## Quickstart
58-
### Basic Usage
61+
## Quick Start
5962

6063
```dart
6164
import 'package:ag_ui/ag_ui.dart';
@@ -99,9 +102,9 @@ void main() async {
99102
}
100103
```
101104

102-
## Usage Examples
105+
## Usage
103106

104-
### 1. Initialize Client
107+
### Initialize Client
105108

106109
```dart
107110
import 'package:ag_ui/ag_ui.dart';
@@ -136,7 +139,7 @@ final customClient = AgUiClient(
136139
);
137140
```
138141

139-
### 2. Send User Message and Stream Response
142+
### Send User Message and Stream Response
140143

141144
```dart
142145
import 'dart:io';
@@ -182,7 +185,7 @@ Future<void> sendMessage(String userInput) async {
182185
}
183186
```
184187

185-
### 3. Handle Tool Calls
188+
### Handle Tool Calls
186189

187190
```dart
188191
import 'package:ag_ui/ag_ui.dart';
@@ -264,7 +267,7 @@ String processToolCall(ToolCall toolCall) {
264267
}
265268
```
266269

267-
### 4. Manage Conversation State
270+
### Manage Conversation State
268271

269272
```dart
270273
import 'dart:io';
@@ -342,7 +345,7 @@ class ConversationManager {
342345
}
343346
```
344347

345-
### 5. Error Handling and Cancellation
348+
### Error Handling and Cancellation
346349

347350
```dart
348351
import 'dart:async';
@@ -413,7 +416,7 @@ bool shouldCancel(BaseEvent event) {
413416
}
414417
```
415418

416-
### 6. Custom Event Processing
419+
### Custom Event Processing
417420

418421
```dart
419422
import 'dart:io';
@@ -485,7 +488,7 @@ void main() async {
485488
}
486489
```
487490

488-
### 7. Using Environment Variables
491+
### Using Environment Variables
489492

490493
```dart
491494
import 'dart:io';
@@ -515,7 +518,7 @@ AgUiClient createClientFromEnv() {
515518
// AGUI_BASE_URL=https://api.example.com AGUI_API_KEY=sk-xxx dart run main.dart
516519
```
517520

518-
### 8. Complete End-to-End Example
521+
### Complete End-to-End Example
519522

520523
```dart
521524
import 'dart:io';
@@ -649,92 +652,6 @@ Future<void> main() async {
649652
}
650653
```
651654

652-
### Handling Tool Calls
653-
654-
```dart
655-
import 'package:ag_ui/ag_ui.dart';
656-
import 'dart:convert';
657-
658-
Future<void> handleToolCalls() async {
659-
final client = AgUiClient(
660-
config: AgUiConfig(baseUrl: 'http://localhost:20203'),
661-
);
662-
663-
final messages = <Message>[];
664-
665-
// Initial user message
666-
messages.add(UserMessage(
667-
id: 'msg_1',
668-
content: 'What\'s the weather in San Francisco?',
669-
));
670-
671-
final input = RunAgentInput(
672-
threadId: 'thread_${DateTime.now().millisecondsSinceEpoch}',
673-
runId: 'run_${DateTime.now().millisecondsSinceEpoch}',
674-
messages: messages,
675-
state: {},
676-
tools: [],
677-
context: [],
678-
forwardedProps: {},
679-
);
680-
681-
await for (final event in client.streamEvents('/agent', input)) {
682-
if (event is MessagesSnapshotEvent) {
683-
// Check for tool calls in assistant messages
684-
for (final message in event.messages) {
685-
if (message is AssistantMessage && message.toolCalls != null) {
686-
for (final toolCall in message.toolCalls!) {
687-
print('Tool called: ${toolCall.function.name}');
688-
print('Arguments: ${toolCall.function.arguments}');
689-
690-
// Provide tool result
691-
final toolResult = ToolMessage(
692-
id: 'tool_msg_${DateTime.now().millisecondsSinceEpoch}',
693-
content: json.encode({'temperature': 72, 'condition': 'sunny'}),
694-
toolCallId: toolCall.id,
695-
);
696-
697-
messages.add(toolResult);
698-
699-
// Continue conversation with tool result
700-
final continuedInput = RunAgentInput(
701-
threadId: input.threadId,
702-
runId: 'run_${DateTime.now().millisecondsSinceEpoch}',
703-
messages: messages,
704-
state: {},
705-
tools: [],
706-
context: [],
707-
forwardedProps: {},
708-
);
709-
710-
// Stream the continuation
711-
await for (final nextEvent in client.streamEvents('/agent', continuedInput)) {
712-
// Handle continuation events...
713-
if (nextEvent is RunFinishedEvent) break;
714-
}
715-
}
716-
}
717-
}
718-
}
719-
}
720-
}
721-
```
722-
723-
### Environment Variables
724-
725-
Configure the client using environment variables:
726-
727-
```bash
728-
export AGUI_BASE_URL=http://your-server:20203
729-
export AGUI_API_KEY=your-api-key-here
730-
731-
dart run your_app.dart
732-
```
733-
734-
```dart
735-
// Client will automatically use environment variables
736-
final client = AgUiClient.fromEnvironment();
737-
```
738655

739656
## API Overview
740657

@@ -807,7 +724,7 @@ dart pub get
807724
dart run ag_ui_example --help
808725
```
809726

810-
## Integration Testing
727+
## Testing
811728

812729
The SDK includes comprehensive integration tests that validate compatibility with AG-UI servers. To run tests locally:
813730

@@ -881,9 +798,6 @@ Contributions are welcome! Please:
881798

882799
This SDK is part of the AG-UI Protocol project. See the [main repository](https://github.com/mattsp1290/ag-ui) for license information.
883800

884-
## Versioning
885-
886-
This SDK follows semantic versioning. Version history will be tracked in future releases.
887801

888802
## Support
889803

sdks/community/dart/lib/ag_ui.dart

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,40 @@
22
///
33
/// This library provides strongly-typed Dart models for the AG-UI protocol,
44
/// enabling agent-user interaction through a standardized event-based system.
5+
///
6+
/// ## Features
7+
///
8+
/// - **Core Protocol Support**: Full implementation of AG-UI event types
9+
/// - **HTTP Client**: Production-ready client with SSE streaming support
10+
/// - **Event Streaming**: Real-time event processing with backpressure handling
11+
/// - **Tool Interactions**: Support for tool calls with generative UI
12+
/// - **State Management**: Handle snapshots and deltas (JSON Patch RFC 6902)
13+
/// - **Type Safety**: Strongly-typed models for all protocol entities
14+
///
15+
/// ## Getting Started
16+
///
17+
/// ```dart
18+
/// import 'package:ag_ui/ag_ui.dart';
19+
///
20+
/// final client = AgUiClient(
21+
/// config: AgUiClientConfig(
22+
/// baseUrl: 'http://localhost:8000',
23+
/// ),
24+
/// );
25+
///
26+
/// final input = SimpleRunAgentInput(
27+
/// messages: [
28+
/// UserMessage(
29+
/// id: 'msg_1',
30+
/// content: 'Hello, world!',
31+
/// ),
32+
/// ],
33+
/// );
34+
///
35+
/// await for (final event in client.runAgent('agent', input)) {
36+
/// print('Event: ${event.type}');
37+
/// }
38+
/// ```
539
library ag_ui;
640

741
// Core types

0 commit comments

Comments
 (0)