Documentation
¶
Overview ¶
Package mail implements inter-AI messaging.
Architecture:
- internal/mail — Core domain logic (this package)
- internal/toolcall/mail — LLM tool registration & argument parsing
The mail system enables explicit communication between AI maintainers. Each AI is identified by a name_id (from ai_names table). Senders are determined from the current session via ainame.GetNameID(). Recipients are looked up by case-insensitive name_en or email.
Data Model:
mail — id, sender_name_id, recipient_name_id, subject, body, is_read, created_at mail_fts — FTS5 external content table over mail(subject, body)
Handlers:
HandleSendMail — Send a mail to another maintainer by name/email HandleReadMail — Read mails (list or single) for the current maintainer HandleMailSearch — FTS5 search across mails HandleReplyMail — Reply to an existing mail HandleDeleteMail — Delete a mail (recipient only) HandleContacts — List all known contacts from ai_names
Package mail implements an inter-AI messaging system backed by SQLite.
Architecture:
The mail system is split into two layers:
- internal/mail — Core domain logic (this package)
- internal/toolcall/mail — LLM tool registration & argument parsing
Mail enables explicit communication between AI maintainers. Each AI is identified by a name_id (from ai_names). Senders are determined from the current session via ainame.GetNameID(). Recipients are looked up by case-insensitive name or email.
Schema:
mail — id, sender_name_id, recipient_name_id, subject, body, is_read, created_at mail_fts — FTS5 external content table over mail(subject, body)
FTS sync is managed explicitly in Go (not via SQL triggers), so that Chinese content is tokenized with gse before insertion — ensuring the same tokenization on both index and query sides.
Handlers:
HandleSendMail — Send a mail to another maintainer by name HandleReadMail — Read mails for the current maintainer HandleMailSearch — FTS5 search across mails HandleContacts — List contacts with assigned projects
Index ¶
- func HandleContacts(ctx context.Context) (result, warning string, err error)
- func HandleDeleteMail(ctx context.Context, mailID int64) (result, warning string, err error)
- func HandleMailSearch(ctx context.Context, query string, limit int) (result, warning string, err error)
- func HandleReadMail(ctx context.Context, mailID int64, unreadOnly bool, limit int) (result, warning string, err error)
- func HandleReplyMail(ctx context.Context, replyToID int64, subject, body string) (result, warning string, err error)
- func HandleSendMail(ctx context.Context, recipient, subject, body string) (result, warning string, err error)
- type MailRow
- type MaintainerRow
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HandleContacts ¶
HandleContacts lists contacts that have been assigned to at least one project, along with their project assignments.
func HandleDeleteMail ¶
HandleDeleteMail deletes a mail by ID. Only the recipient (current user) can delete their own mails.
func HandleMailSearch ¶
func HandleMailSearch(ctx context.Context, query string, limit int) (result, warning string, err error)
HandleMailSearch searches mails using FTS5.
func HandleReadMail ¶
func HandleReadMail(ctx context.Context, mailID int64, unreadOnly bool, limit int) (result, warning string, err error)
HandleReadMail reads mail for the current maintainer. mailID > 0: read specific mail; mailID == 0: list mails (with optional unreadOnly filter).
func HandleReplyMail ¶
func HandleReplyMail(ctx context.Context, replyToID int64, subject, body string) (result, warning string, err error)
HandleReplyMail replies to an existing mail. The recipient is automatically set to the original mail's sender. If subject is empty, "Re: <original subject>" is used.
Types ¶
type MailRow ¶
type MailRow struct {
ID int64 `json:"id"`
SenderName string `json:"sender_name"`
SenderEmail string `json:"sender_email"`
RecipientName string `json:"recipient_name"`
RecipientEmail string `json:"recipient_email"`
Subject string `json:"subject"`
Body string `json:"body"`
IsRead bool `json:"is_read"`
CreatedAt string `json:"created_at"`
}
MailRow represents a single mail message.
Source Files
¶
- doc.go
- mail.go