Class JobContext<ProcessUserData>

The job and environment context as seen by the agent, accessible by the entrypoint function.

Type Parameters

  • ProcessUserData = Record<string, unknown>

Constructors

Accessors

  • get agent(): undefined | LocalParticipant
  • Returns undefined | LocalParticipant

    The agent's participant if connected to the room, otherwise undefined

  • get isFakeJob(): boolean
  • Returns boolean

    Whether this job is a locally-synthesized fake job (e.g. console mode).

  • get sessionDirectory(): string
  • Returns string

    The session directory for storing recordings and session data.

Methods

  • Adds a promise to be awaited whenever a new participant joins the room.

    Parameters

    • callback: ((job, p) => Promise<void>)

    Returns void

    Throws

    FunctionExistsError if an entrypoint already exists

  • Adds a promise to be awaited when shutdown is called.

    Parameters

    • callback: (() => Promise<void>)
        • (): Promise<void>
        • Returns Promise<void>

    Returns void

  • Connects the agent to the room.

    Parameters

    • Optional e2ee: E2EEOptions
    • autoSubscribe: AutoSubscribe = AutoSubscribe.SUBSCRIBE_ALL
    • Optional rtcConfig: RtcConfiguration

    Returns Promise<void>

    Remarks

    It is recommended to run this command as early in the function as possible, as executing it later may cause noticeable delay between user and agent joins.

    See

    @livekit/rtc-node for more information about the parameters.

  • Deletes the room and disconnects all participants.

    Parameters

    • Optional roomName: string

    Returns Promise<void>

  • Parameters

    • options: Required<RecordingOptions>

    Returns Promise<void>

  • Gracefully shuts down the job, and runs all shutdown promises.

    Parameters

    • reason: string = ''

      Optional reason for shutdown

    Returns void

  • Returns the SimulationContext when this job is running under a simulation, or undefined for a normal/production session.

    Resolved once and cached. The framework hands it to onSimulationEnd when the run finishes; read it earlier (e.g. from the entrypoint) to reach scenario.userdata for seeding mocks. Resolves synchronously from the job's lk.simulator.dispatch attribute (a protojson SimulationDispatch), available as soon as the job starts.

    Returns undefined | SimulationContext

  • Parameters

    • Optional identity: string

    Returns Promise<RemoteParticipant>