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.
Parameters
Section titled “Parameters”devices
Section titled “devices”readonly Device[]
Devices to assign — typically the fleet list; non-consoles are skipped.
Returns
Section titled “Returns”A modality-keyed assignment of the eligible consoles.
Throws
Section titled “Throws”'session/invalid-plan' when two consoles share a
modality.
Example
Section titled “Example”const devices = useDevices({ connected: true });await start({ kind: 'free', devices: roleMap(devices), target });