Skip to content

Commit f9855ec

Browse files
Merge branch 'main' into brandon/iframe-dojo
2 parents 8162291 + a9398d1 commit f9855ec

File tree

239 files changed

+33600
-35
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

239 files changed

+33600
-35
lines changed

.github/pull_request_template.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
<!--
3+
4+
**Please PLEASE reach out to us first before starting any significant work on new or existing features.**
5+
6+
By the time you've gotten here, you're looking at creating a pull request so hopefully we're not too late.
7+
8+
We love community contributions! That said, we want to make sure we're all on the same page before you start.
9+
Investing a lot of time and effort just to find out it doesn't align with the upstream project feels awful, and we don't want that to happen.
10+
It also helps to make sure the work you're planning isn't already in progress.
11+
12+
As described in our contributing guide, please file an issue first: https://github.com/ag-ui-protocol/ag-ui/issues
13+
Or, reach out to us on Discord: https://discord.gg/Jd3FzfdJa8
14+
15+
Take a look at the contributing guide:
16+
https://github.com/ag-ui-protocol/ag-ui/blob/main/CONTRIBUTING.md
17+
18+
-->

.github/workflows/test.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,3 +190,25 @@ jobs:
190190
else
191191
echo "✅ All $total_tests tests passed!"
192192
fi
193+
194+
java:
195+
name: Java SDK Tests
196+
runs-on: ubuntu-latest
197+
198+
defaults:
199+
run:
200+
working-directory: sdks/community/java
201+
202+
steps:
203+
- name: Checkout code
204+
uses: actions/checkout@v4
205+
206+
- name: Set up Java
207+
uses: actions/setup-java@v4
208+
with:
209+
distribution: 'temurin'
210+
java-version: '17'
211+
cache: 'maven'
212+
213+
- name: Run tests
214+
run: mvn -B -ntp test

CONTRIBUTING.md

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,36 +10,46 @@ Here’s how to get involved:
1010

1111
Pick the right spot so we can help you faster:
1212

13-
- **🐛 Bugs / Feature Ideas**[GitHub Issues](https://github.com/ag-ui-protocol/ag-ui/issues)
14-
- **❓ "How do I...?" / General Questions**[GitHub Discussions](https://github.com/ag-ui-protocol/ag-ui/discussions)
13+
- **🐛 Bugs / Feature Ideas**[GitHub Issues](https://github.com/ag-ui-protocol/ag-ui/issues)
14+
- **❓ "How do I...?" / General Questions**[GitHub Discussions](https://github.com/ag-ui-protocol/ag-ui/discussions)
1515
- **💬 Quick chats / casual stuff**[Discord](https://discord.gg/Jd3FzfdJa8)`#-💎-contributing`
1616

1717
---
1818

1919
## 🧑‍💻 Want to Contribute Code?
2020

21-
1. **Find Something to Work On**
22-
Browse open issues on [GitHub](https://github.com/ag-ui-protocol/ag-ui/issues).
21+
First, an important plea:
22+
**Please PLEASE reach out to us first before starting any significant work on new or existing features.**
23+
24+
We love community contributions! That said, we want to make sure we're all on the same page before you start.
25+
Investing a lot of time and effort just to find out it doesn't align with the upstream project feels awful, and we don't want that to happen.
26+
It also helps to make sure the work you're planning isn't already in progress.
27+
28+
As described below, please file an issue first: https://github.com/ag-ui-protocol/ag-ui/issues
29+
Or, reach out to us on Discord: https://discord.gg/Jd3FzfdJa8
30+
31+
1. **Find Something to Work On**
32+
Browse open issues on [GitHub](https://github.com/ag-ui-protocol/ag-ui/issues).
2333
Got your own idea? Open an issue first so we can start the discussion.
2434

25-
2. **Ask to Be Assigned**
26-
Comment on the issue and tag a code owner:
35+
2. **Ask to Be Assigned**
36+
Comment on the issue and tag a code owner:
2737
[Code Owners](https://github.com/ag-ui-protocol/ag-ui/blob/main/.github/CODEOWNERS)
2838

29-
3. **Get on the Roadmap**
39+
3. **Get on the Roadmap**
3040
Once approved, you'll be assigned the issue, and it'll get added to our [roadmap](https://github.com/orgs/ag-ui-protocol/projects/1).
3141

32-
4. **Coordinate With Others**
33-
- If you're collaborating or need feedback, start a thread in `#-💎-contributing` on Discord
42+
4. **Coordinate With Others**
43+
- If you're collaborating or need feedback, start a thread in `#-💎-contributing` on Discord
3444
- Or just DM the assignee directly
3545

36-
5. **Open a Pull Request**
37-
- When you’re ready, submit your PR
38-
- In the description, include: `Fixes #<issue-number>`
46+
5. **Open a Pull Request**
47+
- When you’re ready, submit your PR
48+
- In the description, include: `Fixes #<issue-number>`
3949
(This links your PR to the issue and closes it automatically)
4050

41-
6. **Review & Merge**
42-
- A maintainer will review your code and leave comments if needed
51+
6. **Review & Merge**
52+
- A maintainer will review your code and leave comments if needed
4353
- Once it’s approved, we’ll merge it and move the issue to “done.”
4454

4555
**NOTE:** All community integrations (ie, .NET, Golang SDK, etc.) will need to be maintained by the community
@@ -52,13 +62,13 @@ Docs are part of the codebase and super valuable—thanks for helping improve th
5262

5363
Here’s how to contribute:
5464

55-
1. **Open an Issue First**
56-
- Open a [GitHub issue](https://github.com/ag-ui-protocol/ag-ui/issues) describing what you’d like to update or add.
65+
1. **Open an Issue First**
66+
- Open a [GitHub issue](https://github.com/ag-ui-protocol/ag-ui/issues) describing what you’d like to update or add.
5767
- Then comment and ask to be assigned.
5868

59-
2. **Submit a PR**
69+
2. **Submit a PR**
6070
- Once assigned, make your edits and open a pull request.
61-
- In the description, include: `Fixes #<issue-number>`
71+
- In the description, include: `Fixes #<issue-number>`
6272
(This links your PR to the issue and closes it automatically)
6373

6474
- A maintainer will review it and merge if it looks good.
@@ -69,5 +79,5 @@ That’s it! Simple and appreciated.
6979

7080
## 🙌 That’s It!
7181

72-
AG-UI is community-built, and every contribution helps shape where we go next.
82+
AG-UI is community-built, and every contribution helps shape where we go next.
7383
Big thanks for being part of it!

docs/quickstart/clients.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ export const agent = new MastraAgent({
145145
agent: new Agent({
146146
name: "AG-UI Assistant",
147147
instructions: `
148-
You are a helpful AI assistant. Be friendly, conversational, and helpful.
148+
You are a helpful AI assistant. Be friendly, conversational, and helpful.
149149
Answer questions to the best of your ability and engage in natural conversation.
150150
`,
151151
model: openai("gpt-4o"),
@@ -175,7 +175,7 @@ Now let's create the interactive chat interface. Create `src/index.ts`:
175175
```typescript
176176
import * as readline from "readline"
177177
import { agent } from "./agent"
178-
import { randomUUID } from "node:crypto"
178+
import { randomUUID } from "@ag-ui/client"
179179

180180
const rl = readline.createInterface({
181181
input: process.stdin,
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
title: "AbstractAgent"
3+
description: "Base agent implementation with core event handling (Java)"
4+
---
5+
6+
# AbstractAgent
7+
8+
The `AbstractAgent` class provides the foundation for agent implementations. It handles event stream processing, state management, and message history. Extend it and implement `protected void run(RunAgentInput input, IEventStream<BaseEvent> stream)`.
9+
10+
## Example Implementation
11+
12+
```java
13+
public class MyAgent extends AbstractAgent {
14+
public MyAgent() {
15+
super("my-agent", "A custom agent", "thread-123", List.of(), new State(), false);
16+
}
17+
18+
@Override
19+
protected void run(RunAgentInput input, IEventStream<BaseEvent> stream) {
20+
// Emit events using the stream
21+
stream.next(new RunStartedEvent(input.getThreadId(), input.getRunId()));
22+
23+
// Your agent logic here...
24+
25+
stream.next(new RunFinishedEvent(input.getThreadId(), input.getRunId()));
26+
}
27+
}
28+
```
29+
30+
## Configuration
31+
32+
Constructors take: `agentId`, `description`, `threadId`, `initialMessages`, `state`, `debug`.
33+
34+
## Core Methods
35+
36+
- `CompletableFuture<Void> runAgent(RunAgentParameters parameters, AgentSubscriber subscriber)` — orchestrates an async run and event distribution
37+
- `Subscription subscribe(AgentSubscriber subscriber)` — persistent subscriber registration
38+
- `void addMessage(BaseMessage message)` / `void addMessages(List<BaseMessage>)`
39+
- `void setMessages(List<BaseMessage>)`
40+
- `void setState(State state)` / `State getState()`
41+
42+
## Protected Methods
43+
44+
- `protected abstract void run(RunAgentInput input, IEventStream<BaseEvent> stream)` — emit events into `stream`
45+
- `protected RunAgentInput prepareRunAgentInput(RunAgentParameters parameters)`
46+
- `protected void onInitialize(RunAgentInput input, List<AgentSubscriber> subscribers)`
47+
- `protected void handleEvent(BaseEvent event, List<AgentSubscriber> subscribers, AtomicReference<IEventStream<BaseEvent>> streamRef)`
48+
- `protected void handleComplete(List<AgentSubscriber> subscribers, RunAgentInput input, CompletableFuture<Void> future)`
49+
- `protected void handleError(Throwable error, List<AgentSubscriber> subscribers, CompletableFuture<Void> future)`
50+
51+
### Text Message Helpers
52+
53+
`handleTextMessageStart`, `handleTextMessageContent`, `handleTextMessageChunk`, `handleTextMessageEnd` integrate with `MessageFactory` to assemble streamed messages and notify subscribers.
54+
55+
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
title: "HttpAgent"
3+
description: "HTTP-based agent for connecting to remote AI agents (Java)"
4+
---
5+
6+
# HttpAgent
7+
8+
`HttpAgent` extends `AbstractAgent` to provide HTTP-based connectivity to remote AI agents. It delegates streaming to a `BaseHttpClient` implementation and forwards incoming events to subscribers.
9+
10+
## Configuration
11+
12+
Use the builder to construct an instance:
13+
14+
```java
15+
HttpAgent agent = HttpAgent.builder()
16+
.agentId("my-agent")
17+
.threadId("thread-123")
18+
.httpClient(myHttpClient)
19+
.messages(new ArrayList<>())
20+
.state(new State())
21+
.debug(true)
22+
.build();
23+
```
24+
25+
Required: `agentId`, `threadId`, `httpClient`
26+
27+
## Methods
28+
29+
- `protected void run(RunAgentInput input, IEventStream<BaseEvent> stream)` — streams events via `httpClient.streamEvents`
30+
- `void close()` — closes the underlying HTTP client
31+
32+
## Builder
33+
34+
Fluent builder with validation. Required fields must be set or an `IllegalArgumentException` is thrown.
35+
36+

docs/sdk/java/client/overview.mdx

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
title: "Overview"
3+
description: "Client package overview for the Java SDK"
4+
---
5+
6+
# ag-ui-client
7+
8+
The Java Client SDK provides agent connectivity options for AI systems. It builds on the core types and events to deliver flexible connection methods to agent implementations.
9+
10+
## AbstractAgent
11+
12+
`AbstractAgent` is the base agent class for implementing custom agent connectivity. Extend this class and implement `run` to bridge your service to AG-UI.
13+
14+
- Configuration — agent ID, messages, and state
15+
- Core Methods — runAgent, subscribe, message/state helpers
16+
- Protected Methods — event handling hooks
17+
- Properties — state and message tracking
18+
19+
<Card
20+
title="AbstractAgent Reference"
21+
icon="cube"
22+
href="/sdk/java/client/abstract-agent"
23+
color="#3B82F6"
24+
iconType="solid"
25+
>
26+
Base class for creating custom agent connections
27+
</Card>
28+
29+
## HttpAgent
30+
31+
Concrete implementation for HTTP-based agent connectivity using an injected `BaseHttpClient` implementation.
32+
33+
- Configuration — agentId, threadId, httpClient
34+
- Methods — run via HTTP streaming, close
35+
- Builder — fluent configuration with validation
36+
37+
<Card
38+
title="HttpAgent Reference"
39+
icon="cube"
40+
href="/sdk/java/client/http-agent"
41+
color="#3B82F6"
42+
iconType="solid"
43+
>
44+
Ready-to-use HTTP implementation for agent connectivity
45+
</Card>
46+
47+
## AgentSubscriber
48+
49+
Event-driven subscriber system for handling agent lifecycle events and state mutations during execution.
50+
51+
- Event Handlers — lifecycle, message, tool call, and state events
52+
- Usage Examples — logging, persistence, error handling patterns
53+
- Integration — register and use subscribers with agents
54+
55+
<Card
56+
title="AgentSubscriber Reference"
57+
icon="bolt"
58+
href="/sdk/java/client/subscriber"
59+
color="#3B82F6"
60+
iconType="solid"
61+
>
62+
Comprehensive event system for reactive agent interaction
63+
</Card>
64+
65+
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
title: "AgentSubscriber"
3+
description: "Event subscriber interface for reactive agent interaction (Java)"
4+
---
5+
6+
# AgentSubscriber
7+
8+
Implement `AgentSubscriber` to handle lifecycle, message, tool call, and state events during agent execution.
9+
10+
## Event Handlers
11+
12+
- Request lifecycle: `onRunInitialized`, `onRunFailed`, `onRunFinalized`
13+
- Lifecycle events: `onRunStartedEvent`, `onRunFinishedEvent`, `onRunErrorEvent`, `onStepStartedEvent`, `onStepFinishedEvent`
14+
- Text messages: `onTextMessageStartEvent`, `onTextMessageContentEvent`, `onTextMessageEndEvent`
15+
- Tool calls: `onToolCallStartEvent`, `onToolCallArgsEvent`, `onToolCallEndEvent`, `onToolCallResultEvent`
16+
- State: `onStateSnapshotEvent`, `onStateDeltaEvent`, `onMessagesSnapshotEvent`, `onMessagesChanged`, `onStateChanged`
17+
- Special: `onRawEvent`, `onCustomEvent`, and catch-all `onEvent`
18+
19+
## Usage Example
20+
21+
```java
22+
agent.subscribe(new AgentSubscriber() {
23+
@Override
24+
public void onRunStartedEvent(RunStartedEvent event) {
25+
System.out.println("Run started: " + event.getRunId());
26+
}
27+
28+
@Override
29+
public void onTextMessageContentEvent(TextMessageContentEvent event) {
30+
System.out.print(event.getDelta());
31+
}
32+
});
33+
```
34+
35+

docs/sdk/java/core/events.mdx

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
title: "Events"
3+
description: "Java event types used by the Agent User Interaction Protocol"
4+
---
5+
6+
# Events
7+
8+
All events live in `com.agui.core.event` and share `BaseEvent` with a `type` and `timestamp`.
9+
10+
## Lifecycle Events
11+
12+
- `RunStartedEvent`
13+
- `RunFinishedEvent`
14+
- `RunErrorEvent`
15+
- `StepStartedEvent`
16+
- `StepFinishedEvent`
17+
18+
## Text Message Events
19+
20+
- `TextMessageStartEvent` — Begin of a streamed assistant message
21+
- `TextMessageContentEvent` — Incremental content chunks (`delta`)
22+
- `TextMessageEndEvent` — Message finished
23+
24+
## Tool Call Events
25+
26+
- `ToolCallStartEvent`
27+
- `ToolCallArgsEvent`
28+
- `ToolCallEndEvent`
29+
- `ToolCallResultEvent`
30+
31+
## State Management Events
32+
33+
- `StateSnapshotEvent`
34+
- `StateDeltaEvent`
35+
- `MessagesSnapshotEvent`
36+
37+
## Special Events
38+
39+
- `RawEvent` — Raw payload passthrough
40+
- `CustomEvent` — Application-specific event
41+
42+
See also: `AgentSubscriber` callbacks in the client docs for handling these events.
43+
44+

0 commit comments

Comments
 (0)