Nice to see that in JXA.
This vanilla AppleScript will cd the the current Terminal session (if not busy) to the front Finder window (or the Desktop if no windows are open) — it will open a new Terminal window IF the currently selected tab is busy.
tell application "Finder" to set _dir to insertion location as alias
tell application "Terminal"
tell selected tab of front window
if its busy = false then
do script "cd " & (quoted form of (POSIX path of _dir)) in it
else
do script "cd " & (quoted form of (POSIX path of _dir))
end if
end tell
end tell
-Chris