Skip to content

Commit e5b50dd

Browse files
mattsp1290claude
andcommitted
docs: Add comprehensive Go SDK documentation
- Add main Go SDK overview with installation and getting started guide - Add client package documentation for SSE client implementation - Add core package documentation for events and types - Add encoding package documentation for marshaling/unmarshaling - Add errors package documentation for error handling - Include code examples and API references for all packages 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 9ffdbc7 commit e5b50dd

File tree

8 files changed

+2598
-0
lines changed

8 files changed

+2598
-0
lines changed

docs/sdk/go/client/overview.mdx

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
---
2+
title: "Overview"
3+
description: "Client package overview for Go SDK"
4+
---
5+
6+
# Client Package
7+
8+
The AG-UI Go SDK client package provides Server-Sent Events (SSE) connectivity for real-time event streaming from AG-UI agents. This package enables Go applications to connect to agent endpoints and receive streaming responses.
9+
10+
## Package Import
11+
12+
```go
13+
import "github.com/ag-ui-protocol/ag-ui/sdks/community/go/pkg/client/sse"
14+
```
15+
16+
## SSE Client Introduction
17+
18+
The SSE (Server-Sent Events) client provides a robust connection mechanism for streaming events from AG-UI agents. SSE is a standard protocol for server-to-client streaming over HTTP, making it ideal for real-time agent interactions where the agent needs to send continuous updates about its processing state, thoughts, and outputs.
19+
20+
Key features:
21+
- Real-time event streaming from agents
22+
- Automatic connection management
23+
- Context-based cancellation support
24+
- Configurable timeouts and buffer sizes
25+
- Built-in authentication support
26+
27+
## Configuration
28+
29+
The client is highly configurable to adapt to different deployment scenarios:
30+
31+
```go
32+
client := sse.NewClient(sse.Config{
33+
Endpoint: "https://api.example.com/agent",
34+
APIKey: "your-api-key",
35+
ConnectTimeout: 30 * time.Second,
36+
ReadTimeout: 5 * time.Minute,
37+
BufferSize: 100,
38+
})
39+
40+
// Start streaming with context and payload
41+
frames, errors, err := client.Stream(sse.StreamOptions{
42+
Context: context.Background(),
43+
Payload: map[string]interface{}{
44+
"threadId": "thread_123",
45+
"messages": []interface{}{
46+
map[string]string{
47+
"role": "user",
48+
"content": "Hello, agent!",
49+
},
50+
},
51+
},
52+
})
53+
```
54+
55+
## Quick Example
56+
57+
Here's a complete example showing how to connect to an agent and process events:
58+
59+
```go
60+
package main
61+
62+
import (
63+
"context"
64+
"fmt"
65+
"log"
66+
67+
"github.com/ag-ui-protocol/ag-ui/sdks/community/go/pkg/client/sse"
68+
"github.com/ag-ui-protocol/ag-ui/sdks/community/go/pkg/core/events"
69+
)
70+
71+
func main() {
72+
// Create SSE client
73+
client := sse.NewClient(sse.Config{
74+
Endpoint: "https://api.example.com/agent",
75+
APIKey: "your-api-key",
76+
})
77+
78+
// Start streaming
79+
ctx := context.Background()
80+
frames, errors, err := client.Stream(sse.StreamOptions{
81+
Context: ctx,
82+
Payload: map[string]interface{}{
83+
"threadId": "thread_123",
84+
"messages": []interface{}{
85+
map[string]string{
86+
"role": "user",
87+
"content": "What is the weather today?",
88+
},
89+
},
90+
},
91+
})
92+
93+
if err != nil {
94+
log.Fatal("Failed to start stream:", err)
95+
}
96+
97+
// Process events
98+
decoder := events.NewEventDecoder()
99+
for {
100+
select {
101+
case frame := <-frames:
102+
event, err := decoder.Decode(frame.Data)
103+
if err != nil {
104+
log.Printf("Decode error: %v", err)
105+
continue
106+
}
107+
108+
// Handle different event types
109+
switch e := event.(type) {
110+
case *events.TextMessageContentEvent:
111+
fmt.Print(e.Delta)
112+
case *events.RunFinishedEvent:
113+
fmt.Println("\nAgent finished processing")
114+
return
115+
}
116+
117+
case err := <-errors:
118+
log.Printf("Stream error: %v", err)
119+
return
120+
}
121+
}
122+
}
123+
```
124+
125+
## Navigation
126+
127+
<Card
128+
title="SSE Client Reference"
129+
icon="cube"
130+
href="/sdk/go/client/sse-client"
131+
color="#3B82F6"
132+
iconType="solid"
133+
>
134+
Detailed documentation for the Server-Sent Events client including configuration, streaming, and error handling
135+
</Card>

0 commit comments

Comments
 (0)