// Force-expire the most-recent searching chat_session by hitting the dev-only
// /internal/_test/force-pairing-timeout endpoint. Used by the Stage 5 maestro
// flow (05_searching_timeout.yaml) to drive the searching screen into the
// timeout state without waiting 5 minutes.
//
// Reads BACKEND_INTERNAL_URL from env (Maestro injects it from the flow).
const url = BACKEND_INTERNAL_URL || 'http://localhost:3001'
const resp = http.post(`${url}/internal/_test/force-pairing-timeout`, {
  body: JSON.stringify({ latest: true }),
  headers: { 'Content-Type': 'application/json' },
})
if (resp.status !== 200) {
  throw new Error(`force-pairing-timeout failed (${resp.status}): ${resp.body}`)
}
const data = json(resp.body)
output.SESSION_ID = data.session_id
