Package com.tnsai.hooks.events
Record Class PreAction
java.lang.Object
java.lang.Record
com.tnsai.hooks.events.PreAction
- Record Components:
eventId- ULID-shaped correlation idtimestamp- when the event was constructedcontext- surrounding hook contextrequest- typed request about to be dispatched — Modify-abletype- dispatch channel (LLM,TOOL, …)
- All Implemented Interfaces:
ActionHookEvent,HookEvent
public record PreAction(String eventId, Instant timestamp, HookContext context, ActionRequest request, ActionType type)
extends Record
implements ActionHookEvent
Fires before
ActionExecutor routes any action (issue #59).
Carries the typed ActionRequest and the resolved
ActionType so hooks can match on dispatch channel (LLM /
MCP_TOOL / WEB_SERVICE / LOCAL) and branch policy per-channel.
Hooks may Block the
action outright (tenant quota hit, cost budget exceeded) or
Modify the request's
parameters via withRequest(ActionRequest) (argument scrub,
policy-driven rewrite).
- Since:
- 0.5.0 (issue #59)
-
Constructor Summary
ConstructorsConstructorDescriptionPreAction(String eventId, Instant timestamp, HookContext context, ActionRequest request, ActionType type) Creates an instance of aPreActionrecord 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.request()Returns the value of therequestrecord component.Returns the value of thetimestamprecord component.final StringtoString()Returns a string representation of this record class.type()Returns the value of thetyperecord component.withRequest(ActionRequest newRequest) Build a copy withnewRequestreplacingrequest.
-
Constructor Details
-
PreAction
public PreAction(String eventId, Instant timestamp, HookContext context, ActionRequest request, ActionType type) Creates an instance of aPreActionrecord class.
-
-
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. -
withRequest
Build a copy withnewRequestreplacingrequest. -
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. -
request
Returns the value of therequestrecord component.- Returns:
- the value of the
requestrecord component
-
type
Returns the value of thetyperecord component.- Returns:
- the value of the
typerecord component
-