Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
530 commits
Select commit Hold shift + click to select a range
d053aaa
REmoved unecessary files and added gitignore
Abubakar-01 Jul 17, 2025
a9dce90
Merge pull request #192 from juanpabloCamus/litebox-readme-update
NathanTarbert Jul 17, 2025
9d3196d
Merge pull request #193 from ag-ui-protocol/ataibarkai-patch-2
NathanTarbert Jul 18, 2025
05d735e
update llamaindex doc comment
mme Jul 18, 2025
411a314
update llamaindex version
mme Jul 18, 2025
0a49b9a
Update CONTRIBUTING.md
NathanTarbert Jul 18, 2025
9df222e
Update README.md
NathanTarbert Jul 18, 2025
5f27ae8
feat(cli): add better templates for all integrations in next.js client
tylerslaton Jul 18, 2025
f6bc34c
chore(cli): release 0.0.36
tylerslaton Jul 19, 2025
4963d8e
Fixed the Core test case
Abubakar-01 Jul 21, 2025
6056706
chore(python-sdk): add type literals for new events
stevenh Jul 18, 2025
115d52f
fix(typescript-sdk): random build failures (#78)
stevenh Jul 22, 2025
6db0f77
feat(cli): add pydantic-ai to cli
tylerslaton Jul 22, 2025
439209b
chore(cli): release 0.0.37
tylerslaton Jul 22, 2025
fd1d069
feat: Pydantic AI support (#133)
stevenh Jul 22, 2025
30b4106
Merge pull request #190 from ag-ui-protocol/chore/add-disabling-of-si…
ranst91 Jul 23, 2025
0b23ad5
Update README.md
NathanTarbert Jul 23, 2025
c1f3e0e
Merge pull request #199 from ag-ui-protocol/NathanTarbert-patch-12
NathanTarbert Jul 23, 2025
ddbeb3c
Update README.md to include the workshop link
NathanTarbert Jul 23, 2025
d76731c
Update README.md
NathanTarbert Jul 23, 2025
26232a1
chore: pin mastra versions for CLI client
tylerslaton Jul 24, 2025
e187f74
chore: fix pnpm lockfile
tylerslaton Jul 24, 2025
c74ba41
update dojo link
mme Jul 24, 2025
becce91
Update README.md
NathanTarbert Jul 24, 2025
a9ebcee
Update README.md
NathanTarbert Jul 24, 2025
0d4d7a2
Fix build by wrapping sidebar in a suspense (#221)
maxkorp Jul 24, 2025
0acdd98
Prepare dojo for deployment
maxkorp Jul 8, 2025
7061036
Update README.md
juanpabloCamus Jul 25, 2025
2bde69e
Update README.md
juanpabloCamus Jul 25, 2025
c6e85d5
Update peerdeps of @mastra/core (#214)
wardpeet Jul 25, 2025
72cea11
release @ag-ui/mastra 0.0.5
mme Jul 25, 2025
d4b3217
fix typescript error
mme Jul 25, 2025
2bcd3f6
Merge pull request #222 from juanpabloCamus/litebox-readme-update
ataibarkai Jul 25, 2025
116e982
Update README.md
NathanTarbert Jul 25, 2025
706f1dc
add error property to tool messages to enable retrying failed fronten…
mme Jul 28, 2025
e919ce8
Bump some mastra versions in dojo to align with types in mastra integ…
maxkorp Jul 25, 2025
af72c4b
Add doing a build to tests in CI
maxkorp Jul 25, 2025
40afa96
chore: add code and readme viewer to dojo demos
ranst91 Jul 25, 2025
d8f53cb
chore: enable fetching and showing remote files like pydantics
ranst91 Jul 25, 2025
1a13949
align with main
ranst91 Jul 29, 2025
afa65ea
Update package.json for Mastra integration (#225)
NathanTarbert Jul 29, 2025
27854ad
chore: remove unused code
ranst91 Jul 29, 2025
62f96d5
chore: generate files on app start
ranst91 Jul 29, 2025
4cd812c
Merge pull request #223 from ag-ui-protocol/chore/display-code-in-dojo
ranst91 Jul 29, 2025
fe75377
chore: update tool based generative ui demo design
ranst91 Jul 29, 2025
d090acb
chore: update agentic generative ui demo design
ranst91 Jul 29, 2025
848bd4a
chore: update hitl demo design
ranst91 Jul 29, 2025
8da3c42
Merge pull request #229 from ag-ui-protocol/chore/individual-demo-imp…
ranst91 Jul 29, 2025
314a94d
chore: fit dojo sidebar and chat width for mobile view
ranst91 Jul 25, 2025
91a86fa
Merge pull request #198 from ag-ui-protocol/NathanTarbert-patch-9
NathanTarbert Jul 29, 2025
20ec075
chore: fit individual demos for mobile
ranst91 Jul 29, 2025
980c77b
Merge pull request #230 from ag-ui-protocol/chore/mobile-friendly-dojo
ranst91 Jul 30, 2025
3e0f7b7
Update README.md
NathanTarbert Jul 30, 2025
a4f923a
Update README.md
NathanTarbert Jul 30, 2025
0fb9851
Add some gitignores
maxkorp Jul 30, 2025
5f1a5af
commit updated files.json
maxkorp Jul 30, 2025
2431587
Add ci to make sure codegenned `files.json` is committed up to date
maxkorp Jul 30, 2025
207974c
Update langgraph dep and remove unused poetry lockfile
maxkorp Jul 30, 2025
c7379cd
chore: fix desktop display for demo
ranst91 Jul 30, 2025
0b1d8b3
chore: use two languages files for langgraph examples
ranst91 Jul 30, 2025
325f352
feat: restore time travel and re-generation
ranst91 Jul 30, 2025
7f00398
chore: remove unused imports
ranst91 Jul 31, 2025
413b342
chore: latest generated dojo files
ranst91 Jul 31, 2025
af6688c
chore: unify python examples
ranst91 Aug 1, 2025
bf6b715
fix: fix time travel on fastapi implementation
ranst91 Aug 1, 2025
76022a6
chore: use checkpointer in fastapi version and omit on lgp
ranst91 Aug 1, 2025
37a3a09
fix: fix both lg hitl post interrupt calls
ranst91 Aug 1, 2025
a8f37ef
Update README.md
NathanTarbert Aug 1, 2025
5c49784
fix: use class property for default schema keys
ranst91 Aug 1, 2025
971c901
fix: dispatch step start when resuming an interrupt
ranst91 Aug 1, 2025
11d5f2f
chore: align demo files
ranst91 Aug 1, 2025
c08e98b
chore: set fastapi in env when running fastapi dojo examples
ranst91 Aug 1, 2025
928a4bf
Merge pull request #241 from ag-ui-protocol/feat/restore-time-travel
ranst91 Aug 1, 2025
73c9018
Fix typo in CopilotKit link
tomsugden Jul 31, 2025
de3489e
Bring in the example from the Pydantic repo so you can see it locally…
maxkorp Aug 1, 2025
d852fc8
Merge pull request #189 from Abubakar-01/dojo-abubakar-e2e
ranst91 Aug 1, 2025
844fd06
Ignore e2e folder in dojo build (#250)
maxkorp Aug 1, 2025
4e3fcd1
v0.0.8
mme Aug 1, 2025
bbc83dd
Run fake dojo tests on every PR (#252)
maxkorp Aug 4, 2025
900487e
Update README.md
NathanTarbert Aug 4, 2025
dae91e1
Consolidate sidebar visilbity in the dojo (#264)
maxkorp Aug 5, 2025
40b0f14
fix query string param
maxkorp Aug 5, 2025
d25374c
fix(mastra): update dependencies and fix integration
roaminro Aug 5, 2025
c0c4215
fix(deps): update mastra dependencies across packages
roaminro Aug 5, 2025
13d6ab1
fix(deps): update mastra dependencies in example package
roaminro Aug 6, 2025
a2378c8
chore(mastra): release 0.0.7
tylerslaton Aug 6, 2025
94554d0
chore(mastra): release 0.0.8
tylerslaton Aug 6, 2025
1719274
feat: add stable test IDs for E2E test reliability
Abubakar-01 Aug 5, 2025
6d2c4f5
fix(docs): run file generation for JSON data (#269)
tylerslaton Aug 6, 2025
8962829
chore: release v0.0.5 of langgraph python fastapi integration
ranst91 Aug 1, 2025
ee20236
Improve Dojo examples (#197)
mme Aug 6, 2025
6eedfa5
Fix up some langgraph docs and scripts in the dojo (#271)
maxkorp Aug 7, 2025
8030a2b
chore: use latest packages for lg integrations and dojo
ranst91 Aug 8, 2025
b1226e3
Merge pull request #281 from ag-ui-protocol/chore/latest-cpk
ranst91 Aug 8, 2025
c27b095
chore: add basic branded styling
ranst91 Aug 8, 2025
83cc337
chore: finalize branded styling
ranst91 Aug 8, 2025
1f78219
chore: mobile view design tweaks
ranst91 Aug 8, 2025
c4e5614
chore: list design tweaks
ranst91 Aug 8, 2025
03528ff
chore(dojo): bump cpk to 1.10.1
tylerslaton Aug 8, 2025
fbed2d1
use 0.0.0.0 as host for mastra example since default changed (#287)
maxkorp Aug 8, 2025
7233dce
bump langgraph example to allow python 3.13
maxkorp Aug 8, 2025
423b31b
Merge pull request #285 from ag-ui-protocol/chore/dojo-redesign
ranst91 Aug 11, 2025
f21d806
fix(langgraph): include the payload with the original user message th…
ranst91 Aug 11, 2025
bec8d6f
fix(langgraph): include the payload with the original user message th…
ranst91 Aug 11, 2025
3aa764a
chore: publish agui fastapi langgraph
ranst91 Aug 11, 2025
a3f21f8
Fix/update e2e test cases (#277)
Abubakar-01 Aug 11, 2025
f6a0d74
bump mastra packages to fix deploy
maxkorp Aug 11, 2025
48efee9
add langgraph-typescript to the menu
maxkorp Aug 11, 2025
e24c74a
generate files
maxkorp Aug 11, 2025
36d36a8
Merge pull request #292 from ag-ui-protocol/fix/include-payload-with-…
ranst91 Aug 12, 2025
fa58b2b
Update README.md
mme Aug 12, 2025
c795bf9
fix: expose run error in legacy runtime events
ranst91 Aug 12, 2025
eb2b92b
0.0.36-alpha.2
mme Aug 12, 2025
100c4cd
fix
ranst91 Aug 12, 2025
e9d7ec2
Update README.md
pascalwilbrink Aug 12, 2025
fdd397d
Use e2e package for dojo testing on PRs (#295)
maxkorp Aug 12, 2025
4a50df0
feat: add THINKING_START and THINKING_END event schemas to discrimina…
pescn Aug 13, 2025
b304635
0.0.38-alpha.3
mme Aug 13, 2025
880b9cb
Merge branch 'main' into fix/legacy-error-message-forwarding
ranst91 Aug 13, 2025
a5bf5d5
chore: fix persistence of the generated document in predicted state u…
ranst91 Aug 13, 2025
b4ff602
chore: fix scroll on shared state demo
ranst91 Aug 13, 2025
2e3b0ae
Merge pull request #303 from ag-ui-protocol/chore/fix-persistence-of-…
ranst91 Aug 13, 2025
b573f73
Merge pull request #304 from ag-ui-protocol/chore/fix-demos-scroll
ranst91 Aug 13, 2025
dac3fce
chore: remove alpha versions from different packages
ranst91 Aug 13, 2025
7adb8a6
Merge branch 'main' into fix/legacy-error-message-forwarding
ranst91 Aug 13, 2025
e9ca110
Merge pull request #298 from ag-ui-protocol/fix/legacy-error-message-…
ranst91 Aug 13, 2025
9ae9c91
v0.0.36
mme Aug 13, 2025
509f1d5
0.0.9
mme Aug 13, 2025
62af69c
Merge pull request #299 from Work-m8/main
NathanTarbert Aug 14, 2025
2fa632c
chore: disable dark theme in dojo
ranst91 Aug 19, 2025
5b6e40f
Merge pull request #308 from ag-ui-protocol/chore/disable-dark-theme-…
ranst91 Aug 19, 2025
1e0df12
fix: fix picking and reporting of state snapshots
ranst91 Aug 20, 2025
3c67dc9
chore: remove unnecessary log
ranst91 Aug 20, 2025
c40dea2
fix: add health endpoint to agui langgraph fastapi
ranst91 Aug 20, 2025
829c7c0
Merge pull request #310 from ag-ui-protocol/fix/report-state-langgraph
ranst91 Aug 20, 2025
ba02c38
chore: release agui langgraph integration for python
ranst91 Aug 20, 2025
cfe5cc6
Merge pull request #311 from ag-ui-protocol/fix/agui-fastapi-langgrap…
ranst91 Aug 20, 2025
477e102
chore: use latest agui fastapi langgraph integration
ranst91 Aug 13, 2025
9123fc1
chore: enable all predictive state updates tests
ranst91 Aug 13, 2025
d08eeba
chore: disable pydantic test which requires fix
ranst91 Aug 18, 2025
b719d68
fix: reset active run values to an actual dictionary
ranst91 Aug 18, 2025
3aa3f6a
chore: consider the activity dots of cpk as a loader in tests
ranst91 Aug 18, 2025
8ed2e85
chore: refrain from attempting to open an always open chat
ranst91 Aug 18, 2025
798d023
chore: fix predictive state update tests for langgraph
ranst91 Aug 22, 2025
795f5eb
chore: fix predictive state update tests for several integrations
ranst91 Aug 22, 2025
e78fe76
chore: revert several test changes
ranst91 Aug 22, 2025
c475749
chore: revert several test changes
ranst91 Aug 22, 2025
41b25fb
Merge pull request #305 from ag-ui-protocol/chore/examples-fix-bundle
ranst91 Aug 22, 2025
9b238a5
Update README.md
NathanTarbert Aug 22, 2025
646489f
deparallelize the tests in CI for now
maxkorp Aug 25, 2025
c27ef44
Fixes for most of tool-based generative ui and some other misc tests …
maxkorp Aug 27, 2025
a750897
Remove unneeded .fixme and fix more tests (#325)
maxkorp Aug 28, 2025
dc068d1
mark 2 more flaky tests
maxkorp Aug 28, 2025
671c3dc
use local files for pydantic example
maxkorp Aug 22, 2025
7ae7570
chore: support mastra 0.11.1 or above
tylerslaton Aug 27, 2025
8edfac7
chore: release 0.0.10
tylerslaton Aug 28, 2025
976c6ec
chore: release v0.0.9 of langgraph python integration
ranst91 Aug 22, 2025
6679b49
chore: use latest langgraph integration for python
ranst91 Aug 22, 2025
c590baa
chore: release agui langgraph integration for typescript
ranst91 Aug 21, 2025
42e9808
chore: add jetbrains folder to gitignore
ranst91 Aug 21, 2025
38f2afb
chore: attempt fix flaky test
ranst91 Aug 25, 2025
198fd8e
Merge pull request #315 from ag-ui-protocol/chore/release-agui-lg-py-009
ranst91 Aug 29, 2025
5d37bcf
Merge pull request #313 from ag-ui-protocol/chore/release-lg-integrat…
ranst91 Aug 29, 2025
4774736
fix: close off dangling steps by properly tracking open ones
ranst91 Aug 29, 2025
7951f01
Fix sharedState tests and refactor out some shared pages (#335)
maxkorp Aug 29, 2025
8bfa7ae
Merge pull request #333 from ag-ui-protocol/fix/close-off-dangling-ev…
ranst91 Sep 1, 2025
3b398e8
feat: add subgraph streaming demo for langgraph
ranst91 Aug 28, 2025
2c13107
chore: fix readme for subgraphs demo
ranst91 Aug 28, 2025
afd9128
chore: add demo agents for showcasing subgraphs support
ranst91 Aug 28, 2025
a24b11d
feat: add subgraphs support in langgraph integrations
ranst91 Aug 28, 2025
59adbd7
chore: add e2e tests for subgraphs feature
ranst91 Aug 29, 2025
2835e88
formatting
ranst91 Aug 29, 2025
7e2eb2c
chore: fix flaky test
ranst91 Sep 1, 2025
7009464
chore: fix flaky test
ranst91 Sep 1, 2025
ee200e9
fix: use fallback when closing off active step
ranst91 Sep 1, 2025
019d3d5
chore: release and use alpha version for python
ranst91 Sep 1, 2025
f63fbd1
chore: fix subgraphs e2e test wrong route
ranst91 Sep 2, 2025
98c9db5
Merge pull request #332 from ag-ui-protocol/feat/support-subgraph-str…
ranst91 Sep 2, 2025
174445d
Merge pull request #301 from pescn/main
ranst91 Sep 2, 2025
95dc54d
chore: release langgraph python integration 0.0.10
ranst91 Sep 2, 2025
3846b49
chore: use latest python agui langgraph integration
ranst91 Sep 2, 2025
4544012
Merge pull request #342 from ag-ui-protocol/chore/release-lg-py-inter…
ranst91 Sep 2, 2025
d0d3f25
release 0.0.11
mme Sep 3, 2025
28714dc
Support multiple runs in one request (#290)
mme Sep 4, 2025
19e64e0
v 0.0.37
mme Sep 4, 2025
208b299
fix: use peer and dev dependencies to prevent version locks for consu…
ranst91 Sep 4, 2025
06f7ef5
If state is empty on run_finished event, don't trigger a state update…
maxkorp Sep 4, 2025
a3cdf26
docs: point towards the roadmap in GitHub
JohnRiv Sep 4, 2025
b4210e2
chore: release lg integration 0.0.12
ranst91 Sep 5, 2025
fad52eb
Merge pull request #350 from ag-ui-protocol/fix/mismatch-core-package…
ranst91 Sep 5, 2025
5b6b5d9
fix: fix version mismatch for consumers by using peer dependencies
ranst91 Sep 5, 2025
866b851
Merge pull request #351 from ag-ui-protocol/fix/move-core-package-dep…
ranst91 Sep 5, 2025
bdc2e0c
Updated demo and docs links
johnprg Sep 5, 2025
5eed965
Merge pull request #352 from johnprg/patch-2
NathanTarbert Sep 6, 2025
9e1f23c
Merge pull request #347 from JohnRiv/roadmap-docs
NathanTarbert Sep 6, 2025
6a6e1a8
feat(dart): scaffold sdk and example directories
mattsp1290 Sep 8, 2025
26d452c
chore(dart): apply formatting and add dependencies
mattsp1290 Sep 8, 2025
6a9493f
Add proompts folder to .gitignore
mattsp1290 Sep 8, 2025
b68cf7c
Merge branch 'dart-sdk' into feat/dart-setup-repo-structure
mattsp1290 Sep 8, 2025
c41dd30
chore(dart): adopt strict analysis options (effective-dart)
mattsp1290 Sep 8, 2025
3a5b743
chore(dart): add .gitignore for Dart package
mattsp1290 Sep 8, 2025
3df7d69
chore(dart): remove .dart_tool folders from git tracking
mattsp1290 Sep 9, 2025
8121f03
Merge pull request #3 from mattsp1290/feat/dart-lints
mattsp1290 Sep 9, 2025
57614a7
docs(dart): document GitHub-only publishing and Git dependency usage
mattsp1290 Sep 9, 2025
a3166ba
chore: remove tasks.yaml from tracking (keep local copy)
mattsp1290 Sep 9, 2025
17c8309
Merge pull request #4 from mattsp1290/feat/dart-github-publishing-docs
mattsp1290 Sep 9, 2025
d7b1234
docs: add Docker server setup documentation
mattsp1290 Sep 9, 2025
e34ff9f
feat(dart): define core AG-UI types and JSON codecs
mattsp1290 Sep 9, 2025
367fa35
Merge pull request #5 from mattsp1290/feat/dart-core-types
mattsp1290 Sep 9, 2025
6b81b20
feat(dart): implement SSE client with reconnect and backoff
mattsp1290 Sep 9, 2025
174aa70
Merge pull request #6 from mattsp1290/feat/dart-sse-client
mattsp1290 Sep 9, 2025
a7a1516
feat(dart): implement event encoder/decoder with streaming support
mattsp1290 Sep 9, 2025
529d1e8
feat(dart): implement public client API
mattsp1290 Sep 9, 2025
e374d01
Merge pull request #7 from mattsp1290/dart-public-client-api
mattsp1290 Sep 9, 2025
06c01db
feat(dart): add validation and structured error types
mattsp1290 Sep 9, 2025
9f33e3a
Merge pull request #8 from mattsp1290/dart-validation
mattsp1290 Sep 9, 2025
5dc2416
feat(dart): implement HTTP endpoints and error handling
mattsp1290 Sep 9, 2025
0ba4b2f
Merge pull request #9 from mattsp1290/dart-implement-http-endpoints
mattsp1290 Sep 9, 2025
3a1f7e3
feat(dart): add event decoding integration test
mattsp1290 Sep 9, 2025
3e8b7a5
Merge pull request #10 from mattsp1290/dart-map-events-to-models
mattsp1290 Sep 9, 2025
9a3612f
feat(dart): scaffold example CLI for Tool Based Generative UI
mattsp1290 Sep 9, 2025
2903e41
Merge pull request #11 from mattsp1290/scaffold-example-app
mattsp1290 Sep 9, 2025
ad4d9ce
feat(dart): add tool-based generative UI support and parity testing
mattsp1290 Sep 9, 2025
d1a12cf
Merge pull request #12 from mattsp1290/dart-parity-with-dojo
mattsp1290 Sep 9, 2025
eef1a46
test(dart): add comprehensive unit tests and fix streaming issues
mattsp1290 Sep 10, 2025
9fbbab5
Merge pull request #13 from mattsp1290/dart-unit-tests-core
mattsp1290 Sep 10, 2025
bf48570
docs(dart): add comprehensive README with GitHub-only usage
mattsp1290 Sep 11, 2025
201ae88
feat(dart): add integration tests and improve client robustness
mattsp1290 Sep 11, 2025
be2da7f
Merge pull request #14 from mattsp1290/dart-integration-test-servers
mattsp1290 Sep 11, 2025
4b957c4
Merge pull request #15 from mattsp1290/docs/dart-readme
mattsp1290 Sep 11, 2025
8b9adb9
docs(dart): add comprehensive usage snippets to README
mattsp1290 Sep 11, 2025
fea894f
fix(dart): add support for THINKING_CONTENT events in decoder
mattsp1290 Sep 11, 2025
dd47576
Merge branch 'dart-sdk' into docs/example-readme
mattsp1290 Sep 11, 2025
dece994
Merge pull request #16 from mattsp1290/docs/example-readme
mattsp1290 Sep 16, 2025
36e1690
docs(dart): align package with Dart documentation best practices
mattsp1290 Sep 21, 2025
cbbf328
change package name
mattsp1290 Sep 21, 2025
8c36587
Revert "change package name"
mattsp1290 Sep 21, 2025
50967f5
update deps
mattsp1290 Sep 21, 2025
73175aa
add LICENSE for pub
mattsp1290 Sep 25, 2025
64c142b
test(dart): add comprehensive unit test coverage and fix test suite
mattsp1290 Sep 27, 2025
2779b17
docs(dart): add comprehensive Dart SDK documentation
mattsp1290 Sep 27, 2025
1763855
docs(dart): fix example references in documentation
mattsp1290 Sep 27, 2025
778c66e
ci: add Dart SDK tests to GitHub Actions workflow
mattsp1290 Sep 28, 2025
e5c7369
Merge pull request #18 from ag-ui-protocol/main
mattsp1290 Sep 28, 2025
e9d6aad
update readme
mattsp1290 Sep 28, 2025
c0bd034
Merge branch 'main' into dart-sdk
mattsp1290 Sep 28, 2025
81bbf59
remove test artifacts
mattsp1290 Sep 28, 2025
f8efc92
remove DS Store files
mattsp1290 Sep 28, 2025
af3b6cc
remove parity report
mattsp1290 Sep 28, 2025
31d6d06
remove some confusing things
mattsp1290 Sep 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
352 changes: 352 additions & 0 deletions docs/sdk/dart/client/client.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,352 @@
---
title: "AgUiClient"
description: "Main client class for AG-UI server connectivity"
---

# AgUiClient

The `AgUiClient` class is the primary interface for connecting to AG-UI compatible servers. It handles HTTP communication, SSE streaming, binary protocol encoding/decoding, and provides a type-safe API for agent interactions.

## Constructor

```dart
AgUiClient({
required AgUiClientConfig config,
http.Client? httpClient,
Encoder? encoder,
Decoder? decoder,
})
```

### Parameters

- `config` (required): Configuration object with server details
- `httpClient` (optional): Custom HTTP client implementation
- `encoder` (optional): Custom encoder for request serialization
- `decoder` (optional): Custom decoder for response parsing

## Methods

### runAgent

Executes an agent and returns a stream of decoded events.

```dart
Stream<BaseEvent> runAgent(
String agentId,
RunAgentInput input, {
Map<String, String>? headers,
})
```

#### Parameters

- `agentId`: Unique identifier for the agent
- `input`: Agent input containing messages, context, and configuration
- `headers`: Optional additional headers for this request

#### Returns

A `Stream<BaseEvent>` that emits protocol events as they arrive.

#### Example

```dart
final input = SimpleRunAgentInput(
messages: [
UserMessage(id: 'msg_1', content: 'Hello, agent!'),
],
context: {'sessionId': '12345'},
);

await for (final event in client.runAgent('chat-agent', input)) {
switch (event) {
case RunStartedEvent():
print('Agent started');
case TextMessageDeltaEvent(delta: final text):
print('Agent says: $text');
case RunFinishedEvent():
print('Agent finished');
}
}
```

### runAgentRaw

Executes an agent and returns raw SSE messages without decoding.

```dart
Stream<SseMessage> runAgentRaw(
String agentId,
RunAgentInput input, {
Map<String, String>? headers,
})
```

#### Use Cases

- Custom event processing
- Debugging and logging
- Performance optimization when decoding isn't needed

#### Example

```dart
await for (final message in client.runAgentRaw('agent', input)) {
print('Raw event: ${message.event}');
print('Raw data: ${message.data}');
}
```

### cancelAgent

Cancels an active agent execution.

```dart
Future<void> cancelAgent(String agentId)
```

#### Parameters

- `agentId`: The agent ID to cancel

#### Behavior

- Immediately closes the SSE connection
- Cleans up resources
- Causes the event stream to complete

#### Example

```dart
// Start long-running agent
final stream = client.runAgent('analysis-agent', input);

// Set up listener with timeout
final subscription = stream.listen(
(event) => processEvent(event),
onError: (error) => handleError(error),
);

// Cancel after 10 seconds
Timer(Duration(seconds: 10), () async {
await client.cancelAgent('analysis-agent');
await subscription.cancel();
});
```

### dispose

Cleans up all resources held by the client.

```dart
void dispose()
```

#### Important

- Call this when the client is no longer needed
- Cancels all active streams
- Closes HTTP client connections
- Releases memory resources

## Properties

### config

```dart
final AgUiClientConfig config;
```

The configuration used to initialize the client. Read-only.

### activeStreams

```dart
Map<String, bool> get activeStreams;
```

Returns a map of currently active agent IDs and their status.

## Error Handling

The client throws specific exceptions for different error scenarios:

### AgUiClientError

General client-side errors.

```dart
try {
await for (final event in client.runAgent('agent', input)) {
// Process events
}
} on AgUiClientError catch (e) {
print('Client error: ${e.message}');
print('Error code: ${e.code}');
}
```

### NetworkError

Network connectivity issues.

```dart
on NetworkError catch (e) {
print('Network error: ${e.message}');
// Implement retry logic
}
```

### ValidationError

Input validation failures.

```dart
on ValidationError catch (e) {
print('Validation failed: ${e.message}');
print('Failed fields: ${e.fields}');
}
```

### ServerError

Server-side errors (5xx status codes).

```dart
on ServerError catch (e) {
print('Server error: ${e.statusCode}');
print('Message: ${e.message}');
}
```

## Advanced Usage

### Custom HTTP Client

Provide a custom HTTP client for advanced scenarios:

```dart
import 'package:http/http.dart' as http;
import 'package:http/retry.dart';

final retryClient = RetryClient(http.Client());

final client = AgUiClient(
config: AgUiClientConfig(baseUrl: 'http://localhost:8000'),
httpClient: retryClient,
);
```

### Custom Encoding/Decoding

Implement custom encoders/decoders for specialized formats:

```dart
class CustomEncoder implements Encoder {
@override
List<int> encode(RunAgentInput input) {
// Custom encoding logic
return utf8.encode(jsonEncode(input.toJson()));
}
}

class CustomDecoder implements Decoder {
@override
BaseEvent decode(List<int> data) {
// Custom decoding logic
final json = jsonDecode(utf8.decode(data));
return BaseEvent.fromJson(json);
}
}

final client = AgUiClient(
config: config,
encoder: CustomEncoder(),
decoder: CustomDecoder(),
);
```

### Stream Transformations

Transform the event stream for specific use cases:

```dart
// Filter only message events
final messageStream = client
.runAgent('agent', input)
.where((event) => event is TextMessageEvent);

// Collect all text into a single string
final completeText = await client
.runAgent('agent', input)
.whereType<TextMessageDeltaEvent>()
.map((event) => event.delta)
.join();
```

### Concurrent Agents

Run multiple agents concurrently:

```dart
final agent1 = client.runAgent('agent1', input1);
final agent2 = client.runAgent('agent2', input2);

// Process both streams
await Future.wait([
agent1.forEach((event) => processAgent1(event)),
agent2.forEach((event) => processAgent2(event)),
]);
```

## Performance Considerations

### Connection Pooling

The client reuses HTTP connections when possible. For high-throughput scenarios:

```dart
final httpClient = http.Client();
// Configure connection pooling
final client = AgUiClient(
config: config,
httpClient: httpClient,
);
```

### Memory Management

For long-running streams:

1. Process events immediately rather than buffering
2. Cancel streams when no longer needed
3. Dispose of the client when done

### Binary Protocol

The binary protocol is more efficient than JSON for large payloads:

```dart
// Binary protocol is used automatically when supported
final stream = client.runAgent('agent', input);
```

## Testing

Mock the client for unit tests:

```dart
class MockAgUiClient implements AgUiClient {
@override
Stream<BaseEvent> runAgent(String agentId, RunAgentInput input) {
return Stream.fromIterable([
RunStartedEvent(runId: 'test-run'),
TextMessageStartedEvent(messageId: 'msg-1'),
TextMessageDeltaEvent(messageId: 'msg-1', delta: 'Hello'),
TextMessageFinishedEvent(messageId: 'msg-1'),
RunFinishedEvent(runId: 'test-run'),
]);
}
}
```
Loading