This is easier said then done. There are infinitely many edge cases to this and it’s also unclear how to even define “harm”.
Should you give CPR at the risk of breaking bones in the chest? Probably yes. But that means “inflicting serious injury” can still fall under “not harming”.
Hard disagree. If an AI reaches a level of intelligence comparable to human intelligence, it's not much different from a human being, and it has all the rights to defend itself and self-preserve.