/** * Room context backlog. * * Room messages an agent should know about but not answer * (specs/2026-10-03-one-responder-per-message.md "Everyone else: context * only"). Instead of a turn of their own — which would wake a sleeping agent * or spend a full prompt on "do nothing" — they wait here and are put at the * top of the agent's next prompt from the same room. * * In memory and bounded: a restart loses it, which is acceptable because the * Slack thread context still shows the thread when the agent is next * addressed there. * * @module services/chat-v2/room-context-backlog */ /** One queued room message. */ export interface RoomContextEntry { /** The chat message id (deduplicates a hand-off re-route) */ messageId: string; /** Who wrote it, as the prompt names them */ sender: string; /** The message text */ content: string; /** Thread root id it belongs to, when it is a thread reply */ threadId?: string; /** Who is answering it, when anyone is (display name) */ responderName?: string; /** Epoch ms when it was queued */ at: number; } /** Constructor options. */ export interface RoomContextBacklogOptions { /** Clock override for tests */ now?: () => number; } /** * The line the prompt shows for one entry. * * @param entry - The queued message * @returns One English line */ export declare function contextOnlyLine(entry: Pick): string; /** * Render queued entries as the block that goes at the top of a prompt. * * @param entries - Entries, oldest first * @returns The block, or '' when there are none */ export declare function renderContextOnlyBlock(entries: readonly RoomContextEntry[]): string; /** * Per (agent, room) queue of context-only messages. */ export declare class RoomContextBacklog { private readonly queues; private readonly now; constructor(options?: RoomContextBacklogOptions); private static key; /** * Queue a message for an agent, to be shown on its next prompt from this room. * * @param agentSession - The agent * @param channelId - The room (chat-v2 channel id) * @param entry - The message (its `at` is set here) */ add(agentSession: string, channelId: string, entry: Omit): void; /** * Take (and clear) what an agent has queued for a room. * * @param agentSession - The agent * @param channelId - The room * @param excludeMessageId - The message being delivered now (never shown as its own context) * @returns Entries, oldest first */ take(agentSession: string, channelId: string, excludeMessageId?: string): RoomContextEntry[]; /** * Put entries back after a delivery failed, ahead of anything queued since. * * @param agentSession - The agent * @param channelId - The room * @param entries - What {@link take} returned */ restore(agentSession: string, channelId: string, entries: readonly RoomContextEntry[]): void; /** * What an agent has queued for a room, without taking it (tests, diagnostics). * * @param agentSession - The agent * @param channelId - The room * @returns Entries, oldest first */ peek(agentSession: string, channelId: string): RoomContextEntry[]; private fresh; } //# sourceMappingURL=room-context-backlog.d.ts.map