Class AguiStateConverter
java.lang.Object
io.agentscope.core.agui.converter.AguiStateConverter
Converter for state management in the AG-UI protocol.
This class handles the creation of state events (snapshots and deltas) from AgentScope's state system.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCreate a STATE_DELTA event by comparing before and after states.Create a STATE_SNAPSHOT event from a state map.booleanCheck if there are any differences between two states.
-
Constructor Details
-
AguiStateConverter
public AguiStateConverter()
-
-
Method Details
-
createSnapshot
public AguiEvent.StateSnapshot createSnapshot(Map<String, Object> state, String threadId, String runId) Create a STATE_SNAPSHOT event from a state map.- Parameters:
state- The state mapthreadId- The thread IDrunId- The run ID- Returns:
- The StateSnapshot event
-
createDelta
public AguiEvent.StateDelta createDelta(Map<String, Object> before, Map<String, Object> after, String threadId, String runId) Create a STATE_DELTA event by comparing before and after states.This method generates JSON Patch operations (RFC 6902) that can transform the "before" state into the "after" state.
- Parameters:
before- The state before changesafter- The state after changesthreadId- The thread IDrunId- The run ID- Returns:
- The StateDelta event, or null if there are no changes
-
hasChanges
Check if there are any differences between two states.- Parameters:
before- The state before changesafter- The state after changes- Returns:
- true if there are differences
-