Skip to main content

Class: Conversation<T>

Defined in: packages/client/src/conversation.ts:142

Type Parameters​

T​

T = unknown

Constructors​

Constructor​

new Conversation<T>(select, options?, hooks?): Conversation<T>

Defined in: packages/client/src/conversation.ts:155

Parameters​

select​

SelectProvider

options?​

ConversationOptions<T> = {}

hooks?​

ConversationHooks = {}

Returns​

Conversation<T>

Accessors​

needs​

Get Signature​

get needs(): Capability[]

Defined in: packages/client/src/conversation.ts:175

What this conversation's AI must be able to do for full answers (tools when it has some).

Returns​

Capability[]

Methods​

close()​

close(): void

Defined in: packages/client/src/conversation.ts:261

End the provider session (e.g. on page unload). The history stays.

Returns​

void


getState()​

getState(): ConversationState

Defined in: packages/client/src/conversation.ts:172

Returns​

ConversationState


on()​

on(listener): () => void

Defined in: packages/client/src/conversation.ts:185

Every event of every turn, e.g. for a trace panel or an eval harness.

Parameters​

listener​

(event) => void

Returns​

() => void


rejectToolCall()​

rejectToolCall(callId, error?): void

Defined in: packages/client/src/conversation.ts:227

Refuse a tool call that has no execute; the model sees error.

Parameters​

callId​

string

error?​

string = "The visitor declined."

Returns​

void


reset()​

reset(messages?): void

Defined in: packages/client/src/conversation.ts:254

Clear the history and end the provider session.

Parameters​

messages?​

MessageInput[] = []

Returns​

void


send()​

send(input, options?): ChatRun<T>

Defined in: packages/client/src/conversation.ts:191

Send a user message. Queued behind the running turn, if any.

Parameters​

input​

MessageInput

options?​

SendOptions = {}

Returns​

ChatRun<T>


stop()​

stop(): void

Defined in: packages/client/src/conversation.ts:249

Cancel the running turn and every queued one.

Returns​

void


submitToolResult()​

submitToolResult(callId, result): void

Defined in: packages/client/src/conversation.ts:222

Answer a tool call that has no execute (see pendingInputs).

Parameters​

callId​

string

result​

unknown

Returns​

void


subscribe()​

subscribe(listener): () => void

Defined in: packages/client/src/conversation.ts:179

Parameters​

listener​

() => void

Returns​

() => void


warm()​

warm(): Promise<boolean>

Defined in: packages/client/src/conversation.ts:236

Open the provider session ahead of the first message, so the first answer does not pay for an agent start. Resolves false when no provider is ready.

Returns​

Promise<boolean>