/** * Name-addressed durable mailbox. * * Peer messaging used to require a live recipient: the sender resolved a name * to a running instance and wrote into that instance's journal. Two failures * followed from that. A message to a name whose session had ended was refused * outright, so the sender spent a long sequence of discovery calls looking for * somewhere else to put it. A message to a live peer was accepted but never * shown to them, because nothing surfaces another session's journal. * * This module addresses the durable persona name instead of the instance, so a * message can be queued before its recipient exists. Delivery happens on the * recipient's side: their next SessionStart or prompt drains the queue, shows * the messages, and records them in their journal. * * Storage: `.harnery/mailbox/.jsonl`, one JSON record per line, appended * by senders and removed by an atomic claim on the recipient's side. Delivered * records are appended to `.harnery/mailbox/delivered/.jsonl` for audit. * * Related but distinct: `core/inbox` is an instance-keyed transport with a * storage-framework service behind it. This mailbox is name-keyed, file-only, * and follows the same shape as council manifests and journals. */ export declare const MAILBOX_MESSAGE_SCHEMA: "harnery.mailbox-message/v1"; /** Per-message body ceiling. Larger payloads belong in a managed artifact, with * the path sent as the message. */ export declare const MAX_BODY_BYTES = 4000; /** Pending messages held for one name before senders are refused. */ export declare const MAX_PENDING = 25; export interface MailboxMessageV1 { schema: typeof MAILBOX_MESSAGE_SCHEMA; message_id: string; /** Bare display name the sender addressed (registry casing when known). */ to_name: string; from_name: string; from_instance_id: string; created_at: string; body: string; /** True when the sender already appended this to a live recipient's journal, * so the drain surfaces it without writing a duplicate entry. */ journaled: boolean; } export type MailboxCapacityReason = "body_limit" | "pending_limit"; export declare class MailboxCapacityError extends Error { readonly reason_code: MailboxCapacityReason; readonly current: number; readonly limit: number; constructor(reason_code: MailboxCapacityReason, current: number, limit: number); } /** Strip an `agent-` prefix and normalize to the registry's bare form. */ export declare function bareAgentName(raw: string): string; export declare function mailboxDir(coordRoot: string): string; export declare function mailboxPath(coordRoot: string, name: string): string; /** Every name a message may be addressed to: live sessions, the durable * identity registry, and the built-in name pool. A name outside all three is a * typo, and queueing it would silently swallow the message. */ export declare function isAddressableName(coordRoot: string, name: string): boolean; /** Names close enough to a miss to be worth suggesting (prefix or one edit). */ export declare function suggestNames(coordRoot: string, name: string, limit?: number): string[]; export interface QueueInput { coordRoot: string; toName: string; fromName: string; fromInstanceId: string; body: string; journaled?: boolean; } export interface QueueResult { message: MailboxMessageV1; path: string; pending: number; } /** * Append one message to a name's mailbox. Throws `MailboxCapacityError` when * the body or the pending queue is over its ceiling; the caller turns that into * an actionable CLI error. */ export declare function queueMailboxMessage(input: QueueInput): QueueResult; /** Pending messages for a name, without claiming them. */ export declare function peekMailbox(coordRoot: string, name: string): MailboxMessageV1[]; /** * Claim and return every pending message for a name. * * The claim is an atomic rename, so two sessions sharing a name cannot deliver * the same message twice: whichever rename wins owns the batch. Claimed records * are appended to the delivered archive before the claim file is removed, so a * crash between the two leaves an auditable copy rather than a silent loss. */ export declare function drainMailbox(coordRoot: string, name: string): MailboxMessageV1[]; /** Render a drained batch as the context block a recipient reads. */ export declare function formatMailboxDelivery(coordRoot: string, messages: readonly MailboxMessageV1[]): string; //# sourceMappingURL=mailbox.d.ts.map