Package com.tnsai.events
Record Class ApprovalRequestEvent
java.lang.Object
java.lang.Record
com.tnsai.events.ApprovalRequestEvent
- Record Components:
eventId- unique identifier for this eventtimestamp- when the event occurredrequestId- unique identifier for this approval requestactionName- the action requiring approvalactionDescription- human-readable description of the actionparameters- the action parameterstimeoutMs- timeout in milliseconds (0 = no timeout)metadata- additional context for the approval UI
- All Implemented Interfaces:
TnsAIEvent
public record ApprovalRequestEvent(String eventId, Instant timestamp, String requestId, String actionName, String actionDescription, Map<String,Object> parameters, long timeoutMs, Map<String,Object> metadata)
extends Record
implements TnsAIEvent
Event requesting human approval for an action.
ApprovalRequestEvent enables human-in-the-loop workflows where certain actions require explicit user confirmation before execution.
Use cases:
- Confirming sensitive operations (delete, send email, make payment)
- Reviewing generated content before publishing
- Approving decisions that affect external systems
The agent execution pauses until approval is received via:
POST /v1/runs/{runId}/approval
{"requestId": "...", "approved": true/false, "feedback": "..."}
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longDefault timeout for approval requests (30 seconds). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theactionDescriptionrecord component.Returns the value of theactionNamerecord component.final booleanIndicates whether some other object is "equal to" this one.eventId()Returns the value of theeventIdrecord component.final inthashCode()Returns a hash code value for this object.metadata()Returns the value of themetadatarecord component.static ApprovalRequestEventCreates an approval request event.Returns the value of theparametersrecord component.Returns the value of therequestIdrecord component.longReturns the value of thetimeoutMsrecord component.Returns the value of thetimestamprecord component.final StringtoString()Returns a string representation of this record class.static ApprovalRequestEventwithSpec(String actionName, String actionDescription, Map<String, Object> parameters, Map<String, Object> metadata) Creates an approval request with metadata for UI customization.static ApprovalRequestEventwithTimeout(String actionName, String actionDescription, Map<String, Object> parameters, long timeoutMs) Creates an approval request with custom timeout.Methods inherited from interface com.tnsai.events.TnsAIEvent
eventType
-
Field Details
-
DEFAULT_TIMEOUT_MS
public static final long DEFAULT_TIMEOUT_MSDefault timeout for approval requests (30 seconds).- See Also:
-
-
Constructor Details
-
ApprovalRequestEvent
public ApprovalRequestEvent(String eventId, Instant timestamp, String requestId, String actionName, String actionDescription, Map<String, Object> parameters, long timeoutMs, Map<String, Object> metadata) Creates an instance of aApprovalRequestEventrecord class.- Parameters:
eventId- the value for theeventIdrecord componenttimestamp- the value for thetimestamprecord componentrequestId- the value for therequestIdrecord componentactionName- the value for theactionNamerecord componentactionDescription- the value for theactionDescriptionrecord componentparameters- the value for theparametersrecord componenttimeoutMs- the value for thetimeoutMsrecord componentmetadata- the value for themetadatarecord component
-
-
Method Details
-
of
public static ApprovalRequestEvent of(String actionName, String actionDescription, Map<String, Object> parameters) Creates an approval request event.- Parameters:
actionName- the action nameactionDescription- description for the userparameters- the action parameters- Returns:
- new ApprovalRequestEvent
-
withTimeout
public static ApprovalRequestEvent withTimeout(String actionName, String actionDescription, Map<String, Object> parameters, long timeoutMs) Creates an approval request with custom timeout.- Parameters:
actionName- the action nameactionDescription- description for the userparameters- the action parameterstimeoutMs- timeout in milliseconds- Returns:
- new ApprovalRequestEvent
-
withSpec
public static ApprovalRequestEvent withSpec(String actionName, String actionDescription, Map<String, Object> parameters, Map<String, Object> metadata) Creates an approval request with metadata for UI customization.- Parameters:
actionName- the action nameactionDescription- description for the userparameters- the action parametersmetadata- UI customization data (severity, icon, etc.)- Returns:
- new ApprovalRequestEvent
-
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
eventId
Returns the value of theeventIdrecord component.- Specified by:
eventIdin interfaceTnsAIEvent- Returns:
- the value of the
eventIdrecord component
-
timestamp
Returns the value of thetimestamprecord component.- Specified by:
timestampin interfaceTnsAIEvent- Returns:
- the value of the
timestamprecord component
-
requestId
Returns the value of therequestIdrecord component.- Returns:
- the value of the
requestIdrecord component
-
actionName
Returns the value of theactionNamerecord component.- Returns:
- the value of the
actionNamerecord component
-
actionDescription
Returns the value of theactionDescriptionrecord component.- Returns:
- the value of the
actionDescriptionrecord component
-
parameters
Returns the value of theparametersrecord component.- Returns:
- the value of the
parametersrecord component
-
timeoutMs
public long timeoutMs()Returns the value of thetimeoutMsrecord component.- Returns:
- the value of the
timeoutMsrecord component
-
metadata
Returns the value of themetadatarecord component.- Returns:
- the value of the
metadatarecord component
-