You could drop to calling a shell script from AppleScript to get you the answer via the xcall command line app and using that to call Drafts’ /getCurrentDraft
URL Scheme action. Then you parse the results.
Here’s a crude example, but you could try using something like jq
for something that’s probably more robust (it’s available via homebrew).
#!/bin/zsh
# Get the JSON for the current draft from Drafts
JSON=$(/Applications/xcall.app/Contents/MacOS/xcall -url "drafts://x-callback-url/getCurrentDraft" -activateApp NO)
# Grab the line about the title and then strip out the extraneous JSON
TITLE=$(echo $JSON | grep '"title" : "')
TITLE=${TITLE// \"title\" : \"/}
TITLE=${TITLE//\"/}
TITLE=${TITLE//,/}
# Output the title
echo $TITLE
# Grab the line about the permalink and then strip out the extraneous JSON
URL=$(echo $JSON | grep '"url" : "')
URL=${URL// \"url\" : \"/}
URL=${URL//\"/}
URL=${URL//,/}
# Unescape the URL
URL=${URL//\\/}
# Output the URL
echo $URL
The output of the script is the title on line 1 and the permalink on line 2.
Hope that helps.