Client

Client

curb/client is the browser side of a call, for your own page on your own host. It needs a LiveKit room you already joined.

ExportWhat it does
connectAgentConnects to the agent in a room
AgentRefusedErrorThe agent refused a request. Has code, issues and path
AgentUnavailableErrorNo agent answered in time
DEFAULT_AGENT_TIMEOUT_MSThe timeout of a request, 10000
MAX_CLIENT_MESSAGE_BYTESThe largest message

connectAgent

import { connectAgent } from "curb/client";

const agent = connectAgent(room);
agent.on("cart.updated", (payload) => render(payload));
await agent.send("page.changed", { path: location.pathname });

connectAgent(room, { agentIdentity? }) returns an object with these:

MethodWhat it does
send(key, payload?)Sends a message the agent handles with useMessage
ask(key, payload?)The same, and resolves with what onMessage returned
on(key, handler)Handles a message from send.toClient. Returns a function that stops it
update(settings)Changes a setting of <Agent adjustable>, and resolves with the effective settings
close()Stops listening

agentIdentity picks the agent in a room with several participants.

Next steps