hitl

package
v0.1.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 10, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

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

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

func (s *NotifierStore) GetPending(ctx context.Context, senderContext string) (string, bool)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL