Interface TnsAIEvent

All Known Implementing Classes:
AgentHierarchyEvent, ApprovalRequestEvent, ArtifactEvent, BDIUpdateEvent, ErrorEvent, RunEndEvent, RunStartEvent, SkillActivationEvent, StatusEvent, TextDeltaEvent, ThoughtEvent, ToolCallEndEvent, ToolCallStartEvent, UiComponentEvent

Sealed interface representing internal TnsAI events.

This event hierarchy provides a type-safe way to represent all events that can occur during agent execution. Events are used for:

  • Real-time streaming to frontends (via AG-UI protocol)
  • Observability and logging
  • Event sourcing patterns
  • Human-in-the-loop workflows

Event types:

Example usage:


 agent.chatWithEvents("Hello")
     .subscribe(event -> {
         switch (event) {
             case TextDeltaEvent delta -> System.out.print(delta.content());
             case ToolCallStartEvent tool -> System.out.println("Calling: " + tool.toolName());
             case ErrorEvent error -> System.err.println("Error: " + error.message());
             default -> {}
         }
     });
 
Author:
TnsAI Team
See Also:
  • invalid reference
    com.tnsai.agents.Agent#chatWithEvents(String)
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the unique identifier of this event.
    default String
    Returns the type of this event as a string.
    static String
    Generates a new unique event ID.
    static Instant
    now()
    Returns the current timestamp.
    Returns the timestamp when this event was created.
  • Method Details

    • eventId

      String eventId()
      Returns the unique identifier of this event.
      Returns:
      event ID (never null)
    • timestamp

      Instant timestamp()
      Returns the timestamp when this event was created.
      Returns:
      event timestamp (never null)
    • eventType

      default String eventType()
      Returns the type of this event as a string.
      Returns:
      event type name (never null)
    • generateEventId

      static String generateEventId()
      Generates a new unique event ID.
      Returns:
      new UUID string
    • now

      static Instant now()
      Returns the current timestamp.
      Returns:
      current instant