private static void handleSessionUpdate(SessionUpdate update) {
if (update instanceof AgentMessageChunk msg) {
System.out.print(((TextContent) msg.content()).text());
} else if (update instanceof AgentThoughtChunk thought) {
System.out.println("[Thought] " +
((TextContent) thought.content()).text());
} else if (update instanceof ToolCall tool) {
System.out.println("[Tool] " + tool.title() +
" (" + tool.status() + ")");
} else if (update instanceof ToolCallUpdateNotification toolUpdate) {
System.out.println("[Tool Update] " + toolUpdate.title() +
" -> " + toolUpdate.status());
} else if (update instanceof Plan plan) {
System.out.println("[Plan] " + plan.entries().size() + " steps");
} else if (update instanceof AvailableCommandsUpdate commands) {
System.out.println("[Commands] " + commands.availableCommands().size() +
" available");
} else if (update instanceof CurrentModeUpdate mode) {
System.out.println("[Mode] " + mode.currentModeId());
}
}