Function: addAIPeer()
@roomful/core / addAIPeer
Function: addAIPeer()
Section titled “Function: addAIPeer()”addAIPeer<
TPresence>(roomId,options):AIPeer
Defined in: packages/core/src/ai-peer.ts:240
Adds a programmatic (“AI”) peer to a room: it joins as a second participant over the given transport and an AIPeerAgent drives its presence, cursor, and events on a tick loop. Headless — no DOM required — so it runs in a browser tab alongside the human client, in Node, or on a server.
The agent is pluggable: pair it with createHeuristicAgent for a zero-dependency demo bot, or write one that calls an LLM to decide actions.
Type Parameters
Section titled “Type Parameters”TPresence
Section titled “TPresence”TPresence extends PresenceData = PresenceData
The room presence shape.
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
The room to join (the same id the humans are in).
options
Section titled “options”AddAIPeerOptions<TPresence>
The agent and join configuration.
Returns
Section titled “Returns”A handle exposing the peer id and a stop() teardown.