import type { RunEvent, RunEventLog } from '../types/server.js'; /** Options for the in-memory run event log. */ export interface MemoryRunEventLogOptions { /** Events kept per run before the oldest are dropped. Defaults to 1,000. */ maxEventsPerRun?: number; /** Runs kept before the least recently written is dropped. Defaults to 1,000. */ maxRuns?: number; } /** * Run events in process memory, with waiters woken as events arrive. * * The default, and all a single-process server needs: a client that reconnects reads what it missed * from here. Across replicas the log has to be shared, which is what `RedisRunEventLog` is for. */ export declare class MemoryRunEventLog implements RunEventLog { private readonly runs; private readonly waiters; private readonly maxEvents; private readonly maxRuns; constructor(options?: MemoryRunEventLogOptions); /** Appends an event, numbering it, and wakes anything waiting on this run. */ append(runId: string, event: Omit): RunEvent; /** Events of a run after an id, oldest first. */ read(runId: string, options?: { after?: number; limit?: number; }): RunEvent[]; /** Resolves as soon as an event after `after` exists, or when the wait is aborted or times out. */ wait(runId: string, after: number, options?: { signal?: AbortSignal; timeoutMs?: number; }): Promise; /** Forgets a run's events. */ clear(runId: string): void; } /** * The Redis commands the event log needs, in `ioredis` argument order. * * Structural, as with the other Redis adapters, so no Redis client becomes a dependency. */ export interface RedisEventLogLikeClient { /** Appends to a list and returns its new length, which numbers the event. */ rpush(key: string, value: string): Promise | number | unknown; /** Reads a range of a list. */ lrange(key: string, start: number, stop: number): Promise | string[]; /** Trims a list to a range. */ ltrim(key: string, start: number, stop: number): Promise | unknown; /** Sets a key's lifetime in seconds. */ expire(key: string, seconds: number): Promise | unknown; /** Deletes a key. */ del(key: string): Promise | unknown; } /** Options for the Redis run event log. */ export interface RedisRunEventLogOptions { /** Key prefix. Defaults to `nexus-ai-pro:runs:`. */ prefix?: string; /** Events kept per run. Defaults to 1,000. */ maxEventsPerRun?: number; /** How long a run's events live after the last append, in seconds. Defaults to one day. */ ttlSeconds?: number; /** How often a waiting reader looks again, in milliseconds. Defaults to 250. */ pollIntervalMs?: number; } /** * Run events in Redis, so a client can reconnect to any replica and resume. * * One list per run, whose length numbers each event, which is what makes ids stable without a second * counter. Waiting readers poll rather than subscribe, so the log needs no second connection and no * pub/sub delivery guarantees; the poll interval is the only latency a reconnecting client sees. */ export declare class RedisRunEventLog implements RunEventLog { private readonly client; private readonly options; private readonly prefix; constructor(client: RedisEventLogLikeClient, options?: RedisRunEventLogOptions); /** Appends an event, numbered by the list's new length. */ append(runId: string, event: Omit): Promise; /** Events of a run after an id, oldest first. */ read(runId: string, options?: { after?: number; limit?: number; }): Promise; /** Polls until an event after `after` exists, or the wait is aborted or times out. */ wait(runId: string, after: number, options?: { signal?: AbortSignal; timeoutMs?: number; }): Promise; /** Forgets a run's events. */ clear(runId: string): Promise; private key; }