Skip to content
providerkit
GitHub

ChatClient

Defined in: react/src/client.ts:319

respond: Respond;

Defined in: react/src/client.ts:345

Answers a request. It shows as submitting until the host changes the request or the run.

attach(): () => void;

Defined in: react/src/client.ts:332

Starts observing, and returns the function that stops. Commands work without it, but only an attached client opens observations and reattaches them.

Calls nest: the client observes while anyone is attached. Detaching closes the observation and nothing else. A stream that is the reply to a command stays open to its end, because for many hosts closing it stops the run, and only Stop may stop a run.

() => void


discard(messageId): CommandResult;

Defined in: react/src/client.ts:340

Takes a message whose outcome is unknown out of the conversation, and out of pendingSend storage, without sending it again: for a message the person gives up on. If it did arrive, the host’s copy still shows once the host sends it.

Parameter Type
messageId string

CommandResult


getState(): ChatState;

Defined in: react/src/client.ts:321

The current state. The same object until something in it changed.

ChatState


recallInput(inputId): Promise<CommandResult>;

Defined in: react/src/client.ts:350

Manual recall through a host that can fence the race with input acceptance.

Parameter Type
inputId string

Promise<CommandResult>


reconnect(): void;

Defined in: react/src/client.ts:352

Opens a fresh observation, with a full budget of tries, after the connection was lost.

void


retry(messageId): Promise<SendResult>;

Defined in: react/src/client.ts:336

Sends a message whose outcome is unknown again, with the same clientId. Nothing else ever sends a message twice.

Parameter Type
messageId string

Promise<SendResult>


send(input): Promise<SendResult>;

Defined in: react/src/client.ts:333

Parameter Type
input | string | MessageInput

Promise<SendResult>


setOptions(options): void;

Defined in: react/src/client.ts:355

A new transport or changed settings, for what comes next. initialMessages is read once, when the client is made.

Parameter Type
options ChatClientOptions

void


startClientTool(requestId): Promise<RespondResult>;

Defined in: react/src/client.ts:348

Explicit user action only. Never wire this to an effect or a replay listener. After a result delivery failure, this resubmits the saved result, never reruns the handler.

Parameter Type
requestId string

Promise<RespondResult>


stop(): Promise<CommandResult>;

Defined in: react/src/client.ts:343

Asks the host to stop the run, then waits for it to say so, with the observation still open. Without transport.stop, closes the stream the run lives in and marks it stopped here.

Promise<CommandResult>


subscribe(listener): () => void;

Defined in: react/src/client.ts:323

Called after the state changed. What the host streams is batched to one call per frame.

Parameter Type
listener () => void

() => void