mail

package
v0.8.2 Latest Latest
Warning

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

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

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleContacts

func HandleContacts(ctx context.Context) (result, warning string, err error)

HandleContacts lists contacts that have been assigned to at least one project, along with their project assignments.

func HandleDeleteMail

func HandleDeleteMail(ctx context.Context, mailID int64) (result, warning string, err error)

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.

func HandleSendMail

func HandleSendMail(ctx context.Context, recipient, subject, body string) (result, warning string, err error)

HandleSendMail sends a mail to a recipient identified by name or email.

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.

type MaintainerRow

type MaintainerRow struct {
	ID       int64  `json:"id"`
	NameCN   string `json:"name_cn"`
	NameEN   string `json:"name_en"`
	BirdFrog string `json:"bird_frog"`
	Email    string `json:"email"`
}

MaintainerRow represents a maintainer from ai_names.

Source Files

  • doc.go
  • mail.go

Jump to

Keyboard shortcuts

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