agents
Version:
A home for your AI agents
121 lines (119 loc) • 3.67 kB
TypeScript
import {
a as StreamJson,
c as StreamReadBatchesOptions,
d as StreamState,
f as StreamStatus,
i as StreamChunk,
l as StreamReadOptions,
n as Streams,
o as StreamListOptions,
p as StreamWriter,
r as StreamsOptions,
s as StreamOpenOptions,
t as DEFAULT_MAX_CHUNK_BYTES,
u as StreamSettleOptions
} from "../streams-BcE8JP2X.js";
//#region src/streams/errors.d.ts
/**
* Error classes for the Streams capability. Each carries a stable `name` so
* hosts and tests can classify failures without depending on message text.
*/
/**
* Thrown when `open()` targets a terminal stream, or an append reaches a
* stream that settled (or was deleted) after the writer was created.
*
* @experimental The API surface may change before stabilizing.
*/
declare class StreamClosedError extends Error {
/** The stream that no longer accepts writes. */
readonly streamId: string;
constructor(streamId: string, detail: string);
}
/**
* Thrown when `read()` targets a stream that was never opened (or was
* deleted). `status()` returns `null` instead, for existence probes.
*
* @experimental The API surface may change before stabilizing.
*/
declare class StreamNotFoundError extends Error {
readonly streamId: string;
constructor(streamId: string);
}
/**
* Thrown when a chunk or metadata value is not JSON-serializable or exceeds
* the configured size limit.
*
* @experimental The API surface may change before stabilizing.
*/
declare class StreamSerializationError extends Error {
constructor(context: string, detail: string);
}
//#endregion
//#region src/streams/sse.d.ts
/**
* Options accepted by {@link sseResponse}.
*
* @experimental The API surface may change before stabilizing.
*/
interface SSEResponseOptions {
/**
* The incoming request. Used for resume (the `Last-Event-ID` header a
* reconnecting `EventSource` sends, or a `?from=` query parameter) and to
* abort the tail when the client disconnects (`request.signal`).
*/
request?: Request;
/** First sequence number to yield. Overrides request-derived resume. */
from?: number;
/** Extra abort signal; composed with `request.signal`. */
signal?: AbortSignal;
/** Maximum chunks per write. Defaults to the read batch size (100). */
batchSize?: number;
/**
* Milliseconds between `: heartbeat` comment frames while tailing, keeping
* idle proxies from killing the connection. 0 disables. Default: 30000.
*/
heartbeatMs?: number;
}
/**
* Serve one durable stream as a Server-Sent Events response: replay from the
* resume point, emit an `up-to-date` control event on reaching the tail,
* tail live appends, and finish with `done` (completed) or `error` (errored,
* carrying the recorded reason). Returns a 404 response when the stream does
* not exist.
*
* ```ts
* async onRequest(request: Request) {
* return sseResponse(this.streams, "reply:123", { request });
* }
* // client: new EventSource(url) — reconnect resume is automatic.
* ```
*
* @experimental The API surface may change before stabilizing.
*/
declare function sseResponse(
streams: Streams,
streamId: string,
options?: SSEResponseOptions
): Promise<Response>;
//#endregion
export {
DEFAULT_MAX_CHUNK_BYTES,
type SSEResponseOptions,
type StreamChunk,
StreamClosedError,
type StreamJson,
type StreamListOptions,
StreamNotFoundError,
type StreamOpenOptions,
type StreamReadBatchesOptions,
type StreamReadOptions,
StreamSerializationError,
type StreamSettleOptions,
type StreamState,
type StreamStatus,
type StreamWriter,
Streams,
type StreamsOptions,
sseResponse
};
//# sourceMappingURL=index.d.ts.map