export declare const SERIALIZER_PREFIX_FILE = "!TelefuncFile:"; export declare const SERIALIZER_PREFIX_BLOB = "!TelefuncBlob:"; export declare const SERIALIZER_PREFIX_FILE_DOWNLOAD = "!TelefuncFileDownload:"; export declare const SERIALIZER_PREFIX_BLOB_DOWNLOAD = "!TelefuncBlobDownload:"; export declare const SERIALIZER_PREFIX_STREAM = "!TelefuncStream:"; export declare const SERIALIZER_PREFIX_GENERATOR = "!TelefuncGenerator:"; export declare const SERIALIZER_PREFIX_PROMISE = "!TelefuncPromise:"; export declare const SERIALIZER_PREFIX_CHANNEL = "!TelefuncChannel:"; export declare const SERIALIZER_PREFIX_FUNCTION = "!TelefuncFunction:"; export declare const SERIALIZER_PREFIX_BROADCAST = "!TelefuncBroadcast:"; /** Marker key used on the ack payload of a server-returned function when its arg shield * rejects the incoming args. The client-side reviver detects this and throws on the * caller's side — keeps the channel oblivious to shield semantics. */ export declare const FN_SHIELD_ERROR_KEY = "__telefunc_fn_shield_error"; /** 1-byte tag prefixed to every binary send in per-channel streaming pumps. */ export declare const CHANNEL_PUMP_TAG_DATA = 0; export declare const CHANNEL_PUMP_TAG_ERROR = 1; /** Marker u32 value used as frame length in streaming responses to signal an error frame. */ export declare const STREAMING_ERROR_FRAME_MARKER = 4294967295; /** Error types used in streaming error frame payloads. */ export declare const STREAMING_ERROR_TYPE: { readonly ABORT: 'abort'; readonly BUG: 'bug'; }; export type StreamingErrorType = (typeof STREAMING_ERROR_TYPE)[keyof typeof STREAMING_ERROR_TYPE]; /** Streaming error frame payload: abort with value. */ export type StreamingErrorFrameAbort = { type: typeof STREAMING_ERROR_TYPE.ABORT; abortValue: unknown; }; /** Streaming error frame payload: unhandled bug (no details sent to client). */ export type StreamingErrorFrameBug = { type: typeof STREAMING_ERROR_TYPE.BUG; }; /** Union of all streaming error frame payloads. */ export type StreamingErrorFramePayload = StreamingErrorFrameAbort | StreamingErrorFrameBug; export declare const STREAM_TRANSPORT: { readonly BINARY_INLINE: 'binary-inline'; readonly CHANNEL: 'channel'; readonly SSE_INLINE: 'sse-inline'; }; export declare const CHANNEL_TRANSPORT: { readonly SSE: 'sse'; readonly WS: 'ws'; }; /** Transport for streamed values returned by telefunctions. */ export type StreamTransport = (typeof STREAM_TRANSPORT)[keyof typeof STREAM_TRANSPORT]; export declare const DEFAULT_STREAM_TRANSPORT: StreamTransport; /** Transport for persistent channels created with `new Channel()`. */ export type ChannelTransport = (typeof CHANNEL_TRANSPORT)[keyof typeof CHANNEL_TRANSPORT]; /** Ordered list of transports to use for channels. `['sse', 'ws']` starts on SSE and upgrades to WebSocket. */ export type ChannelTransports = ChannelTransport[]; /** Default transports the client tries, in order. Starts on SSE and upgrades to WS if available. */ export declare const DEFAULT_CLIENT_CHANNEL_TRANSPORTS: ChannelTransports; /** Default transports enabled on the server. SSE only until a WS adapter calls enableChannelTransports. */ export declare const DEFAULT_SERVER_CHANNEL_TRANSPORTS: ChannelTransports; /** How long to wait for a WebSocket probe ping/pong before giving up on the upgrade. */ export declare const WS_PROBE_TIMEOUT_MS = 3000; /** How long to wait for the stream-request POST handshake ack on the SSE downstream * before declaring the upstream wire dead and falling back to outbox+batch POSTs. */ export declare const STREAM_REQUEST_HANDSHAKE_TIMEOUT_MS = 3000; /** Batch mode only: how long the barrier waits for a natural outbox drain before flushing it * itself. On a duplex upstream the barrier is just the last frame pushed onto the open body. */ export declare const UPGRADE_DRAIN_TIMEOUT_MS = 2000; /** Post-flip wait for both join limbs — FIN on the old wire, RECONCILED on the new one. */ export declare const UPGRADE_HANDOFF_JOIN_TIMEOUT_MS = 2000; /** Past either bound the upgrade is abandoned rather than letting a stalled join buffer forever. */ export declare const UPGRADE_HANDOFF_BUFFER_BYTES: number; export declare const UPGRADE_HANDOFF_BUFFER_FRAMES = 4096; /** Wall-clock bound on one attempt, PREPARE to COMMITTED (see the assertion below). */ export declare const UPGRADE_ATTEMPT_TIMEOUT_MS = 10000; /** How long a staged, uncommitted upgrade may hold its session before the probe is dropped. */ export declare const UPGRADE_STAGE_TTL_MS = 10000; /** Longest channel id the wire will carry. */ export declare const UPGRADE_MAX_ID_BYTES = 256; /** Bounds what unauthenticated PREPARE frames can pin in memory before any of them commits. */ export declare const UPGRADE_MAX_STAGED_RECORDS = 1024; export declare const UPGRADE_MAX_STAGED_BYTES: number; /** Largest data-plane frame. Generous because it carries user payloads. */ export declare const WIRE_MAX_RAW_FRAME_BYTES: number; /** The single channels-per-connection limit: the client refuses to open past it, a barrier may * list no more, and the control-frame byte cap below is derived from it. Every reconcile lists * every channel, so this is also what a peer can make the server parse. (The wire could address * 65 536 — a u16 index — but that is exhaustion, not a working limit.) */ export declare const MAX_CHANNELS_PER_CONNECTION = 4096; /** Largest control frame the server will decode, checked on the raw bytes. Derived, never picked: * the biggest legitimate one lists every channel at the id cap, and a cap that refuses a legal * frame is worse than no cap. */ export declare const WIRE_MAX_CONN_CTRL_FRAME_BYTES: number; /** Per-connection ceiling on accepted-but-unprocessed frames: a peer that outruns its recv chain * is terminated rather than allowed to queue without bound. */ export declare const WIRE_MAX_RECV_BACKLOG_BYTES: number; export declare const WIRE_MAX_RECV_BACKLOG_FRAMES = 50000; /** Largest SSE request metadata header the server will read off a POST body. */ export declare const SSE_METADATA_MAX_BYTES: number; /** How long the client waits for RECONCILED after sending a RECONCILE before declaring the * wire dead and reconnecting. A downstream that stalls without erroring (bytes stop, no FIN) * otherwise wedges the connection: the upstream keeps sending pings but `handlePongTimeout` * is suppressed while reconciling, so nothing notices the dead wire and every call buffered * behind the un-acked RECONCILE hangs. */ export declare const RECONCILE_TIMEOUT_MS = 10000; /** Shorter flush delay for the first SSE batch POST after an idle period. */ export declare const SSE_POST_IDLE_FLUSH_DELAY_MS = 50; /** Idle window used to decide whether the next upstream SSE batch is post-idle. */ export declare const SSE_FLUSH_THROTTLE_MS = 300; /** Latest-send deadline for SSE reconcile batches so immediate channel activity can coalesce into one POST. */ export declare const SSE_RECONCILE_DEADLINE_MS = 10; export declare const CHANNEL_RECONNECT_TIMEOUT_MS = 60000; export declare const CHANNEL_IDLE_TIMEOUT_MS = 60000; export declare const CHANNEL_PING_INTERVAL_MS = 5000; export declare const CHANNEL_PING_INTERVAL_MIN_MS = 1000; export declare const CHANNEL_CLOSE_TIMEOUT_MS = 5000; /** Per-channel replay buffer for text frames kept on the server for reconnect recovery. */ export declare const CHANNEL_SERVER_REPLAY_BUFFER_BYTES: number; /** Per-channel replay buffer for binary frames kept on the server for reconnect recovery. */ export declare const CHANNEL_SERVER_REPLAY_BUFFER_BINARY_BYTES: number; /** Per-channel replay buffer for text frames advertised to the client for reconnect replay. */ export declare const CHANNEL_CLIENT_REPLAY_BUFFER_BYTES: number; /** Per-channel replay buffer for binary frames advertised to the client for reconnect replay. */ export declare const CHANNEL_CLIENT_REPLAY_BUFFER_BINARY_BYTES: number; /** * Maximum bytes buffered per channel for text messages sent before a peer connects. * When the budget is exceeded the oldest entries are evicted (FIFO) so the * channel stays alive and memory stays bounded. */ export declare const CHANNEL_BUFFER_LIMIT_BYTES: number; /** Maximum bytes buffered per channel for binary messages sent before a peer connects. */ export declare const CHANNEL_BUFFER_LIMIT_BINARY_BYTES: number; /** How long a channel waits for a peer to connect after the server→client * HTTP response carrying `channel.client` has been serialized. */ export declare const CHANNEL_CONNECT_TTL_MS = 5000; export declare const CHANNEL_RECONNECT_INITIAL_DELAY_MS = 500; export declare const CHANNEL_RECONNECT_MAX_DELAY_MS = 5000; /** Initial credit window — sized so a typical ~MB-scale burst doesn't stall on * the BDP ramp-up. Grows further via the estimator up to `CREDIT_WINDOW_MAX_BYTES`. */ export declare const CREDIT_WINDOW_INITIAL_BYTES: number; /** Initial window when SSE upstream has fallen back to per-frame POSTs — each * POST has its own RTT, so a small window would spend it on flow-control alone. */ export declare const CREDIT_WINDOW_INITIAL_BYTES_BATCH: number; /** Hard cap on the adaptive credit window — bounds per-channel buffering worst case. * Covers ~5 Gbit/s × 100 ms RTT or ~500 Mbit/s × 1 s RTT. */ export declare const CREDIT_WINDOW_MAX_BYTES: number; /** Initial per-channel message-count credit. Independent of the byte budget: * many tiny frames within a normal byte window can still bury the receive loop * in dispatch work. Grows alongside the byte window from the same BDP probe — * the receiver derives bytes-in-flight and msgs-in-flight samples per RTT, * each saturating its own window independently. */ export declare const CREDIT_MSG_WINDOW_INITIAL = 100; /** Hard cap on the adaptive message-count window. The self-utilisation gate in * `FlowControl.onPingAck` stops growth long before this on hosts that can't * sustain the dispatch rate. */ export declare const CREDIT_MSG_WINDOW_MAX = 50000; /** Floor on the gap between consecutive BDP probes. On a fat-pipe-long-latency link * RTT alone paces the probes; on loopback (RTT ≈ 1 ms) this prevents thousands of * ping round-trips per second of event-loop churn for no estimator benefit. */ export declare const BDP_PING_MIN_INTERVAL_MS = 50; /** Ceiling for the adaptive probe interval — keeps a converged link's BDP probes * rare without ever freezing them, so a rate change is rediscovered within this. */ export declare const BDP_PING_MAX_INTERVAL_MS = 10000; /** Rolling window over which `FlowControl` measures its own contribution to the * event loop (telefunc-side self-time vs wall-clock). 1 s captures recent * pressure without lingering on stale history. */ export declare const FC_SELF_TIME_WINDOW_MS = 1000; /** Self-utilisation threshold above which the flow-control sender yields a * macrotask before its next send, and above which the receiver-side BDP gate * refuses to grow either window. Half the loop reserved for everything else * (UI, other channels, GC). Higher = throughput-first; lower = realtime-first. * * Note: this measures *our* CPU share specifically. An unrelated UI library * hogging the loop doesn't affect this value, so we don't falsely throttle * telefunc when the choke is elsewhere. */ export declare const FC_SELF_UTIL_THRESHOLD = 0.5; /** User-facing header for sticky session routing (opaque token). */ export declare const TELEFUNC_SESSION_HEADER = "x-telefunc-session";