Package com.github.copilot.sdk.events
Class AbstractSessionEvent
java.lang.Object
com.github.copilot.sdk.events.AbstractSessionEvent
- Direct Known Subclasses:
AbortEvent,AssistantIntentEvent,AssistantMessageDeltaEvent,AssistantMessageEvent,AssistantReasoningDeltaEvent,AssistantReasoningEvent,AssistantTurnEndEvent,AssistantTurnStartEvent,AssistantUsageEvent,HookEndEvent,HookStartEvent,PendingMessagesModifiedEvent,SessionCompactionCompleteEvent,SessionCompactionStartEvent,SessionErrorEvent,SessionHandoffEvent,SessionIdleEvent,SessionInfoEvent,SessionModelChangeEvent,SessionResumeEvent,SessionStartEvent,SessionTruncationEvent,SessionUsageInfoEvent,SubagentCompletedEvent,SubagentFailedEvent,SubagentSelectedEvent,SubagentStartedEvent,SystemMessageEvent,ToolExecutionCompleteEvent,ToolExecutionPartialResultEvent,ToolExecutionProgressEvent,ToolExecutionStartEvent,ToolUserRequestedEvent,UserMessageEvent
public abstract sealed class AbstractSessionEvent
extends Object
permits SessionStartEvent, SessionResumeEvent, SessionErrorEvent, SessionIdleEvent, SessionInfoEvent, SessionModelChangeEvent, SessionHandoffEvent, SessionTruncationEvent, SessionUsageInfoEvent, SessionCompactionStartEvent, SessionCompactionCompleteEvent, AssistantTurnStartEvent, AssistantIntentEvent, AssistantReasoningEvent, AssistantReasoningDeltaEvent, AssistantMessageEvent, AssistantMessageDeltaEvent, AssistantTurnEndEvent, AssistantUsageEvent, AbortEvent, ToolUserRequestedEvent, ToolExecutionStartEvent, ToolExecutionPartialResultEvent, ToolExecutionProgressEvent, ToolExecutionCompleteEvent, UserMessageEvent, PendingMessagesModifiedEvent, SubagentStartedEvent, SubagentCompletedEvent, SubagentFailedEvent, SubagentSelectedEvent, HookStartEvent, HookEndEvent, SystemMessageEvent
Base class for all session events in the Copilot SDK.
Session events represent all activities that occur during a Copilot
conversation, including messages from the user and assistant, tool
executions, and session state changes. Events are delivered to handlers
registered via
CopilotSession.on(java.util.function.Consumer).
Event Categories
- Session events:
SessionStartEvent,SessionResumeEvent,SessionErrorEvent,SessionIdleEvent, etc. - Assistant events:
AssistantMessageEvent,AssistantMessageDeltaEvent,AssistantTurnStartEvent, etc. - Tool events:
ToolExecutionStartEvent,ToolExecutionCompleteEvent, etc. - User events:
UserMessageEvent
Example Usage
session.on(event -> {
if (event instanceof AssistantMessageEvent msg) {
System.out.println("Assistant: " + msg.getData().getContent());
} else if (event instanceof SessionIdleEvent) {
System.out.println("Session is idle");
}
});
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns whether this is an ephemeral event.getId()Gets the unique identifier for this event.Gets the parent event ID, if this event is a child of another.Gets the timestamp when this event occurred.abstract StringgetType()Gets the event type discriminator string.voidsetEphemeral(Boolean ephemeral) Sets whether this is an ephemeral event.voidSets the event identifier.voidsetParentId(UUID parentId) Sets the parent event ID.voidsetTimestamp(OffsetDateTime timestamp) Sets the event timestamp.
-
Constructor Details
-
AbstractSessionEvent
public AbstractSessionEvent()
-
-
Method Details
-
getType
Gets the event type discriminator string.This corresponds to the event type in the JSON protocol (e.g., "assistant.message", "session.idle").
- Returns:
- the event type string
-
getId
Gets the unique identifier for this event.- Returns:
- the event UUID
-
setId
Sets the event identifier.- Parameters:
id- the event UUID
-
getTimestamp
Gets the timestamp when this event occurred.- Returns:
- the event timestamp
-
setTimestamp
Sets the event timestamp.- Parameters:
timestamp- the event timestamp
-
getParentId
Gets the parent event ID, if this event is a child of another.- Returns:
- the parent event UUID, or
null
-
setParentId
Sets the parent event ID.- Parameters:
parentId- the parent event UUID
-
getEphemeral
Returns whether this is an ephemeral event.Ephemeral events are not persisted in session history.
- Returns:
trueif ephemeral,falseotherwise
-
setEphemeral
Sets whether this is an ephemeral event.- Parameters:
ephemeral-trueif ephemeral
-