Package com.tnsai.hooks.events
Record Class OnSessionIdle
java.lang.Object
java.lang.Record
com.tnsai.hooks.events.OnSessionIdle
- Record Components:
eventId- ULID-shaped correlation idtimestamp- when the idle threshold trippedcontext- surrounding hook contextsessionId- framework session ididleFor- how long the session has been idlesuggestedAction- framework's recommendation
- All Implemented Interfaces:
HookEvent,SessionHookEvent
public record OnSessionIdle(String eventId, Instant timestamp, HookContext context, String sessionId, Duration idleFor, IdleAction suggestedAction)
extends Record
implements SessionHookEvent
Fires when a session has been idle past the configured threshold
(issue #63). The
suggestedAction is the framework's
default (IdleAction.WARN → IdleAction.SUSPEND →
IdleAction.CLOSE as the idle duration grows). Hooks can
override the action via withSuggestedAction(IdleAction)
or Block to refuse the
suggestion (e.g. high-priority sessions never auto-close).- Since:
- 0.5.0 (issue #63)
-
Constructor Summary
ConstructorsConstructorDescriptionOnSessionIdle(String eventId, Instant timestamp, HookContext context, String sessionId, Duration idleFor, IdleAction suggestedAction) Creates an instance of aOnSessionIdlerecord class. -
Method Summary
Modifier and TypeMethodDescriptioncontext()Returns the value of thecontextrecord component.final booleanIndicates whether some other object is "equal to" this one.eventId()Returns the value of theeventIdrecord component.Short stable string identifier of the event kind, e.g.final inthashCode()Returns a hash code value for this object.idleFor()Returns the value of theidleForrecord component.Returns the value of thesessionIdrecord component.Returns the value of thesuggestedActionrecord component.Returns the value of thetimestamprecord component.final StringtoString()Returns a string representation of this record class.withSuggestedAction(IdleAction newAction) Build a copy withnewActionreplacingsuggestedAction.
-
Constructor Details
-
OnSessionIdle
public OnSessionIdle(String eventId, Instant timestamp, HookContext context, String sessionId, Duration idleFor, IdleAction suggestedAction) Creates an instance of aOnSessionIdlerecord class.- Parameters:
eventId- the value for theeventIdrecord componenttimestamp- the value for thetimestamprecord componentcontext- the value for thecontextrecord componentsessionId- the value for thesessionIdrecord componentidleFor- the value for theidleForrecord componentsuggestedAction- the value for thesuggestedActionrecord component
-
-
Method Details
-
eventType
Description copied from interface:HookEventShort stable string identifier of the event kind, e.g."PreToolUse". Default implementation derives it from the concrete record's simple class name; concrete records may override if a different naming is desirable. -
withSuggestedAction
Build a copy withnewActionreplacingsuggestedAction. Used by Modify hooks that override the idle-policy default per-session. -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
eventId
Returns the value of theeventIdrecord component. -
timestamp
Returns the value of thetimestamprecord component. -
context
Returns the value of thecontextrecord component. -
sessionId
Returns the value of thesessionIdrecord component.- Returns:
- the value of the
sessionIdrecord component
-
idleFor
Returns the value of theidleForrecord component.- Returns:
- the value of the
idleForrecord component
-
suggestedAction
Returns the value of thesuggestedActionrecord component.- Returns:
- the value of the
suggestedActionrecord component
-