(value: unknown)
| 111 | } |
| 112 | |
| 113 | export function normalizeSession(value: unknown): AgentDeviceSession { |
| 114 | const { record, platform, id, name, target } = readClientDeviceIdentity(value, 'name'); |
| 115 | const deviceName = readRequiredString(record, 'device'); |
| 116 | const appleOs = readAppleOs(record); |
| 117 | const identifiers = { |
| 118 | session: name, |
| 119 | ...buildDeviceIdentifiers(platform, id, deviceName), |
| 120 | }; |
| 121 | return { |
| 122 | name, |
| 123 | createdAt: readRequiredNumber(record, 'createdAt'), |
| 124 | sessionStateDir: readOptionalString(record, 'sessionStateDir'), |
| 125 | runnerLogPath: readOptionalString(record, 'runnerLogPath'), |
| 126 | device: { |
| 127 | platform, |
| 128 | target, |
| 129 | id, |
| 130 | name: deviceName, |
| 131 | // Additive Apple-OS discriminant; present only when the daemon emits it (Apple devices). |
| 132 | ...(appleOs ? { appleOs } : {}), |
| 133 | identifiers, |
| 134 | ...buildClientDevicePlatformFields( |
| 135 | platform, |
| 136 | id, |
| 137 | readNullableString(record, 'ios_simulator_device_set'), |
| 138 | ), |
| 139 | }, |
| 140 | identifiers, |
| 141 | }; |
| 142 | } |
| 143 | |
| 144 | function readAppleOs(record: Record<string, unknown>): AppleOS | undefined { |
| 145 | const value = record.appleOs; |
no test coverage detected