whereEndoSock = (platform, env, info, protocol = 'captp0') => {
  // It must be possible to override the socket or named pipe location, but we
  // cannot use XDG_RUNTIME_DIR for Windows named pipes, so for this case, we
  // invent our own environment variable.
  if (env.ENDO_SOCK !== undefined) {
    return env.ENDO_SOCK;
  } else if (platform === 'win32') {
    // Named pipes have a special place in Windows (and in our ashen hearts).
    const user = env.USERNAME !== undefined ? env.USERNAME : info.user;
    return `\\\\?\\pipe\\${user}-Endo\\${protocol}.pipe`;
  } else if (env.XDG_RUNTIME_DIR !== undefined) {
    return `${env.XDG_RUNTIME_DIR}/endo/${protocol}.sock`;
  } else if (platform === 'darwin') {
    const home = env.HOME !== undefined ? env.HOME : info.home;
    return `${home}/Library/Application Support/Endo/${protocol}.sock`;
  }
  const user = env.USER !== undefined ? env.USER : info.user;
  const temp = env.TMPDIR !== undefined ? env.TMPDIR : info.temp;
  return `${temp}/endo-${user}/${protocol}.sock`;
}
Returns the most suitable path for the Endo UNIX domain socket or Windows
named pipe.

@type {typeof import('./types.js').whereEndoSock}