MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / buildPendingApprovalEvent

Method buildPendingApprovalEvent

internal/agent/webhooks_api.go:73–101  ·  view source on GitHub ↗

buildPendingApprovalEvent fires when a HITL-enabled agent holds an outbound message for human review. msg is the pending row; req is the composed SendRequest that produced it.

(
	agent *identity.AgentIdentity,
	msg *identity.Message,
	req outbound.SendRequest,
	msgType string,
)

Source from the content-addressed store, hash-verified

71// outbound message for human review. msg is the pending row; req is
72// the composed SendRequest that produced it.
73func (a *API) buildPendingApprovalEvent(
74 agent *identity.AgentIdentity,
75 msg *identity.Message,
76 req outbound.SendRequest,
77 msgType string,
78) webhookpub.Event {
79 data := map[string]interface{}{
80 "message_id": msg.ID,
81 "direction": "outbound",
82 "from": agent.EmailAddress(),
83 "to": req.To,
84 "cc": req.CC,
85 "bcc": req.BCC,
86 "subject": req.Subject,
87 "type": msgType,
88 "conversation_id": req.ConversationID,
89 "approval_expires_at": msg.ApprovalExpiresAt,
90 }
91 return webhookpub.Event{
92 ID: generateEventIDForAgent(),
93 Type: webhookpub.EventEmailPendingReview,
94 CreatedAt: time.Now().UTC(),
95 UserID: agent.UserID,
96 AgentID: agent.ID,
97 ConversationID: req.ConversationID,
98 MessageID: msg.ID,
99 Data: data,
100 }
101}
102
103// buildApprovedEvent fires after ApproveAndSend hands the message to
104// SES. sent carries the post-approve message row (now status=sent).

Callers 2

HoldForApprovalCoreMethod · 0.95

Calls 2

generateEventIDForAgentFunction · 0.85
EmailAddressMethod · 0.80

Tested by 1