Record Class OnCapabilityDispatch

java.lang.Object
java.lang.Record
com.tnsai.hooks.events.OnCapabilityDispatch
Record Components:
eventId - ULID-shaped correlation id
timestamp - when the dispatch was about to occur
context - surrounding hook context
capabilityInterface - fully-qualified name of the @Capability interface
methodName - method name being dispatched
args - positional arguments to the call (immutable copy)
dispatchType - which ActionType channel routed the call (LOCAL, LLM, …)
All Implemented Interfaces:
CapabilityHookEvent, HookEvent

public record OnCapabilityDispatch(String eventId, Instant timestamp, HookContext context, String capabilityInterface, String methodName, List<Object> args, ActionType dispatchType) extends Record implements CapabilityHookEvent
Fires when ActionExecutor dispatches a method that originated from a @Capability interface (issue #60). Use for capability-level audit, usage metrics, per-capability rate-limiting — concerns that span every role implementing the capability without each role having to know about them.

args is captured as List<Object> matching the dispatcher's reflective call shape. Implementations should treat the list as opaque and avoid mutating it.

Since:
0.5.0 (issue #60)
  • Constructor Details

    • OnCapabilityDispatch

      public OnCapabilityDispatch(String eventId, Instant timestamp, HookContext context, String capabilityInterface, String methodName, List<Object> args, ActionType dispatchType)
      Creates an instance of a OnCapabilityDispatch record class.
      Parameters:
      eventId - the value for the eventId record component
      timestamp - the value for the timestamp record component
      context - the value for the context record component
      capabilityInterface - the value for the capabilityInterface record component
      methodName - the value for the methodName record component
      args - the value for the args record component
      dispatchType - the value for the dispatchType record component
  • Method Details

    • eventType

      public String eventType()
      Description copied from interface: HookEvent
      Short 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.
      Specified by:
      eventType in interface HookEvent
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • eventId

      public String eventId()
      Returns the value of the eventId record component.
      Specified by:
      eventId in interface HookEvent
      Returns:
      the value of the eventId record component
    • timestamp

      public Instant timestamp()
      Returns the value of the timestamp record component.
      Specified by:
      timestamp in interface HookEvent
      Returns:
      the value of the timestamp record component
    • context

      public HookContext context()
      Returns the value of the context record component.
      Specified by:
      context in interface HookEvent
      Returns:
      the value of the context record component
    • capabilityInterface

      public String capabilityInterface()
      Returns the value of the capabilityInterface record component.
      Returns:
      the value of the capabilityInterface record component
    • methodName

      public String methodName()
      Returns the value of the methodName record component.
      Returns:
      the value of the methodName record component
    • args

      public List<Object> args()
      Returns the value of the args record component.
      Returns:
      the value of the args record component
    • dispatchType

      public ActionType dispatchType()
      Returns the value of the dispatchType record component.
      Returns:
      the value of the dispatchType record component