Skip to content

roleMap

roleMap(devices): RoleAssignment

Defined in: console-sdk/src/roleMap.ts:123

Builds a modality-keyed RoleAssignment from a device list — the general fleet form of start({ devices }) (SDK_PLAN.md §3.6.5). The throwing companion to tryRoleMap: use this for the ergonomic happy path, tryRoleMap when you need to gate a UI on the conflict without a try/catch.

Only metrics-producing consoles with a modality participate: any device whose modality is null is ignored, so a full useDevices() list can be passed through unfiltered. Because a session cannot contain two devices of the same modality, encountering a second console of a modality already claimed throws SessionError 'session/invalid-plan' (carrying the conflicting device id) — the invariant is enforced here, before a plan is ever built.

readonly Device[]

Devices to assign — typically the fleet list; non-consoles are skipped.

RoleAssignment

A modality-keyed assignment of the eligible consoles.

'session/invalid-plan' when two consoles share a modality.

const devices = useDevices({ connected: true });
await start({ kind: 'free', devices: roleMap(devices), target });