Yes. It’s a library that you import into your scripts/rules. It’s standard JavaScript so you import it in the standard JavaScript way.
No, libraries do not appear in the UI anywhere. Only on the file system.
You might do well to go through a few JavaScript tutorials because for the most part, the OH docs will not cover the basics like how to import a library in depth. Importing an using a library is one of those basic JavaScript things.
I do notice that this is one of the several design pattern tutorials I need to update for JS Scripting but the usage example in the OP is still useful.
The first part (find and install) was done for you by openHABian so we can skip to the usage example.
If you break down the usage example, the first two lines import the library, third line creates the GateKeeper and the last two lines show adding a command to run with a 1 second delay following it and cancelling all scheduled commands.
If you look at the JS Scripting add-on’s docs it says
Scripts may include standard NPM based libraries by using CommonJS
require. The library search will look in the pathautomation/js/node_modulesin the user configuration directory.
Searching further down the page reveals a few examples of require but if you need more to understand it, there are many tutorials on the internet (e.g. How to use require() in ECMAScript modules - DEV Community).
Additionally, the openhab_rules_tools readme states:
Be sure to look at the comments, the code, and the tests for further details on usage and details.
A perfect example can be found in the Gatekeeper tests for how to import exactly the Gatekeeper itself. From that we find the require statement that imports Gatekeeper.
var { gatekeeper } = require('openhab_rules_tools');
Since you are running a version of OH prior to this past week, you’ll have to use the cache to save your Gatekeeper between runs of the rule, if you are creating rules in the UI.
var gk = cache.get(ruleUID+'_gk', () => new gatekeeper.Gatekeeper());
In any version of OH past 3.4 M5 you’ll use the privateCache or sharedCache which I believe will look something like this:
var { privateCache } = require('@runtime');
var gk = privateCache.get(ruleUID+'_gk', () => new gatekeeper.Gatekeeper());
Then you just use it. The first argument to addCommand is the amount of time to wait (supports anything supported by time.toZDT(), see JavaScript Scripting - Automation | openHAB) after executing the passed in command before executing the next one .
You may need to install the latest openhab-js library for openhab_rules_tools to work on an version of OH that old though. You can do that from openhabian_config.