AG-UI Event Streaming
AGUIStream and AGUIEvent emit typed agent UI events (thought, token, tool_start, tool_end, status, error, done) validated and serialized into Server-Sent Events (text/event-stream) through the shared Rust core.
- Python
- TypeScript
- Rust
- Go
- C#
- Java
import asyncio
from ish.integrations.protocols import AGUIStream
async def main() -> None:
stream = AGUIStream()
await stream.emit("status", {"step": "planning"})
await stream.emit("token", {"text": "Ready."})
await stream.close()
async for sse_frame in stream.sse_stream():
print(sse_frame)
asyncio.run(main())
import { AGUIStream, IshClient } from "ish-harness";
const client = new IshClient();
const stream = new AGUIStream(client);
stream.emit("status", { step: "planning" });
stream.emit("token", { text: "Ready." });
stream.close();
for await (const event of stream) {
console.log(event.toSse());
}
client.close();
use ish_harness::ish_invoke_json;
use serde_json::json;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let validated = ish_invoke_json(
"agui.event.validate",
&json!({ "event_type": "status", "data": { "step": "planning" }, "timestamp": 1.0 })
.to_string(),
)?;
println!("Validated: {validated}");
let sse = ish_invoke_json(
"agui.event.sse",
&json!({ "event_type": "token", "data": { "text": "Ready." }, "timestamp": 2.0 })
.to_string(),
)?;
println!("SSE frame: {sse}");
Ok(())
}
package main
import (
"fmt"
ish "github.com/ish-harness/ish-harness/sdks/go"
)
func main() {
client, err := ish.NewClient()
if err != nil {
panic(err)
}
defer client.Close()
if _, err := ish.ValidateAGUIEvent(client, "status", map[string]any{"step": "planning"}, 1.0); err != nil {
panic(err)
}
sseFrame, err := ish.FormatAGUISSE(client, "token", map[string]any{"text": "Ready."}, 2.0)
if err != nil {
panic(err)
}
fmt.Println(sseFrame)
}
using System;
using System.Text.Json;
using Ish.Harness;
using var client = new IshClient();
await using var stream = new AGUIStream(client);
await stream.EmitAsync("status", JsonDocument.Parse("""{"step":"planning"}""").RootElement);
await stream.EmitAsync("token", JsonDocument.Parse("""{"text":"Ready."}""").RootElement);
await stream.DisposeAsync();
await foreach (var sseFrame in stream.SseStream())
{
Console.WriteLine(sseFrame);
}
import com.fasterxml.jackson.databind.ObjectMapper;
import io.github.ishharness.AGUIStream;
import io.github.ishharness.IshClient;
import java.nio.file.Path;
public class AguiExample {
public static void main(String[] args) {
var mapper = new ObjectMapper();
try (var client = new IshClient(Path.of(System.getenv("ISH_NATIVE_LIBRARY")));
var stream = new AGUIStream(client)) {
stream.emit("status", mapper.createObjectNode().put("step", "planning"));
stream.emit("token", mapper.createObjectNode().put("text", "Ready."));
stream.close();
for (String sseFrame : stream.sseStream()) {
System.out.println(sseFrame);
}
}
}
}