/** * [WHO]: TeamMailbox, MailboxMessage, MailboxMessageType, MailboxDirection * [FROM]: No external deps * [TO]: Consumed by team-runtime.ts, index.ts * [HERE]: extensions/builtin/team/team-mailbox.ts - Phase B B.3 mailbox protocol * * Per refactor plan §B.3: mailbox is the single channel between the leader * and teammates; no direct callbacks are allowed. The implementation is a * typed append-only log with subscribe() for live observers and JSONL-backed * replay across restarts. */ export type MailboxMessageType = "task_request" | "task_progress" | "task_result" | "permission_request" | "permission_response" | "plan_approval_request" | "plan_approval_response" | "teammate_message" | "handoff" | "task_claim" | "task_update" | "mode_change" | "shutdown_request" | "shutdown_ack"; export type MailboxDirection = "leader_to_teammate" | "teammate_to_leader" | "teammate_to_teammate"; export interface MailboxMessage { id: string; teammateId: string; teammateName: string; targetTeammateId?: string; targetTeammateName?: string; type: MailboxMessageType; direction: MailboxDirection; payload: Record; timestamp: number; } export type MailboxListener = (message: MailboxMessage) => void; /** * Append-only typed mailbox shared by all teammates. Bounded by * `maxMessages` to prevent unbounded growth in long-lived sessions; oldest * messages drop first. */ export declare class TeamMailbox { private messages; private listeners; private readonly maxMessages; private readonly filePath?; constructor(maxMessages?: number, filePath?: string); /** Load persisted JSONL messages. Corrupt lines are ignored. */ load(): Promise; /** Post a new message and notify listeners. */ post(message: Omit): MailboxMessage; /** All messages, optionally filtered by teammate id. */ list(teammateId?: string): MailboxMessage[]; /** Subscribe to live mailbox events. Returns an unsubscribe handle. */ subscribe(listener: MailboxListener): () => void; /** Drop all messages owned by a teammate (called on terminate). */ clearTeammate(teammateId: string): void; private persist; /** Remove persisted mailbox data. Intended for tests and full team reset flows. */ clearAll(): Promise; }