BOLT-1322 [6/7] adapters/oem/tesla: handle vehicle:check-pairing-status, populate command.executed output
completedNew handler that runs on Kafka CommandIssuedEvent for the new slug, calls Tesla fleet_status, derives keypair + extended caps, and publishes CommandExecutedEvent with populated output.
1. New file: adapters/oem/src/manufacturers/tesla/events/command.issued/vehicle/handleCheckPairingStatus/index.ts
- Inputs: { accessToken, deviceId (manufacturerDeviceId = VIN), payload }
- Behavior:
a) Call existing tesla fleet_status flow to fetch keyPairedVins + vehicle_info for this VIN. Look at adapters/oem/src/manufacturers/tesla/services/tesla/index.ts for the existing helper; reuse it (likely getDevices() already does fleet_status — check what it returns relative to keyPairedVins).
b) Call adapters/oem/src/manufacturers/tesla/common/fleet-status/index.ts::deriveKeyPaired() with the VIN, keyPairedVins set, and vehicleInfo.
c) Call extractExtendedCapabilities() with the same VIN + vehicleInfo.
d) Return { keyPaired, extendedCapabilities, applicable: true }.
2. Wire into adapters/oem/src/manufacturers/tesla/events/command.issued/index.ts switch statement (alongside the existing 'vehicle:set-charge-limit', etc.):
case 'vehicle:check-pairing-status':
const output = await handleCheckPairingStatus({...});
const commandExecutedEvent: CommandExecutedEvent = {
id: event.id,
status: 'completed',
deviceOnWorkspaceId: event.deviceOnWorkspaceId || event.deviceWorkspaceId,
workspaceId: event.workspaceId,
output,
};
await publishWithRetry(publisher, event.id, commandExecutedEvent, cmdLogger);
emitCommandExecutedMetric(event, 'completed');
return;
3. Tests: unit-level handler test (mocked tesla client) covering happy-path + fleet-status-unavailable + VIN-not-in-set cases. Confirm output shape matches VehicleCheckPairingStatusCommandOutputSchema.
4. Do NOT publish device.detected from this handler — that's the long-running path Amazon wants to skip. The whole point is the short round-trip via command.executed.output.
Branch: havoc/bolt-1322-tesla-adapter
Worktree: ../mono-bolt-1322-tesla-adapter
Depends on: [1/7] [2/7]
Done when: handler test passes, integration into command.issued switch is correct, no regression on other vehicle command flows.
Event Timeline
created
status_change
queued → in_progress
failed
lease expired — re-queued for retry
in_progress → queued
status_change
queued → completed