Skip to content

Function: addAIPeer()

@roomful/core


@roomful/core / 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.

TPresence extends PresenceData = PresenceData

The room presence shape.

string

The room to join (the same id the humans are in).

AddAIPeerOptions<TPresence>

The agent and join configuration.

AIPeer

A handle exposing the peer id and a stop() teardown.