agenttrace-ag-ui
v0.1.1
Published
AG-UI protocol adapter for agenttrace-react. Visualise AG-UI agent execution traces, tool calls, and human-in-the-loop approval gates as a live React UI.
Downloads
232
Maintainers
Readme
agenttrace-ag-ui
AG-UI protocol adapter for agenttrace-react — visualise AG-UI agent execution traces, tool calls, and human-in-the-loop approval gates as a live React UI.
Install
npm install agenttrace-react agenttrace-ag-ui
# or
pnpm add agenttrace-react agenttrace-ag-uiUse cases
- Rendering a live execution trace for any AG-UI protocol-compatible agent
- Visualising tool calls and steps as they stream in over SSE
- Surfacing
CUSTOMapproval events as human-in-the-loop gates - Building oversight UIs for agents using the AG-UI standard (supported by Google, Microsoft, AWS, LangChain, and others)
Peer dependencies
agenttrace-reactreact
Exports
useAgUiTrace(agentUrl)— connects to an AG-UI SSE endpoint and returns a liveAgentRunagUiToTraceEvent(event)— maps a single AG-UI event to aTraceEvent
Usage
import { TraceProvider, TraceTree, TraceNode, ApprovalGate } from 'agenttrace-react'
import { useAgUiTrace } from 'agenttrace-ag-ui'
export function AgUiTraceView({ onApproval }) {
const run = useAgUiTrace('/api/agent/stream')
return (
<TraceProvider run={run} onApprovalAction={onApproval}>
<TraceTree>
{({ node }) => (
<TraceNode node={node}>
{({ name, status, type }) => (
<div data-status={status} data-type={type}>
{name}: {status}
<ApprovalGate>
{({ approve, reject, context }) => (
<div>
<p>{context.description}</p>
<button onClick={approve}>Approve</button>
<button onClick={reject}>Reject</button>
</div>
)}
</ApprovalGate>
</div>
)}
</TraceNode>
)}
</TraceTree>
</TraceProvider>
)
}Supported AG-UI events
| Event | Mapped to |
|-------|-----------|
| RUN_STARTED | RunStarted |
| RUN_FINISHED | finalises the run |
| RUN_ERROR | NodeFailed |
| STEP_STARTED | NodeStarted (type: agent) |
| STEP_FINISHED | NodeCompleted (type: agent) |
| TOOL_CALL_START | NodeStarted (type: tool) |
| TOOL_CALL_END | NodeCompleted (type: tool) |
| CUSTOM | ApprovalRequested or ApprovalResolved |
How it works
- Connects to any AG-UI-compatible agent endpoint via
EventSource(SSE) - Parses and maps all AG-UI event types to
agenttrace-reacttrace events - Infers approval events from
CUSTOMevent names and payload shape - Returns a live
AgentRuncompatible withagenttrace-react'sTraceProvider - Handles SSE connection errors gracefully with a
NodeFailedtrace event
Related packages
agenttrace-react— core headless primitivesagenttrace-langgraph— LangGraph adapteragenttrace-ai-sdk— Vercel AI SDK adapter
Repository
github.com/nedbpowell/agenttrace-react
License
MIT
