Documentation
¶
Index ¶
- type NotifierStore
- func (s *NotifierStore) Close() error
- func (s *NotifierStore) Create(ctx context.Context, req hitl.CreateRequest) (hitl.ApprovalRequest, error)
- func (s *NotifierStore) ExpireStale(ctx context.Context) (int64, error)
- func (s *NotifierStore) Get(ctx context.Context, approvalID string) (hitl.ApprovalRequest, error)
- func (s *NotifierStore) GetPending(ctx context.Context, senderContext string) (string, bool)
- func (s *NotifierStore) GetPendingByMessageID(ctx context.Context, quotedMsgID string) (string, bool)
- func (s *NotifierStore) IsAllowed(toolName string) bool
- func (s *NotifierStore) ListPending(ctx context.Context) ([]hitl.ApprovalRequest, error)
- func (s *NotifierStore) RecoverPending(ctx context.Context, maxAge time.Duration) (hitl.RecoverResult, error)
- func (s *NotifierStore) RemovePending(ctx context.Context, senderContext string)
- func (s *NotifierStore) RemovePendingByApprovalID(ctx context.Context, senderContext, approvalID string)
- func (s *NotifierStore) Resolve(ctx context.Context, req hitl.ResolveRequest) error
- func (s *NotifierStore) WaitForResolution(ctx context.Context, approvalID string) (hitl.ApprovalRequest, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NotifierStore ¶
type NotifierStore struct {
// contains filtered or unexported fields
}
NotifierStore wraps an ApprovalStore to send notifications via Messenger. This struct exists to add a notification layer on top of the persistence layer, ensuring users are alerted when manual intervention is required. Without this wrapper, users would have to manually check the AG-UI or logs to know that the agent is waiting for approval.
func NewNotifierStore ¶
func NewNotifierStore(realStore hitl.ApprovalStore, m messenger.Messenger) *NotifierStore
NewNotifierStore creates a new NotifierStore. This function exists to instantiate the wrapper with its necessary dependencies. Without this function, callers would have to manually construct the struct, which is error-prone and exposes internal fields.
func (*NotifierStore) Close ¶
func (s *NotifierStore) Close() error
Close delegates to the real store. This method exists to clean up resources held by the underlying store. Without this method, database connections or file handles might leak.
func (*NotifierStore) Create ¶
func (s *NotifierStore) Create(ctx context.Context, req hitl.CreateRequest) (hitl.ApprovalRequest, error)
Create persists the approval and sends a notification if a valid sender context is present. This method exists to intercept the approval creation process and trigger a side-effect (notification). Without this method, the approval would be stored silently, and the user would not be notified via their chat platform.
func (*NotifierStore) ExpireStale ¶
func (s *NotifierStore) ExpireStale(ctx context.Context) (int64, error)
ExpireStale delegates to the real store to mark pending approvals past their deadline as expired. Without this delegation the background reaper goroutine would bypass the NotifierStore wrapper and stale approvals would never be cleaned up.
func (*NotifierStore) Get ¶
func (s *NotifierStore) Get(ctx context.Context, approvalID string) (hitl.ApprovalRequest, error)
Get delegates to the real store to return the approval by ID.
func (*NotifierStore) GetPending ¶
GetPending returns the oldest pending approval ID for the given sender context. Returns ("", false) when no approvals are queued.
func (*NotifierStore) GetPendingByMessageID ¶
func (s *NotifierStore) GetPendingByMessageID(ctx context.Context, quotedMsgID string) (string, bool)
GetPendingByMessageID resolves the approval ID associated with an outgoing notification message. When a user swipe-replies to a specific approval notification, the incoming message contains the quoted message ID which maps to the approval via this method.
func (*NotifierStore) IsAllowed ¶
func (s *NotifierStore) IsAllowed(toolName string) bool
func (*NotifierStore) ListPending ¶
func (s *NotifierStore) ListPending(ctx context.Context) ([]hitl.ApprovalRequest, error)
ListPending delegates to the real store to return all currently pending approval requests. Without this delegation the GUILD API would be unable to discover which tool calls are awaiting human approval when the NotifierStore wrapper is in use.
func (*NotifierStore) RecoverPending ¶
func (s *NotifierStore) RecoverPending(ctx context.Context, maxAge time.Duration) (hitl.RecoverResult, error)
RecoverPending delegates to the real store.
func (*NotifierStore) RemovePending ¶
func (s *NotifierStore) RemovePending(ctx context.Context, senderContext string)
RemovePending removes the oldest approval from the sender's pending queue and cleans up any associated messageToApproval entries.
func (*NotifierStore) RemovePendingByApprovalID ¶
func (s *NotifierStore) RemovePendingByApprovalID(ctx context.Context, senderContext, approvalID string)
RemovePendingByApprovalID removes a specific approval ID from the sender's queue (used when reply-to routing resolves a non-oldest approval).
func (*NotifierStore) Resolve ¶
func (s *NotifierStore) Resolve(ctx context.Context, req hitl.ResolveRequest) error
Resolve delegates to the real store. This method exists to satisfy the ApprovalStore interface and pass through resolution requests. Without this method, NotifierStore relies on the embedded interface which might not behave as expected if not explicitly delegated.
func (*NotifierStore) WaitForResolution ¶
func (s *NotifierStore) WaitForResolution(ctx context.Context, approvalID string) (hitl.ApprovalRequest, error)
WaitForResolution delegates to the real store. This method exists to satisfy the ApprovalStore interface and block until approval/rejection. Without this method, the agent would not be able to wait for the user's decision.