This is described at https://rockorager.dev/misc/bracketed-paste-mime/ however the protocol described differs from kitty's actual behavor. This document is based on the linked page and has been modified to match Kitty's implementation of the protocol.
The main OSC 5522 spec can be found here: https://sw.kovidgoyal.net/kitty/clipboard/
Detection is performed with a standard DECRQM query: