Photoshop's embedded JavaScript engine can only manipulate Photoshop. It doesn't even have a 'doAppleScript' method for executing embedded AppleScript code. If you need to interact with other applications, you will need to write your outer script in AppleScript and embed your JavaScript code inside that, using the 'do JavaScript' command to execute it.