import type { UIMessage, UIMessageChunk, UIMessageStreamWriter } from "ai"; /** Text part of a structured eve user message. */ export interface EveAgentTextPart { text: string; type: "text"; } /** A user message as eve's session routes accept it. */ export type EveAgentMessage = string | EveAgentTextPart[]; /** Turn-scoped context sent next to `message` as eve's `clientContext`. */ export type EveAgentClientContext = Record; /** * Stream position persisted on assistant messages. The browser keeps it * between turns; the session ID itself only lives in the httpOnly session * cookie, so `session` is a non-reversible tag of it. */ export interface EveAgentMessageMetadata { session: string; /** Absolute count of NDJSON events consumed from the session stream. */ streamIndex: number; } export interface EveAgentSession { sessionId: string; /** Stream index the next turn's events start at. */ startIndex: number; } export interface StreamEveAgentTurnOptions { /** Base URL of the deployed eve agent. */ agentUrl: string; /** Injectable fetch for tests. Defaults to the global `fetch`. */ fetchImpl?: typeof fetch; /** Resolved headers for every request to the agent. */ headers?: HeadersInit; /** * Chunks written immediately after `start` — used for locally computed * `source-url` citations. */ initialChunks?: UIMessageChunk[]; /** Session that received the turn, from `startOrContinueEveAgentSession`. */ session: EveAgentSession; /** * Tag of the session written to the finishing message metadata with the * next stream index. Without a tag no metadata is written, so the next * turn starts a fresh session. */ sessionTag?: string | null; /** Abort signal from the inbound request; triggers an eve cancel. */ signal?: AbortSignal; /** * Forward tool outputs and the citations found in them. When `false`, * tool results reach the client with a `null` output and no `source-url` * chunks. @default true */ toolCitations?: boolean; /** * Tool names whose calls are forwarded to the client. Calls to other * tools, and their results and citations, are dropped. Omit to forward * every tool. */ visibleTools?: readonly string[]; writer: UIMessageStreamWriter; } export declare const normalizeAgentUrl: (url: string) => string; /** * Stream position on the most recent assistant message before the trailing * user message. Only the most recent assistant message counts: a turn that * failed or was stopped carries no position, and resuming from an older one * would replay events. Legacy shapes (`{ sessionId, streamIndex }` objects * and opaque string tokens) read as no position. */ export declare const getEveAgentMessageMetadata: (messages: UIMessage[]) => EveAgentMessageMetadata | null; /** Whether any earlier assistant message records an eve turn. */ export declare const hasPriorEveAgentTurn: (messages: UIMessage[]) => boolean; /** * Resolve the eve agent URL from the route option and site config, and * reject ambiguous responder configuration. Pure so the fail-fast contract * stays unit-testable outside a bundler. */ export declare const resolveEveAgentUrl: ({ configUrl, hasProxy, optionUrl, }: { configUrl?: string; hasProxy: boolean; optionUrl?: string; }) => string | null; /** * Cap the text of the trailing user message. The chat client limits input * to 1000 characters, but the route is publicly reachable and must not * forward arbitrarily large payloads to the agent. */ export declare const capLastUserMessageText: (messages: UIMessage[], limit: number) => UIMessage[]; /** * Inline prior conversation turns into a single message for a fresh eve * session. Used when history exists but the browser holds no session for * this conversation — for example after the session cookie expired. */ export declare const buildEveAgentTranscript: (messages: UIMessage[], currentMessage: string) => string; /** * Extract http(s) URLs from a tool result so agent-side retrieval can * surface citations. Conservative by design: only string values under * keys named `url` (or `href`) are considered. */ export declare const extractSourceUrls: (value: unknown, limit?: number) => { title?: string; url: string; }[]; /** Start an eve session without a turn so the first message can reuse it. */ export declare const createEmptyEveAgentSession: ({ agentUrl, fetchImpl, headers, signal, }: { agentUrl: string; fetchImpl?: typeof fetch; headers?: HeadersInit; signal?: AbortSignal; }) => Promise<{ sessionId: string; }>; /** * Send the turn's message to the agent: as a follow-up to `continuation` * when given, otherwise (or when that session is no longer active) as the * first message of a new session. Resolves once the agent has accepted the * message, before any event is streamed, so the caller can bind the * resulting session to the response. */ export declare const startOrContinueEveAgentSession: ({ agentUrl, clientContext, continuation, fallbackMessage, fetchImpl, headers, message, signal, }: { /** Base URL of the deployed eve agent. */ agentUrl: string; /** * Turn-scoped context sent as eve's top-level `clientContext` with the * message, including on a replacement session. */ clientContext?: EveAgentClientContext; /** * Session to continue. Only pass a session ID read from a verified * session cookie; never one supplied by the browser. */ continuation?: EveAgentSession | null; /** * Message used when a fresh session replaces an inactive one — typically * the message with the prior conversation inlined, so the new session * does not lose context. Defaults to `message`. */ fallbackMessage?: EveAgentMessage; /** Injectable fetch for tests. Defaults to the global `fetch`. */ fetchImpl?: typeof fetch; headers?: HeadersInit; /** The user message (with any docs context already inlined). */ message: EveAgentMessage; signal?: AbortSignal; }) => Promise; /** * Stream one Ask AI turn from a session that already accepted the turn's * message, writing AI SDK UI message chunks to the provided writer. */ export declare const streamEveAgentTurn: ({ agentUrl, fetchImpl, headers, initialChunks, session, sessionTag, signal, toolCitations, visibleTools, writer, }: StreamEveAgentTurnOptions) => Promise; //# sourceMappingURL=eve-agent.d.ts.map