export type SerializableRequest = { id?: string; url: string; streaming?: boolean; options: { method?: string; headers?: Record; body?: string; }; }; export type SerializableResponse = { id?: string; status: number; statusText: string; headers: Record; body: string; }; // Helper type for branded JSON strings export type TypedBody = string & { __type?: T }; // Client-side RPC types export type RPCRequestPayload = { type: "fetch" | "streamingFetch"; request: SerializableRequest; }; export type RPCResponsePayload = { type: "fetch"; response: SerializableResponse; }; export type RPCRequest = { id: string; type: "rpc"; payload: RPCRequestPayload; }; export type RPCSuccessResponse = { id: string; type: "rpcResponse"; payload: RPCResponsePayload; }; export type RPCStreamChunkResponse = { id: string; type: "rpcStreamChunk"; chunk: string; }; export type RPCStreamEndResponse = { id: string; type: "rpcStreamEnd"; payload?: RPCResponsePayload; }; export type RPCErrorResponse = { id: string; type: "rpcResponse"; error: any; }; export type RPCResponse = | RPCSuccessResponse | RPCErrorResponse | RPCStreamChunkResponse | RPCStreamEndResponse; export type UploadProgress = { loaded: number; total?: number; percent?: number; // 0-100 };