eve
Version:
Filesystem-first framework for durable backend AI agents that run anywhere.
52 lines (51 loc) • 2.13 kB
TypeScript
import type { HandleMessageStreamEvent } from "#protocol/message.js";
import { MessageResponse } from "#client/message-response.js";
import type { ClientRedirectPolicy, SendTurnInput, SessionState, StreamOptions } from "#client/types.js";
/**
* Internal interface that a {@link ClientSession} uses to access client-level
* configuration without depending on the full {@link Client} class.
*/
interface SessionContext {
readonly host: string;
readonly maxReconnectAttempts: number;
readonly preserveCompletedSessions: boolean;
readonly redirect?: ClientRedirectPolicy;
resolveHeaders(perRequest?: Readonly<Record<string, string>>): Promise<Headers>;
}
/**
* One conversation with an eve agent.
*
* A session tracks conversation state (continuation token, session ID, stream
* cursor) automatically across {@link send} calls. Read the state from
* the {@link state} getter and serialize it to persist a session.
*/
export declare class ClientSession {
#private;
/** @internal */
constructor(context: SessionContext, state: SessionState);
/**
* Current session cursor. Always reflects the latest state after each
* completed turn. Serialize this to persist and resume later.
*/
get state(): SessionState;
/**
* Sends one turn payload to the agent.
*
* Pass a string as shorthand for `{ message }`, or pass an object to submit
* follow-up text, HITL results, client context, output schema, signal, and
* headers in a single request.
*/
send<TOutput = unknown>(input: SendTurnInput<TOutput>): Promise<MessageResponse<TOutput>>;
/**
* Opens this session's event stream for the current session ID.
*
* Resumes from the session's stored stream cursor unless `options.startIndex`
* overrides it. The returned iterable reconnects on transient socket
* disconnects, up to the client's `maxReconnectAttempts`.
*
* @throws {Error} If the session has no session ID (no message has been sent
* yet).
*/
stream(options?: StreamOptions): AsyncIterable<HandleMessageStreamEvent>;
}
export {};