Conversation
The conversation is the message history maintained by the server. After connect(), the client mirrors it locally and keeps it in sync as new messages arrive.
Reading
client.getConversation(); // Conversation | null — metadata
client.getConversationMessages(); // ConversationMessage[] — copygetConversationMessages() returns a copy — mutating the array has no effect on the client's internal state. getConversation() returns the live metadata object, so treat it as read-only and use the setters or events if you need to change something.
Sending a message
await client.engageAutopilot('What is the weather in Berlin?');This is the high-level entry point: post the message and let the autopilot take over (the server returns immediately, the streamed reply arrives over the socket).
For more control:
await client.interactWithConversation({
role: 'user',
message: 'hello',
// …any payload your server accepts
});engageAutopilot is a thin wrapper around interactWithConversation that adds async: true.
Mutating local state directly
client.addConversationMessage({
role: 'assistant',
creator: 'autopilot',
message: 'Optimistic local update',
});
client.updateConversationMessage(0, { /* … */ });
client.clearConversationMessages();These do not round-trip to the server — they only update the local store. Useful for optimistic UI; use sparingly.
Resetting
await client.resetConversation();Asks the server to wipe the conversation. The client clears its local copy when the server confirms.
Re-fetching
const fresh = await client.fetchConversation(
'https://llmor.example.com/v1/conversations/<token>',
);Performs the same HTTP fetch as connect() does internally, without touching the socket. Mostly useful for tools and inspection.
Re-syncing from the socket
client.requestConversationState();Asks the server to re-send its current snapshot. The client emits conversationLoaded when it arrives.
Events you can listen to
client.on('conversationLoaded', ({ conversation, messages }) => { /* … */ });
client.on('messageAdded', ({ message, index }) => { /* … */ });
client.on('messageUpdated', ({ message, index }) => { /* … */ });
client.on('conversationCleared', () => { /* … */ });For streaming progress on the next assistant message (chunks arriving in real time), see Streaming.
Enriching messages for display
The server represents a tool result as a separate tool message whose function_response is the id of the call it answers. To render a call together with its result, pair them with the exported helper:
import { enrichMessagesWithFunctionResults } from '@llmor/autopilot-core';
const enriched = enrichMessagesWithFunctionResults(messages);
// assistant messages now carry the result on each function_calls[] entry,
// with status flipped to 'completed' once a result is present.It is pure and non-mutating (the inputs are untouched). The Vue store's visibleMessages uses it for you, so you only need it when rendering messages without the store.