Member Junction
    Preparing search index...

    The shared MEDIA SURFACE as a pluggable interactive channel — a BaseRealtimeChannelClient resolved from the MJ: AI Agent Channels registry row whose ClientPluginClass is 'RealtimeMediaChannel'. One instance per session (created via ClassFactory at session start).

    It owns a MediaChannelState engine and contributes the channel's full contract:

    • Action: the Media_* client-executed tool set (MEDIA_TOOL_DEFINITIONS); ApplyAgentTool parses the args, mutates the state engine, returns a short JSON result string, and sends the model a [media] background context note (so it stays aware of what's on screen). Works with NO surface bound — the tools mutate the state engine directly.
    • Surface: RealtimeMediaSurfaceComponent, created dynamically by the overlay's channel tab; BindSurface hands it the shared state engine + agent name.
    • State of record: every mutation requests a debounced save of MediaChannelState.ToJSON under channel name 'Media'; a prior session's media is rehydrated via RestoreState.

    Modeled directly on RealtimeWhiteboardChannel.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    Context: RealtimeChannelContext | null = null

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

    SessionIdWaitIntervalMs: number = 200
    SessionIdWaitTimeoutMs: number = 8000

    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: MediaChannelState = ...

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

    Accessors

    • 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

    Methods

    • Executes one Media_* tool call LOCALLY: parse args, mutate the state engine, push a [media] background context note so the agent stays aware of the surface, and return a short JSON result string for the model. Never throws — malformed args resolve to a { success: false, error } payload the model can narrate. Works with or without a bound surface (it mutates the state engine, which the surface observes).

      Parameters

      • toolName: string
      • argsJson: string

      Returns string

    • 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>