import { PartySocketOptions, PartyFetchOptions, PartySocket } from 'partysocket'; import { SerializableReturnValue, SerializableValue } from './serializable.js'; /** * Options for creating an AgentClient */ type AgentClientOptions = Omit & { /** Name of the agent to connect to */ agent: string; /** Name of the specific Agent instance */ name?: string; /** Called when the Agent's state is updated */ onStateUpdate?: (state: State, source: "server" | "client") => void; }; /** * Options for streaming RPC calls */ type StreamOptions = { /** Called when a chunk of data is received */ onChunk?: (chunk: unknown) => void; /** Called when the stream ends */ onDone?: (finalChunk: unknown) => void; /** Called when an error occurs */ onError?: (error: string) => void; }; /** * Options for the agentFetch function */ type AgentClientFetchOptions = Omit & { /** Name of the agent to connect to */ agent: string; /** Name of the specific Agent instance */ name?: string; }; /** * Convert a camelCase string to a kebab-case string * @param str The string to convert * @returns The kebab-case string */ declare function camelCaseToKebabCase(str: string): string; /** * WebSocket client for connecting to an Agent */ declare class AgentClient extends PartySocket { /** * @deprecated Use agentFetch instead */ static fetch(_opts: PartyFetchOptions): Promise; agent: string; name: string; private options; private _pendingCalls; constructor(options: AgentClientOptions); setState(state: State): void; /** * Call a method on the Agent * @param method Name of the method to call * @param args Arguments to pass to the method * @param streamOptions Options for handling streaming responses * @returns Promise that resolves with the method's return value */ call(method: string, args?: SerializableValue[], streamOptions?: StreamOptions): Promise; call(method: string, args?: unknown[], streamOptions?: StreamOptions): Promise; } /** * Make an HTTP request to an Agent * @param opts Connection options * @param init Request initialization options * @returns Promise resolving to a Response */ declare function agentFetch(opts: AgentClientFetchOptions, init?: RequestInit): Promise; export { AgentClient, type AgentClientFetchOptions, type AgentClientOptions, type StreamOptions, agentFetch, camelCaseToKebabCase };