eve
Version:
Filesystem-first framework for durable backend AI agents that run anywhere.
45 lines (44 loc) • 1.84 kB
TypeScript
import type { HandleMessageStreamEvent } from "#protocol/message.js";
import type { ClientRedirectPolicy, StreamReconnectPolicy } from "#client/types.js";
interface RetryPolicy {
readonly baseDelayMs: number;
readonly maxAttempts: number;
readonly maxDelayMs: number;
}
interface ResolvedStreamReconnectPolicy {
readonly retryableErrorStatuses: ReadonlySet<number>;
readonly streamIdleReconnectPolicy: RetryPolicy;
readonly streamOpenReconnectPolicy: RetryPolicy;
}
/**
* Internal configuration for following a durable event stream.
*/
interface FollowStreamInput {
readonly host: string;
readonly streamReconnectPolicy?: StreamReconnectPolicy;
readonly resolveHeaders: () => Promise<Headers>;
readonly redirect?: ClientRedirectPolicy;
readonly sessionId: string;
readonly signal?: AbortSignal;
readonly startIndex: number;
}
/**
* Follows a session's durable event stream from an absolute cursor,
* transparently reconnecting whenever the transport ends.
*
* Transport endings reconnect from the advanced cursor. Progress resets the
* idle budget; repeated empty streams eventually stop the follow. Callers own
* boundary handling. Negative tail-relative cursors use one connection because
* they cannot be advanced safely.
*/
export declare function followStreamIterable(input: FollowStreamInput): AsyncGenerator<HandleMessageStreamEvent>;
/**
* Opens one stream response body, retrying transient failures with capped
* exponential backoff (~35s total): brief network outages and the short
* propagation window where a just-acknowledged session may not yet be
* readable from the stream route.
*/
export declare function openStreamBody(input: FollowStreamInput & {
readonly retryPolicy?: ResolvedStreamReconnectPolicy;
}): Promise<ReadableStream<Uint8Array>>;
export {};