Documentation
¶
Index ¶
- Constants
- func DeliveredMessageIDs(messages []awid.ChatMessage) []string
- func FilterDeliveredMessages(messages []awid.ChatMessage) []awid.ChatMessage
- func LoadDeliveredIDs() (map[string]struct{}, error)
- func LoadDeliveredIDsForDir(startDir string) (map[string]struct{}, error)
- func SaveDeliveredIDs(ids []string) error
- func SaveDeliveredIDsForDir(startDir string, ids []string) error
- type Event
- type ExtendWaitResult
- type HistoryResult
- type OpenResult
- type PendingConversation
- type PendingResult
- type SendOptions
- type SendResult
- func Listen(ctx context.Context, client *awid.Client, targetAlias string, waitSeconds int, ...) (*SendResult, error)
- func Send(ctx context.Context, client *awid.Client, myAlias string, targets []string, ...) (*SendResult, error)
- func ShowPending(ctx context.Context, client *awid.Client, targetAlias string) (*SendResult, error)
- type StatusCallback
Constants ¶
const ( DeliveredIDsFileName = "chat-delivered-ids.json" DeliveredIDsPathEnv = "AW_CHAT_DELIVERED_IDS_PATH" )
const DefaultWait = 120 // Default wait timeout in seconds for replies
const MaxSendTimeout = 16 * time.Minute
MaxSendTimeout is the maximum duration a Send() call can take, accounting for all possible wait extensions.
Variables ¶
This section is empty.
Functions ¶
func DeliveredMessageIDs ¶ added in v1.2.0
func DeliveredMessageIDs(messages []awid.ChatMessage) []string
func FilterDeliveredMessages ¶ added in v1.2.0
func FilterDeliveredMessages(messages []awid.ChatMessage) []awid.ChatMessage
func LoadDeliveredIDs ¶ added in v1.2.0
func LoadDeliveredIDsForDir ¶ added in v1.2.0
func SaveDeliveredIDs ¶ added in v1.2.0
func SaveDeliveredIDsForDir ¶ added in v1.2.0
Types ¶
type Event ¶
type Event struct {
Type string `json:"type"`
Agent string `json:"agent,omitempty"`
SessionID string `json:"session_id,omitempty"`
MessageID string `json:"message_id,omitempty"`
FromAgent string `json:"from_agent,omitempty"`
FromAddress string `json:"from_address,omitempty"`
ToAddress string `json:"to_address,omitempty"`
Body string `json:"body,omitempty"`
By string `json:"by,omitempty"`
Reason string `json:"reason,omitempty"`
Timestamp string `json:"timestamp,omitempty"`
SenderLeaving bool `json:"sender_leaving,omitempty"`
SenderWaiting bool `json:"sender_waiting,omitempty"`
ReaderAlias string `json:"reader_alias,omitempty"`
ExtendWait bool `json:"hang_on,omitempty"`
ExtendsWaitSeconds int `json:"extends_wait_seconds,omitempty"`
ReplyToMessageID string `json:"reply_to_message_id,omitempty"`
// Identity fields for message verification.
FromDID string `json:"from_did,omitempty"`
ToDID string `json:"to_did,omitempty"`
FromStableID string `json:"from_stable_id,omitempty"`
ToStableID string `json:"to_stable_id,omitempty"`
Signature string `json:"signature,omitempty"`
SigningKeyID string `json:"signing_key_id,omitempty"`
RotationAnnouncement *awid.RotationAnnouncement `json:"rotation_announcement,omitempty"`
ReplacementAnnouncement *awid.ReplacementAnnouncement `json:"replacement_announcement,omitempty"`
VerificationStatus awid.VerificationStatus `json:"verification_status,omitempty"`
IsContact *bool `json:"is_contact,omitempty"`
}
Event represents an event received during chat (message or read receipt).
type ExtendWaitResult ¶ added in v0.7.0
type ExtendWaitResult struct {
SessionID string `json:"session_id"`
TargetAgent string `json:"target_agent"`
Message string `json:"message"`
ExtendsWaitSeconds int `json:"extends_wait_seconds"`
}
ExtendWaitResult is the result of an extend-wait acknowledgment.
func ExtendWait ¶ added in v0.7.0
func ExtendWait(ctx context.Context, client *awid.Client, targetAlias string, message string) (*ExtendWaitResult, error)
ExtendWait sends an extend-wait message requesting more time to reply.
type HistoryResult ¶
type HistoryResult struct {
SessionID string `json:"session_id"`
Messages []Event `json:"messages"`
}
HistoryResult is the result of fetching chat history.
type OpenResult ¶
type OpenResult struct {
SessionID string `json:"session_id"`
TargetAgent string `json:"target_agent"`
Messages []Event `json:"messages"`
MarkedRead int `json:"marked_read"`
SenderWaiting bool `json:"sender_waiting"`
UnreadWasEmpty bool `json:"unread_was_empty,omitempty"`
}
OpenResult is the result of opening unread messages for a conversation.
type PendingConversation ¶
type PendingConversation struct {
SessionID string `json:"session_id"`
Participants []string `json:"participants"`
ParticipantDIDs []string `json:"participant_dids,omitempty"`
ParticipantAddresses []string `json:"participant_addresses,omitempty"`
LastMessage string `json:"last_message"`
LastFrom string `json:"last_from"`
LastFromStableID string `json:"last_from_stable_id,omitempty"`
LastFromDID string `json:"last_from_did,omitempty"`
LastFromAddress string `json:"last_from_address,omitempty"`
UnreadCount int `json:"unread_count"`
LastActivity string `json:"last_activity"`
SenderWaiting bool `json:"sender_waiting"`
TimeRemainingSeconds *int `json:"time_remaining_seconds"`
}
PendingConversation represents a conversation with unread messages.
type PendingResult ¶
type PendingResult struct {
Pending []PendingConversation `json:"pending"`
MessagesWaiting int `json:"messages_waiting"`
}
PendingResult is the result of checking pending conversations.
type SendOptions ¶
type SendOptions struct {
Wait int // Seconds to wait for reply (0 = no wait)
WaitExplicit bool // true if caller explicitly set Wait
Leaving bool // Sender is leaving the conversation
StartConversation bool // Ignore targets_left, use 5min default wait
}
SendOptions configures message sending behavior.
type SendResult ¶
type SendResult struct {
SessionID string `json:"session_id"`
Status string `json:"status"` // sent, replied, sender_left, pending, targets_left, timeout
TargetAgent string `json:"target_agent,omitempty"`
Reply string `json:"reply,omitempty"`
Events []Event `json:"events"`
Error string `json:"error,omitempty"`
TargetNotConnected bool `json:"target_not_connected,omitempty"`
SenderWaiting bool `json:"sender_waiting,omitempty"`
WaitedSeconds int `json:"waited_seconds,omitempty"`
}
SendResult is the result of sending a message and optionally waiting for a reply.
func Listen ¶ added in v0.4.0
func Listen(ctx context.Context, client *awid.Client, targetAlias string, waitSeconds int, callback StatusCallback) (*SendResult, error)
Listen waits for a message in an existing conversation without sending. Returns on any message in the session (not filtered by sender).
func Send ¶
func Send(ctx context.Context, client *awid.Client, myAlias string, targets []string, message string, opts SendOptions, callback StatusCallback) (*SendResult, error)
Send sends a message to target agents and optionally waits for a reply.
Wait logic:
- opts.Leaving: send with leaving=true, exit immediately
- opts.Wait == 0: send, return immediately
- opts.StartConversation: ignore targets_left, use 5min wait unless WaitExplicit
- default: send, if all targets in targets_left → skip wait; else wait opts.Wait seconds
func ShowPending ¶
ShowPending shows the pending conversation with a specific agent.
type StatusCallback ¶
StatusCallback receives protocol status updates. kind is one of: "read_receipt", "extend_wait", "wait_extended".