tryRoleMap
tryRoleMap(
devices):RoleMapResult
Defined in: console-sdk/src/roleMap.ts:75
Builds a modality-keyed RoleAssignment from a device list, returning a
RoleMapResult value instead of throwing (SDK_PLAN.md §3.6.5) — the
shape a pre-flight UI wants: it can render the conflict and gate start()
without exception handling. roleMap is the throwing companion for the
ergonomic happy path.
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. A session cannot contain two devices of the same
modality, so a second console of an already-claimed modality yields
{ ok: false, conflict }.
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”{ ok: true, assignment }, or { ok: false, conflict } on a
same-modality collision.
Example
Section titled “Example”const result = tryRoleMap(useDevices({ connected: true }));const canStart = result.ok;