/** * team/mailbox — JSONL-based mailbox for inter-agent communication. * * Each team run has a shared mailbox directory under .pi/swarm/mailbox/ * where agents write messages (outbox) and read messages (inbox). */ import type { MailboxMessage } from "../shared/types.js"; /** * Resolve mailbox paths for a team run. * * {swarmRoot}/state/runs/{runId}/mailbox/ * inbox.jsonl — team-level inbox * outbox.jsonl — team-level outbox * delivery.json — delivery state * tasks/{taskId}/ * inbox.jsonl — per-task inbox * outbox.jsonl — per-task outbox */ export interface MailboxPaths { readonly root: string; readonly inbox: string; readonly outbox: string; readonly delivery: string; readonly taskDir: string; readonly inboxAcks: string; } export declare function resolveMailboxPaths(swarmRoot: string, runId: string): MailboxPaths; export declare function resolveTaskMailboxPaths(paths: MailboxPaths, taskId: string): { inbox: string; outbox: string; }; /** * Ensure the mailbox directory structure exists. */ export declare function ensureMailbox(paths: MailboxPaths): void; /** * Send a message to the team outbox and the recipient's per-task inbox. * For broadcast messages, also deliver to all known role inboxes. * * Transactional guarantees (#108, #113): * - For direct messages, the recipient's task directory must already exist. * If it does not, sendMessage throws BEFORE writing to outbox or inbox, * leaving no partial state behind. * - No phantom task directories are created for unknown recipients. * * Broadcast error surfacing (#115): * - Per-recipient delivery failures during broadcast are surfaced to the * caller instead of being silently swallowed. If any recipient's inbox * cannot be written, sendMessage throws so the caller can retry or report. */ export declare function sendMessage(paths: MailboxPaths, message: MailboxMessage): void; /** * Read unacknowledged messages from the team inbox. */ export declare function readInbox(paths: MailboxPaths): MailboxMessage[]; /** * Read messages from a task-specific inbox. */ export declare function readTaskInbox(paths: MailboxPaths, taskId: string): MailboxMessage[]; /** * Count total messages in the team outbox. */ export declare function countOutboxMessages(paths: MailboxPaths): number; /** * Get delivery state (which messages have been delivered/read). */ export declare function getDeliveryState(paths: MailboxPaths): Record; //# sourceMappingURL=mailbox.d.ts.map