You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/a2a_dart/DESIGN.md
+4-16Lines changed: 4 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -138,38 +138,26 @@ Example `A2AClient` usage:
138
138
```dart
139
139
final client = A2AClient(url: 'https://example.com/a2a', transport: SseTransport(url: 'https://example.com/a2a'));
140
140
141
-
// For a simple request-response
141
+
// Create a task
142
142
final task = await client.createTask(Message(
143
143
messageId: '1',
144
144
role: Role.user,
145
145
parts: [const TextPart(text: 'Hello, agent!')],
146
146
));
147
147
148
-
// For a streaming response
149
-
final stream = client.messageStream(Message(
150
-
role: 'user',
151
-
parts: [TextPart(text: 'Tell me a story.')],
152
-
));
153
-
148
+
// Execute the task and get a stream of events
149
+
final stream = client.executeTask(task.id);
154
150
await for (final event in stream) {
155
151
// process events
156
152
}
157
-
158
-
print(task.status.state);
159
-
160
-
// To execute the task and get a stream of messages:
161
-
final stream = client.executeTask(task.id);
162
-
await for (final message in stream) {
163
-
// process messages
164
-
}
165
153
```
166
154
167
155
## 6. Server Framework
168
156
169
157
The server framework will provide the building blocks for creating A2A-compliant agents in Dart.
170
158
171
159
-**`A2AServer`**: A top-level class that listens for incoming HTTP requests and routes them to the appropriate `RequestHandler`.
172
-
-**`RequestHandler`**: An interface for handling specific A2A methods. Developers will implement this interface to define their agent's behavior.
160
+
-**`RequestHandler`**: An interface for handling specific A2A methods. Developers will implement this interface to define their agent's behavior. The `handle` method returns a `HandlerResult` which can be a `SingleResult` for a single response or a `StreamResult` for a streaming response.
173
161
-**`TaskManager`**: A class responsible for managing the lifecycle of tasks.
Copy file name to clipboardExpand all lines: packages/a2a_dart/GEMINI.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ The `A2AClient` provides a simple and convenient way to interact with an A2A ser
10
10
11
11
## Server
12
12
13
-
The `A2AServer` provides a flexible and extensible framework for building A2A agents. It is built on top of the `shelf` package and uses a request handler pipeline to process incoming requests. Each `RequestHandler` is responsible for a single RPC method, making it easy to add new functionality to the server.
13
+
The `A2AServer` provides a flexible and extensible framework for building A2A agents. It is built on top of the `shelf` package and uses a request handler pipeline to process incoming requests. Each `RequestHandler` is responsible for a single RPC method, making it easy to add new functionality to the server. The `handle` method of a `RequestHandler` returns a `HandlerResult`, which can be a `SingleResult` for a single response or a `StreamResult` for a streaming response.
0 commit comments