Repository navigation
Description
Summary
Implement a mailbox system that gives each agent a persistent, async inbox.
Agents can send typed messages to each other without being co-located or running at the same time.
Depends on: #1 (AgentProfile)
Scope
internal/mailbox/mailbox.go— core types andMailboxinterfaceinternal/mailbox/sqlite.go— SQLite-backed implementation- No TUI in this issue — core layer only
Message types (proposed)
```go
type MessageKind string
const (
KindTask MessageKind = "task" // delegate a task to another agent
KindReply MessageKind = "reply" // reply to a previous message
KindBroadcast MessageKind = "broadcast" // fan-out to all agents in a team
KindEvent MessageKind = "event" // system event (agent started, finished, …)
)
type Message struct {
ID string
Kind MessageKind
FromAgent string // AgentProfile.ID
ToAgent string // AgentProfile.ID or "*" for broadcast
Subject string
Body string
ReplyTo string // parent Message.ID if this is a reply
CreatedAt time.Time
ReadAt *time.Time
}
```
Mailbox interface (proposed)
```go
type Mailbox interface {
Send(ctx context.Context, msg Message) error
Receive(ctx context.Context, agentID string) ([]Message, error) // unread messages
MarkRead(ctx context.Context, msgID string) error
History(ctx context.Context, agentID string, limit int) ([]Message, error)
}
```
Acceptance criteria
-
MessageandMessageKindtypes exported frominternal/mailbox -
Mailboxinterface defined - SQLite implementation with schema migration on first open
- Broadcast fan-out expands to individual messages per recipient
- Unit tests covering send, receive, mark-read, broadcast
- Thread-safe (concurrent sends from multiple goroutines)
Notes
- Start simple: no encryption, no TTL, no delivery guarantees beyond SQLite durability
- Broadcast
"*"resolves recipients at send time via the agent registry (feat: Agent definition — AgentProfile struct and registry #1) - ReplyTo forms a conversation thread — keep the schema flat (no nested tables)
Activity
feat(mailbox): persistent per-agent message inbox (#2)
feat(mailbox): persistent per-agent message inbox (#2)