How to avoid the GUI password prompt when using `osascript`?
You can suppress the password interface by modifying your Mac's authorization rights.

Use the built-in security command line tool or authbuddy to change the system.preferences.accessibility right to allow:

sudo security authorizationdb write system.preferences.accessibility allow


Opening up the system.preferences.accessibility right will permit any user to change the accessibility settings without a password prompt.