In many books, I've seen the word 'spook' used to mean some kind of spy. Definition 5 on dictionary.reference.com confirms this usage, but is not very helpful about the origin.
Does anyone know how this definition came about? More details (does it only refer to American spies? only spies friendly to the speaker?) would also be appreciated.