Skip to content

BotHost

Defined in: packages/core/src/host/index.ts:29

Shared host operations for node-based bot platforms.

The renderer only needs node mutation, events and a commit boundary. Each platform supplies a commit implementation that serializes its tree.

new BotHost(options): BotHost

Defined in: packages/core/src/host/index.ts:49

BotHostOptions

BotHost

readonly container: BotNode

Defined in: packages/core/src/host/index.ts:30


readonly controlled: ReadonlySet<string>

Defined in: packages/core/src/host/index.ts:32

Renderer.Host.controlled


readonly elements: readonly string[]

Defined in: packages/core/src/host/index.ts:31

Renderer.Host.elements


readonly platform: string

Defined in: packages/core/src/host/index.ts:35

The platform this host serializes for, such as discord or slack.


readonly runsMounts: true = true

Defined in: packages/core/src/host/index.ts:33

Renderer.Host.runsMounts

get commits(): number

Defined in: packages/core/src/host/index.ts:45

How many commits this host has completed.

number


get session(): HostSession | null

Defined in: packages/core/src/host/index.ts:62

The session whose id and version are stamped onto interaction ids.

HostSession | null

createContainer(): BotNode

Defined in: packages/core/src/host/index.ts:180

BotNode


createElement(tag): BotNode

Defined in: packages/core/src/host/index.ts:170

string

BotNode

Renderer.Host.createElement


createText(text): BotNode

Defined in: packages/core/src/host/index.ts:174

string

BotNode

Renderer.Host.createText


freeze(nodes?): void

Defined in: packages/core/src/host/index.ts:126

Marks every interactive node disabled, so a painted copy shows the state without offering controls that cannot route to a live root.

readonly BotNode[] = ...

void


insertBefore(parent, node, ref): void

Defined in: packages/core/src/host/index.ts:220

BotNode

BotNode

BotNode | undefined

void

Renderer.Host.insertBefore


nextOf(node): BotNode | undefined

Defined in: packages/core/src/host/index.ts:232

BotNode

BotNode | undefined

Renderer.Host.nextOf


nodes(): readonly BotNode[]

Defined in: packages/core/src/host/index.ts:166

Every node in document order.

Hosts walk the tree several times per commit (ids, routing, serialization). Taking one list and passing it to the other steps keeps those walks in sync and avoids re-traversing the whole tree for each concern.

readonly BotNode[]


parentOf(node): BotNode | undefined

Defined in: packages/core/src/host/index.ts:228

The node’s parent, or undefined once it’s removed. instanceAt relies on this.

BotNode

BotNode | undefined

Renderer.Host.parentOf


prepareInteractionIds(nodes?): string | undefined

Defined in: packages/core/src/host/index.ts:87

Assigns every interactive node its platform-facing custom id.

Without a session the id keeps the old host-generated value. With one, auto ids are document-order ordinals and explicit ids keep the author’s text as the key, both wrapped with the session and its current version. A restored tree therefore produces the same ids as the state it shows.

Returns a message when an id exceeds the platform limit. Callers surface that message as a target failure instead of throwing from the renderer.

readonly BotNode[] = ...

string | undefined


remove(node): void

Defined in: packages/core/src/host/index.ts:224

BotNode

void

Renderer.Host.remove


setAttr(node, name, value, _previous?): void

Defined in: packages/core/src/host/index.ts:188

Sets an attribute of node, or removes it when value is undefined. previous is the value the renderer takes the attribute to hold before the call: the one it last set, or the one hydration read from the node, and undefined when it holds none.

BotNode

string

string | undefined

string

void

Renderer.Host.setAttr


setEvents(node, handlers, dispatch, options): void

Defined in: packages/core/src/host/index.ts:239

BotNode

Readonly<Record<string, View.Handler<unknown, any>>>

Dispatch

Readonly<Record<string, View.EventOptions>>

void

Renderer.Host.setEvents


setProp(node, name, value): void

Defined in: packages/core/src/host/index.ts:204

BotNode

string

unknown

void

Renderer.Host.setProp


setSession(session): void

Defined in: packages/core/src/host/index.ts:67

Binds the host to a resumable message session.

HostSession | null

void


setSessionVersion(version): void

Defined in: packages/core/src/host/index.ts:72

Advances the version used by the next commit.

number

void


setText(node, text): void

Defined in: packages/core/src/host/index.ts:184

BotNode

string

void

Renderer.Host.setText


waitForCommit(after, timeoutMs?): Effect<void>

Defined in: packages/core/src/host/index.ts:146

Waits until a commit after after has run, or the timeout elapses.

number

number = 100

Effect<void>