import {
i as SerializableValue,
r as SerializableReturnValue
} from "./serializable-C4GLimgv.js";
import {
PartyFetchOptions,
PartySocket,
PartySocketOptions
} from "partysocket";
//#region src/client.d.ts
/**
* Options for creating an AgentClient
*/
type AgentClientOptions<State = unknown> = Omit<
PartySocketOptions,
"party" | "room"
> & {
/** 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<PartyFetchOptions, "party" | "room"> & {
/** 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<State = unknown> extends PartySocket {
/**
* @deprecated Use agentFetch instead
*/
static fetch(_opts: PartyFetchOptions): Promise<Response>;
agent: string;
name: string;
private options;
private _pendingCalls;
constructor(options: AgentClientOptions<State>);
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<T extends SerializableReturnValue>(
method: string,
args?: SerializableValue[],
streamOptions?: StreamOptions
): Promise<T>;
call<T = unknown>(
method: string,
args?: unknown[],
streamOptions?: StreamOptions
): Promise<T>;
}
/**
* 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<Response>;
//#endregion
export {
agentFetch as a,
StreamOptions as i,
AgentClientFetchOptions as n,
camelCaseToKebabCase as o,
AgentClientOptions as r,
AgentClient as t
};
//# sourceMappingURL=client-ClORm6f0.d.ts.map