Files
element-call/sdk
Timo K.andClaude Fable 5.1 12bb87fa4c Add the MatrixRTC SDK package, its harness and a failing smoke test
Set up `sdk/` as a package shaped exactly like `component/`: its own
package.json with peer dependencies, the pnpm workspace marker so a host can
install it as a git dependency, a build tsconfig for type emission, and a vite
lib config with an externals list that `pnpm lint:externals` now checks for
both library builds.

The package holds only the interface for now. `createRtcSession` returns an
empty object; `RtcSession`, `RtcMember`, `MemberMedia` and `TransportMetadata`
are the contract Element Call's `CallViewModel` will be rebuilt on (see
sdk-plan.md). The shared primitives are re-exported from `src` until the first
implementation slice moves them.

`sdk/dev` is the smallest consumer of the SDK: a plain page that logs in, joins
a room and renders one tile per member, served by `pnpm dev:sdk` on port 3002.
Playwright starts it as a third web server, and `playwright/sdk/smoke.spec.ts`
has two browsers join one session. It fails on the status line with the SDK's
own error until there is an implementation behind the interface.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-01 16:57:34 +02:00
..

MatrixRTC SDK (EXPERIMENTAL)

@element-hq/matrixrtc-sdk is the call model under Element Call, on its own: MatrixRTC memberships and transports, LiveKit connections, publishing, E2EE keys and the media of every member, as observables. It has no UI. Element Call's own CallViewModel is meant to become one consumer of it; the design is in sdk-plan.md.

Status: interface only. createRtcSession returns an object that does nothing. The development harness and its e2e test exist so the implementation can be built against them.

Using it

import {
  constant,
  createRtcSession,
  E2eeType,
  MatrixRTCMode,
  ObservableScope,
} from "@element-hq/matrixrtc-sdk";

const scope = new ObservableScope();
const session = createRtcSession(
  scope,
  client, // a matrix-js-sdk MatrixClient, logged in and syncing
  room, // the matrix-js-sdk Room to hold the session in
  {
    microphoneEnabled$: constant(true),
    cameraEnabled$: constant(true),
    audioInputDeviceId$: constant(undefined),
    videoInputDeviceId$: constant(undefined),
    videoProcessor$: constant(undefined),
  },
  {
    encryptionSystem: { kind: E2eeType.PER_PARTICIPANT },
    matrixRTCMode: MatrixRTCMode.Compatibility,
  },
);
session.join();

session.remoteMembers$.subscribe((members) => {
  // each member has displayName$, media$ and more; a media track is rendered
  // by handing it a <video> or <audio> element: track.attach(element)
});

// later
session.leave();
scope.end();

dev/main.ts is this example as a working page.

Development

Everything runs from the repository root. This directory is a pnpm project of its own only so that a host can install it as a git dependency (see pnpm-workspace.yaml).

pnpm dev:sdk              # the harness, https://localhost:3002
pnpm build:sdk            # dist/matrixrtc-sdk.js and dist/types
pnpm test:playwright playwright/sdk   # needs `pnpm backend`

Installing

pnpm add github:element-hq/element-call#<ref>&path:/sdk

The host supplies matrix-js-sdk, livekit-client and rxjs; the build leaves them external.