import type { AgentPromptOptions, AgentResponse, AgentStreamResponse, AiMessage, ConversationalOverride, ConversationalSpec, ConversationStore } from './types.js'; /** * Internal hook that's awaited by the persistence helpers to find the * registered `ConversationStore`. Wired to `setConversationStore()` / * `AiProvider`'s `ai.conversations` DI binding via `agent.ts` — * provided here as a parameter to keep this file dependency-free. */ export type ConversationStoreLookup = () => ConversationStore | null | undefined; /** * Resolves the effective {@link ConversationalSpec} for a single * `prompt()` / `stream()` call. Returns `null` when the call should run * stateless (no auto-persist). * * Precedence (high → low): * 1. Per-call `options.conversation` — `false` opts out, a spec replaces * the agent's declaration. * 2. Agent's `conversational()` — supports sync OR async returns. * * The `ConversableAgent` (`forUser` / `continue`) flow does **not** go * through this resolver — it builds its own spec and calls the helper * directly so the explicit form always wins over both layers below. */ export declare function resolveAutoPersistSpec(agentDecl: () => false | ConversationalSpec | Promise, perCall: ConversationalOverride | undefined): Promise; /** * Thrown when a run scoped to one user tries to resume a thread another user * owns (#984). A distinct type so a server can answer 403 rather than 500, * and so a store failure is never mistaken for a refusal. */ export declare class ConversationOwnershipError extends Error { readonly conversationId: string; /** The user the run was scoped to. Never carries the real owner's id. */ readonly userId: string | undefined; constructor(conversationId: string, userId: string | undefined); } /** * Compose the new turn's messages from the user input + the steps the * agent loop produced. Mirrors the old `ConversableAgent.prompt` * persistence shape exactly so downstream stores see no behavioral change. */ export declare function newMessagesFromTurn(input: string, response: AgentResponse): AiMessage[]; /** * Wrap a non-streaming agent run with conversation persistence. Loads * history before, appends the new turn after, and stamps `conversationId` * onto the result. * * `inner` receives the merged options (with the loaded history pre-pended * to `options.history`) and is expected to invoke the actual agent loop. */ export declare function runWithPersistence(spec: ConversationalSpec, agentClassName: string, storeLookup: ConversationStoreLookup, input: string, options: AgentPromptOptions | undefined, inner: (effOptions: AgentPromptOptions | undefined) => Promise): Promise; /** * Wrap a streaming agent run with conversation persistence. Same shape as * {@link runWithPersistence}, but stitched into the * `AgentStreamResponse` `{ stream, response }` pair so the caller sees * stream chunks flowing first and the persisted result resolving last. */ export declare function runWithPersistenceStreaming(spec: ConversationalSpec, agentClassName: string, storeLookup: ConversationStoreLookup, input: string, options: AgentPromptOptions | undefined, inner: (effOptions: AgentPromptOptions | undefined) => AgentStreamResponse): AgentStreamResponse; //# sourceMappingURL=conversation-persistence.d.ts.map