Is there a standard (possibly legal) phrase to denote that a person has a clear mind and is capable of doing things well and understanding the consequences of their actions (as opposed to being e.g. drunk, high or sedated)?
There is the phrase “being of sound mind” which is often seen in a legal context.
One lawyer discusses the phrase in this page.
The Oxford Dictionaries has the following definition in its lengthy entry for sound, as the first meaning of the adjective.
1 In good condition; not damaged, injured, or diseased.
he was not of sound mind