Member Junction
    Preparing search index...

    The LIVE WHITEBOARD as a pluggable interactive channel — the canonical BaseRealtimeChannelClient implementation, resolved from the MJ: AI Agent Channels registry row whose ClientPluginClass is 'RealtimeWhiteboardChannel'.

    One instance per session (created via ClassFactory at session start). It owns the board's WhiteboardState engine and contributes the channel's full contract:

    • Action: the Whiteboard_* client-executed tool set (WHITEBOARD_TOOL_DEFINITIONS); ApplyAgentTool prefers the BOUND host component (board mutation + violet pop-in / toast / presence-cursor garnish) and falls back to the pure ApplyWhiteboardAgentTool engine call when no surface is bound (e.g. the board has not been shown yet) — the channel keeps working, just without the garnish.
    • Perception: BindSurface subscribes the host's coalesced (750 ms) SceneDelta stream and pipes each delta into the live model's context as a [whiteboard] background note; the agent-undo toast click flows the same way.
    • Surface: RealtimeWhiteboardHostComponent, created on the overlay's stage; the host's "Move to stage" button rides Context.SetFocusMode, and the board hears where the overlay placed it (OnSurfacePlacementChange) so the button offers the way back.
    • State of record: every board mutation (user edits AND agent tool calls) requests a save of WhiteboardState.ToJSON under channel name 'Whiteboard' — the host debounces and flushes at teardown.

    A PRIOR session's persisted board is restored through RestoreState (invoked by the session host after Initialize, before any surface binding): the saved JSON is rehydrated IN PLACE into the same WhiteboardState instance, so the save subscription and any later surface binding keep pointing at one engine. Malformed or incompatible payloads are tolerated — the board simply starts fresh.

    Hierarchy (View Summary)

    Implements

    Index

    Constructors

    Properties

    Context: RealtimeChannelContext | null

    The host context, available from Initialize until Dispose. null outside that window — guard with ?. in any code that can run early/late.

    Events$: Observable<RealtimeChannelEvent>

    Everything this channel streams out, as typed events: state changes, discrete user actions, frames pushed, opened/completed. Hosts subscribe (the embeddable element re-emits these as DOM events); the model is told about a change through a coalesced note instead — see RecordChange. Completes at Dispose.

    Output$: Observable<RealtimeChannelOutput>

    What the channel handed back when it completed (see Complete). Completes at Dispose.

    PerceptionOptions: ChannelPerceptionOptions

    Tuning for the perception coalescer (debounce window, max note size). Override to change it.

    SessionIdWaitIntervalMs: number
    SessionIdWaitTimeoutMs: number

    Max time ResolveAgentSessionId waits for the session id to bind before giving up, and the poll interval it re-checks on. Protected so tests can shrink the wait; production keeps the defaults (the real mint race is sub-second, 8s is generous headroom).

    State: WhiteboardState = ...

    The board's state of record — created fresh with the plugin (one per session).

    VisualVideoBridge: ChannelInboundVideoBridge | null

    The shared frame bridge that carries frames to the model's inbound video track. Deliberately NOT named videoBridge: channels that predate the pump (the Remote Browser, app channels) declare their own private videoBridge, and a second private of the same name in the base class would stop them compiling.

    StrictStateChecks: boolean

    Whether state snapshots are validated against the descriptor's noun schemas as notes are built — a development aid that surfaces a channel whose state drifted from its own declaration. On by default only when a Node-style environment reports a non-production NODE_ENV (tests, tooling); a browser production build never pays for it. Hosts may set it explicitly.

    Accessors

    • get CaptureKind(): RealtimeCaptureKind | null

      The runtime capture this channel fronts ('camera' or 'screen'), or null. Such a channel is the capture's policy: the runtime starts the capture only while the channel is in the session and the session's policy lets the agent see pixels through it, and the user's "agent can see" choice for the channel decides whether the capture's frames reach the model. Default null.

      Returns RealtimeCaptureKind | null

    • get CurrentChangeId(): number

      The id of the latest state change (0 before any).

      Returns number

    • get Exposure(): RealtimeChannelExposure

      How much of this channel the model may perceive without asking: the lowest of the channel's own ceiling (GetDescriptor().MaxExposure), the server policy and the user's choice. A channel nobody has applied a policy to simply has its ceiling, which is what every channel had before exposure policy existed.

      • 'none': no state notes and no frames.
      • 'state': structured state notes; no frames.
      • 'pixels': state notes and frames.

      It governs what flows to the model UNPROMPTED (perception notes, the contents of opened / completed notes, frames). It does not REDACT what a verb's result contains: a verb is all-or-nothing. A verb whose result would show the model something above this level declares ReturnsChannelData on the verb, and when this level is below it the verb is refused whole (exposure_restricted) and listed to the model as unavailable; see RefuseVerbForExposure. A verb that does not declare it returns what the channel says it returns, so a channel whose verbs reveal sensitive data must either declare it or lower its own MaxExposure.

      Returns RealtimeChannelExposure

    • get ExposureReasons(): readonly string[]

      Why Exposure is below the channel's ceiling; empty when it is not.

      Returns readonly string[]

    • get InstanceId(): string

      The channel's stable primary-instance id. A single-instance channel has exactly one; a RealtimeChannelDescriptor.MultiInstance channel owns further instance ids itself and routes by the instanceId argument of ApplyVerb. Appears in every structured note ([channel:<Key>#<instance>] …) and every RealtimeChannelEvent.

      Returns string

    • get ShowsAgentVideo(): boolean

      Whether this channel shows the agent's video: it sinks outbound video (GetSunkTracks). The runtime marks it as used when the video arrives, and a host presents its surface as the agent (the call overlay puts it in the agent's place in the call rather than in the focus layout).

      Returns boolean

    • get SurfacePlacement(): ChannelSurfacePlacement

      Where this channel's surface shows when a call starts, and where the user may move it: from the channel's registry row (UIConfig.Placement and UIConfig.AllowedPlacements). A channel without a row, or whose row says nothing, starts on its tab and can go anywhere.

      Returns ChannelSurfacePlacement

    • get TabColor(): string | null

      OPTIONAL accent color for the channel's tab (a CSS color string, e.g. an hsl() / token). When a plugin supplies one, the overlay paints the tab's dot + active underline with it; when omitted (the default null), the overlay derives a stable, deterministic color from the ChannelName so every channel still reads as a distinct, colored surface. A channel only overrides this to enforce a specific brand accent.

      Returns string | null

    • get ToolNamePrefix(): string

      The shared name prefix of every tool this channel exposes (e.g. 'Whiteboard_'). The host registers ONE local-execution route per plugin: tool calls whose name starts with this prefix go to ApplyAgentTool instead of the server relay.

      Default '' — a v2 channel with NO native tools (it is reached only through the ContextTool proxy). The host registers no route for an empty prefix: an empty prefix would match every tool name and hijack the server relay.

      Returns string

    Methods

    • Whether this channel wants to be offered the artifacts a delegated run just produced (the agent asked Skip or Sage to build something, and it came back as artifacts). A channel that hosts artifacts says yes for the ones it can show — and for an artifact it ALREADY shows, so a newer version replaces it in place.

      Asked of every channel in the session, mounted or merely advertised. For an advertised channel it is asked before the channel has been initialized, so it must not depend on Context; the channel's resolved configuration is passed in for exactly that reason. Saying yes for an advertised channel mounts it, so only answer yes when you will do something with the artifacts.

      Default: false — a channel that does not host artifacts is never bothered.

      Parameters

      Returns boolean

    • Applies exposure policy: the server's decision and the user's own choice. The runtime calls this when it mounts the channel and again whenever the user changes their choice.

      Withdrawing exposure takes effect immediately: a pending perception note is dropped, a pending frame is dropped, and the channel's video source stops being forwarded. Restoring it re-baselines (the model's picture of the channel is stale, so the next note is a full snapshot) and sends a fresh frame. When the call is live the model is told about the change, with the reason, so it never assumes it can still see what it can't.

      Parameters

      • settings: ChannelExposureSettings

        Policy — the server-decided exposure; User — the user's choice (omit for none); Reasons — why the policy lowered it, from the server's limits.

      Returns void

    • Runs one verb of this channel — the contract-v2 entry point, reached through the ContextTool proxy (and, via ApplyAgentTool, by native tool calls).

      The runtime has ALREADY resolved the verb against the descriptor, enforced InvokableBy, and validated args against the verb's parameter schema before calling this, so an override can trust its inputs' shape. It must work with no surface bound, and should not throw — return a failure result so the model can recover.

      Default: adapts the legacy ApplyAgentTool (the verb's native tool name, args as JSON), so every v1 channel is reachable through the proxy with no change. A v2 channel overrides this.

      Parameters

      • verb: string

        The verb name (as declared in the descriptor).

      • args: JSONObject

        The validated parameters.

      • actor: RealtimeChannelActor

        Who is acting: the agent (a model call) or the user (their own interaction).

      • OptionalinstanceId: string

        Which instance of a multi-instance channel; undefined for the primary instance.

      Returns RealtimeChannelVerbResult | Promise<RealtimeChannelVerbResult>

    • The channel finished and is handing something back (a submitted form, a chosen option, a finished game). Emits on Output$ and Events$ and tells the model with a completed note. The output is validated against the descriptor's Output schema when StrictStateChecks is on; a mismatch is logged, never swallowed into silence or thrown.

      Parameters

      • output: JSONObject

        What the channel hands back.

      • OptionalinstanceId: string

        The instance that completed, for a multi-instance channel (default: the primary instance).

      Returns void

    • An AGENT action succeeded and changed the channel's picture: push exactly one confirmation frame now and tell the model not to narrate its own change. Call only on SUCCESS — confirming a failed action would assert an edit landed that did not. A no-op until EnableVisualPerception ran.

      Returns Promise<void>

    • Emits a typed event on Events$ (NOT to the model — use RecordChange for state the model should perceive, or send an explicit note for a discrete event it must hear about).

      Parameters

      • name: string

        The event name (declare it in the descriptor's Events).

      • Optionalpayload: JSONObject

        The event payload.

      • OptionalchangeId: number

        The change id the event relates to, when it relates to one.

      • OptionalinstanceId: string

        The instance the event is about, for a multi-instance channel (default: the primary instance).

      Returns void

    • Opts this channel into VISUAL perception: its surface can be shown to a video-capable model as frames. Call it from OnInitialize with the channel's frame source.

      The channel then needs only to say when its picture changed — NotifyVisualChange after a user edit, ConfirmVisualChange after a successful agent edit — and the base class does the rest: change-driven (no idle heartbeat), paced to the negotiated cadence, a trailing settle so the model ends on the final state of a burst, dedupe of identical frames, and a single confirmation frame (with a "do not narrate" note) after an agent edit. Every frame is tagged with the change id of the state it was captured at (frame_pushed events), so state and pixels can be cross-checked.

      Also makes GetSourcedTracks report the inbound video track, which is what gets it negotiated. Idempotent: calling it again replaces the provider and options.

      Parameters

      Returns void

    • The descriptor verb a native tool call runs, or undefined when the tool is not one of the channel's verbs (the runtime uses it to apply RefuseVerbForExposure on the native-tool route as well as the ContextTool one).

      Parameters

      • toolName: string

        The native tool name the model called.

      Returns RealtimeChannelVerb | undefined

    • Sends any pending coalesced perception note now (e.g. before a surface is torn down).

      Returns void

    • A snapshot of the channel's things (the descriptor's nouns), keyed by noun name. Perception notes are computed as deltas between successive snapshots, so this must be a pure read.

      Default: the parsed SerializeState when that is a JSON object, else {} — which makes a v1 channel's state of record its (single, opaque) snapshot with no code change.

      Returns JSONObject

    • Media tracks this client channel can SINK — samples flowing from the model OUT. Default [].

      The session requests them when it connects, so the driver establishes the ones the model supports. A channel that sinks outbound video shows the agent's video: it follows RealtimeChannelContext.AgentVideo$, and counts as used once the video arrives, so the host shows its surface.

      Returns readonly RealtimeTrackDescriptor[]

    • Whether this channel has a rendered MJ surface (GetSurfaceComponent returns non-null). The overlay uses this to decide whether to register a surface tab; server-only channels are false. Override only if surface availability must be decided WITHOUT constructing the type (the default calls GetSurfaceComponent once).

      Returns boolean

    • The channel's picture changed because of a USER action (or a scene replacement): push a frame, respecting the cadence. Resolves when the decision has been carried out; never rejects. A no-op until EnableVisualPerception ran and the session has an inbound video track.

      Returns Promise<void>

    • A delegated run produced artifacts this channel said it wants (AcceptsDelegationArtifacts). The channel is mounted and initialized by now. Never throw into the runtime: handle your own failures and report them (the runtime logs anything that escapes, but cannot recover the work).

      Default: nothing.

      Parameters

      Returns void | Promise<void>

    • Subclass hook invoked once the realtime session is connected and live (the client driver is created, connected, and media tracks negotiated), or when the channel is opened in a live session. Channels that establish media bridges (e.g. video streaming) can start them here when Context.Client is available. Default: a channel with visual perception adds the inbound video track it sources when the call has none (it was opened mid-call) and brings its frame bridge up; any other channel does nothing. An override that keeps visual perception calls super.OnSessionStarted().

      Returns void

    • Called by the host when the bound surface comes into sight or goes out of it (the panel collapsed or hidden, another tab active, the call minimized). The surface stays bound and keeps its state; a channel can pause work nobody sees, such as a screenshot poll, and resume it when the surface is shown again. The host calls it right after BindSurface with the surface's current visibility, then on every change, and not after UnbindSurface. Default: no-op, so a surface keeps running out of sight.

      Parameters

      • _visible: boolean

      Returns void

    • Opens the channel — mounts it for use and seeds it with inputs. Called by the runtime when the agent (or user) opens an on-demand channel, after the channel has been initialized.

      Validates inputs against the descriptor's Inputs schema (a violation is a structured 'invalid_params' failure, never a half-opened channel), runs the OnOpen hook, then tells the model the channel is open and what it currently holds (opened note with a state snapshot) — and takes that snapshot as the baseline later changes are described against.

      Parameters

      • Optionalinputs: JSONObject

        What the agent asked to seed the channel with.

      Returns Promise<RealtimeChannelVerbResult>

    • Records that the channel's state changed. Call this on EVERY mutation, whoever caused it.

      It (1) assigns the change a monotonic id, (2) emits a state_changed event on Events$ immediately (observers see every change), and (3) — unless Perceive is false — schedules a COALESCED structured note to the model: a burst of N changes inside the debounce window produces ONE [channel:<Key>#<instance>] state_changed {"changeId":…,"changes":N,"delta":{…}} note carrying what differs from what the model was last told (the first note is a full snapshot). Notes that would be too large degrade to a list of changed paths.

      Parameters

      • Optionaloptions: { Author?: RealtimeChannelActor | "system"; Perceive?: boolean }

        Author — who made the change (carried on the event); Perceive — whether the model should be told (default true; a channel that already feeds the model its own perception — like the Whiteboard's scene deltas — passes false).

      Returns number

      The change's id.

    • Whether the agent may be given this verb's result at the channel's current exposure. A verb that declares ReturnsChannelData is refused whole when exposure is below that level, because its result would hand the agent what the user or a zero-data-retention policy held back from it. Policy, not redaction: the result is never filtered.

      Applies to the AGENT (the dispatcher and the native-tool route call it); a user acting through the surface is not restricted.

      Parameters

      Returns string | null

      The sentence to give the agent, or null when the call may proceed.

    • Resolves the live RealtimeChannelContext.AgentSessionID, briefly WAITING for it when it isn't bound yet rather than giving up instantly. AgentSessionID is a live getter over the session service's current id: it reads null in the window BEFORE the session mints (the realtime model can fire a tool call the very first beat it connects, before mintSession resolves) and again AFTER teardown. Server-backed tool paths (e.g. the Remote Browser channel's browser_* tools) call this instead of reading Context?.AgentSessionID synchronously, so a tool invoked a beat early WAITS for the session to come live — defense-in-depth against the "session id missing" race — instead of returning a hard failure to the model.

      Returns the id as soon as it's non-null (the common path resolves immediately, no delay), or null if it's still unbound after SessionIdWaitTimeoutMs — or the channel was Disposed in the meantime (Context goes null, so we stop waiting on a torn-down session).

      Returns Promise<string | null>

    • Maps a native tool name back to its verb: the descriptor's NativeToolName match first, then the name minus ToolNamePrefix. Protected so a channel with an unusual naming scheme can override it.

      Parameters

      • toolName: string

      Returns string

    • Checks the current GetState snapshot against the descriptor's noun schemas and returns every violation (empty when valid). Useful in a channel's own tests; the runtime also runs it on every perception note when StrictStateChecks is on.

      Returns string[]