// Accept the latest pending pairing notification regardless of mitra. Used
// by flows where the acceptor mitra UUID isn't known in advance — e.g.
// TS-02 (blast where the seeded mitra was forced offline, so an unknown
// OTHER online mitra got the chat_request_notification row).
//
// Backed by /internal/_test/accept-latest-pending (no body needed).
const url = BACKEND_INTERNAL_URL || 'http://localhost:3001'
const resp = http.post(`${url}/internal/_test/accept-latest-pending`, {
  headers: { 'Content-Type': 'application/json' },
  body: '{}',
})
if (resp.status !== 200) {
  throw new Error(`accept-latest-pending failed (${resp.status}): ${resp.body}`)
}
const data = json(resp.body)
output.ACCEPTED_SESSION_ID = data.session_id
output.ACCEPTOR_MITRA_ID = data.mitra_id
