import type { EveAuthorizationPart, EveMessageData } from "#client/message-reducer-types.js"; import type { InputRequest, InputResponse } from "#shared/input.js"; import { type ConversationTask, type ConversationTaskCall } from "#protocol/session-projection.js"; export type { ConversationTask, ConversationTaskCall }; export interface ConversationTurn { readonly turnId: string; readonly status: "active" | "completed" | "cancelled" | "failed"; /** The open turn is parked, holding on its tasks or on a question one of its calls asked. */ readonly waiting?: boolean; } export interface ConversationInput { readonly request: InputRequest; readonly turnId: string; readonly stepIndex: number; /** The task whose run asks, when a task asks. */ readonly taskId?: string; readonly status: "open" | "responded" | "settled"; readonly response?: InputResponse; readonly outcome?: string; } export type AgentObservation = { readonly status: "not-followed"; } | { readonly status: "following"; readonly conversation: ConversationState; } /** Every call so far has shown its content; a later call to the task resumes following. */ | { readonly status: "idle"; readonly conversation: ConversationState; } | { /** The stream failed; this does not mean the agent failed. */ readonly status: "unavailable"; readonly conversation?: ConversationState; }; /** A session a run opened with `ctx.agent`, as its `agent.started` announced it. */ export interface ConversationAgentSession { readonly sessionId: string; readonly name: string; /** The call whose invocation opened the session. */ readonly callId: string; readonly turnId: string; /** The task whose run opened the session; absent when an `execute` call opened it. */ readonly taskId?: string; readonly observation: AgentObservation; } /** * Renderable conversation state. Root and agent-session input IDs occupy separate scopes. */ export interface ConversationState extends EveMessageData { readonly activeTurnId?: string; readonly turns: Readonly>; readonly inputs: Readonly>; readonly tasks: Readonly>; /** Sessions opened by this session's runs, by session ID. */ readonly agents: Readonly>; } /** Inputs awaiting an answer, including requests introduced in earlier turns. */ export declare function openConversationInputs(state: ConversationState): readonly ConversationInput[]; /** Authorization attempts remain visible across turns, including parked callbacks. */ export declare function conversationAuthorizations(state: ConversationState): readonly EveAuthorizationPart[]; /** A sign-in the session still waits on, which resumes its work when the callback arrives. */ export declare function hasPendingAuthorizations(state: ConversationState): boolean; /** * The agent task whose calls a session receives, when the session is that agent's own. eve's agent * tools send each call as one message, in call order, which is what lets a client attribute the * session's turns to calls. A session an authored tool opens with `ctx.agent` has no such task. */ export declare function agentToolTask(state: ConversationState, agent: ConversationAgentSession): ConversationTask | undefined; /** The session an agent tool forwards its task's calls to. */ export declare function agentToolSession(state: ConversationState, task: ConversationTask): ConversationAgentSession | undefined; /** * Whether a followed agent tool session has shown everything its task's calls produced so far: * no call is working, the session has no open turn, question, or sign-in, and every completed call's * message has arrived. The last check covers a child stream that lags the root stream. */ export declare function isAgentSessionCaughtUp(state: ConversationState, agent: ConversationAgentSession): boolean; /** * Attributes an agent tool session's turns to the calls that produced them. The k-th message the * session received came from the task's k-th call; a turn without a message of its own, such as * one resumed after an approval, continues the previous call. A call whose message joined a * running turn owns no turn. */ export declare function agentCallTurns(task: ConversationTask, conversation: ConversationState): ReadonlyMap; /** * Whether a call's content may still arrive on its agent tool session: one of the call's turns is * still open there, or the call completed before its message reached the session. */ export declare function isAgentCallContentPending(task: ConversationTask, call: ConversationTaskCall, conversation: ConversationState): boolean;