Interface: AIPeerContext\<TPresence\>
@roomful/core / AIPeerContext
Interface: AIPeerContext<TPresence>
Section titled “Interface: AIPeerContext<TPresence>”Defined in: packages/core/src/ai-peer.ts:141
The room snapshot plus action handles handed to an AIPeerAgent each tick. Reads are a snapshot taken at the start of the tick; the action methods apply immediately.
Type Parameters
Section titled “Type Parameters”TPresence
Section titled “TPresence”TPresence extends PresenceData = PresenceData
Properties
Section titled “Properties”cursors
Section titled “cursors”
readonlycursors:CursorPosition[]
Defined in: packages/core/src/ai-peer.ts:149
The current cursor positions of all peers.
events
Section titled “events”
readonlyevents: readonlyAIPeerEvent<TPresence>[]
Defined in: packages/core/src/ai-peer.ts:151
Events observed since the previous tick (only for observeEvents names).
others
Section titled “others”
readonlyothers:Peer<TPresence>[]
Defined in: packages/core/src/ai-peer.ts:147
Every other peer in the room.
proposals
Section titled “proposals”
readonlyproposals: readonlyAgentProposal[]
Defined in: packages/core/src/ai-peer.ts:153
The room’s agent-approval proposals (snapshot at tick start), newest first.
readonlyself:Peer<TPresence>
Defined in: packages/core/src/ai-peer.ts:145
The AI peer’s own peer snapshot.
readonlytick:number
Defined in: packages/core/src/ai-peer.ts:143
The tick counter, incremented after each agent run (starts at 0).
Methods
Section titled “Methods”emit()
Section titled “emit()”emit(
name,payload):void
Defined in: packages/core/src/ai-peer.ts:161
Emits a custom event to the room.
Parameters
Section titled “Parameters”string
payload
Section titled “payload”unknown
Returns
Section titled “Returns”void
moveCursor()
Section titled “moveCursor()”moveCursor(
x,y):void
Defined in: packages/core/src/ai-peer.ts:155
Moves the AI peer’s cursor to a normalized position (each axis 0..1).
Parameters
Section titled “Parameters”number
number
Returns
Section titled “Returns”void
propose()
Section titled “propose()”propose(
type,payload?):string
Defined in: packages/core/src/ai-peer.ts:174
Proposes an action for human approval instead of applying it, and sets the agent’s state to
waiting-approval. Watch proposals on later ticks for the decision, then apply or drop it.
Parameters
Section titled “Parameters”string
payload?
Section titled “payload?”unknown
Returns
Section titled “Returns”string
The new proposal’s id.
recordAction()
Section titled “recordAction()”recordAction(
type,payload?):void
Defined in: packages/core/src/ai-peer.ts:167
Records a structured, auditable action into the room’s activity feed (prefixed
AGENT_ACTION_PREFIX), e.g. recordAction('proposed-edit', { field, value }). Read the
agent’s actions back anywhere with getAgentActions.
Parameters
Section titled “Parameters”string
payload?
Section titled “payload?”unknown
Returns
Section titled “Returns”void
setPresence()
Section titled “setPresence()”setPresence(
data):void
Defined in: packages/core/src/ai-peer.ts:157
Merges a patch into the AI peer’s presence.
Parameters
Section titled “Parameters”Partial<TPresence>
Returns
Section titled “Returns”void
setState()
Section titled “setState()”setState(
state):void
Defined in: packages/core/src/ai-peer.ts:159
Announces what the agent is doing right now, for a live UI indicator.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void