How to return value from executed script with chrome.devtools.inspectedWindow.eval

I’m trying to execute some script inside webpage from devtool panel using chrome.devtools.inspectedWindow.eval, the code is working fine but can’t figure out how to return response to callback. I am grateful for your support.

Executed script

const someScript = function () {
    alert("from panel")
    return 123
    // i can't return
}

Devtool

//this regex convert function body to string
someScript.toString().replace(/^functions*S+s*([^)]*)s*{|}$/g, ""),
   function (result, isException) {
       if (isException) {
           //exception always fire
           console.log("Result not received");
       } else {
           console.log("Selected element: " + result);
       }
});