import type { SharedSessionMessage, SharedSessionMessageRole, SharedSessionRecord } from './session-types.js'; export interface SharedSessionMessageStore { readonly sessions: Map; readonly messages: Map; } export interface AppendSharedSessionMessageInput { readonly sessionId: string; readonly role: SharedSessionMessageRole; readonly body: string; readonly surfaceKind?: SharedSessionMessage['surfaceKind'] | undefined; readonly surfaceId?: string | undefined; readonly routeId?: string | undefined; readonly agentId?: string | undefined; readonly userId?: string | undefined; readonly displayName?: string | undefined; readonly metadata?: Record | undefined; } export declare function listSharedSessionMessages(store: SharedSessionMessageStore, sessionId: string, limit?: number): SharedSessionMessage[]; /** * The stored completion message for `agentId` in this session, if one exists. * * An agent finishes ONCE, but more than one path reports that it finished: the * runtime event bus writes the terminal AGENT_COMPLETED / AGENT_FAILED / * AGENT_CANCELLED payload, and the daemon's pending-surface-reply poller writes * the same agent's rendered answer when it observes the finished record. Both * call the broker's completeAgent, so a conversation stored every assistant * reply twice, and because the next turn's prompt is built from that * transcript, the model was shown every one of its own answers twice. * * Matching is by agent id plus the presence of a terminal `status` in the * message metadata, which only the completion path writes. Reading it back off * the stored bucket rather than an in-memory set means a restart mid-flight * cannot lose the fact that the agent already reported. */ export declare function findAgentCompletionMessage(store: SharedSessionMessageStore, sessionId: string, agentId: string): SharedSessionMessage | undefined; /** * Whether this agent's completion still needs storing, or whether another * reporter already stored it. Logs the skip so a missing second row is * explained rather than mysterious. */ export declare function shouldStoreAgentCompletion(store: SharedSessionMessageStore, sessionId: string, agentId: string): boolean; export declare function appendSharedSessionMessage(store: SharedSessionMessageStore, input: AppendSharedSessionMessageInput, maxPersistedMessages: number): SharedSessionMessage; export declare function buildSharedSessionContinuationTask(input: { readonly session: SharedSessionRecord | null; readonly messages: readonly SharedSessionMessage[]; readonly fallbackSessionId: string; }): string; //# sourceMappingURL=session-broker-messages.d.ts.map