Files
JiboOs/docs/bt/mim/MimManager.js
2026-03-16 13:53:01 +02:00

149 lines
4.3 KiB
JavaScript

/**
* Singleton for hooking into the MIM system.
* @namespace jibo.mim
*/
/**
* The default listen delegate class, for extending to make more advanced delegates.
* @name jibo.mim~GlobalListenDelegate
* @type {jibo.mim.GlobalListener}
* @private
*/
/**
* In the currently active MIM, respond to a 'hey jibo' happening. MIMs could listen to
* GlobalListen directly, but getting events through here allows us to limit the event to
* the currently active MIM, in case a MIM is running another MIM.
* @name jibo.mim#heyJibo
* @type {Event}
* @private
*/
/**
* In the currently active MIM, respond to the completion of a HJ event in which the MIM should
* continue. This includes HJ Only, HJ No Match, and Non Interrupting Global events.
* @name jibo.mim#heyJiboComplete
* @type {Event}
* @private
*/
/**
* If a Hey Jibo event currently active. Used by MIMs to determine when they started during an
* active HJ event.
* @name jibo.mim#isHeyJiboActive
* @type {boolean}
* @private
*/
/**
* If `true`, Question MIMs time out after the specfied `timeout` when run in the simulator.
* If `false` (default), time out when `enter` key is pressed.
* @name jibo.mim~timeoutIgnoresSimulator
* @type {Boolean}
*/
/**
* MimRepeatManager instance with loaded MIM data.
* @name jibo.mim~repeat
* @type {jibo.mim.MimRepeatManager}
* @private
*/
/**
* Promise to load MIM data used by all MIMs as global prompts.
* @name jibo.mim~globalMimLoad
* @type {Promise<void>}
* @private
*/
/**
* MIM data used by potentially all MIMs as response to the 'thanks' MIM global.
* @name jibo.mim~thanksResponse
* @type {jibo.mim.MimConfig}
* @private
*/
/**
* Listen delegate to be used by all MIMs to handle listening.
* @name jibo.mim~listenDelegate
* @type {ListenDelegate}
* @private
*/
/**
* Speaking delegate to be used by all MIMs to handle speech.
* @name jibo.mim~speakDelegate
* @type {SpeakDelegate}
* @private
*/
/**
* Root node of the KB model used to store prompt rotation info for MIMs within the `jibo`
* module.
* @name jibo.mim~jiboRotationNode
* @type {jibo.kb.Node}
* @private
*/
/**
* KB Models for each skill. These are kept in memory, because it isn't that much memory, and
* gives us slightly faster access when we use multiple MIMs from one skill. Also, right now
* everything lives in one process that never shuts down, and it won't matter when we have
* each skill in a separate process.
* @name jibo.mim~kbModels
* @type {Object.<string, jibo.kb.Model>}
* @private
*/
/**
* Loads the root node of a KB slice specific to an asset pack, so that data about prompt
* rotation can be persisted.
* @method jibo.mim~loadMimKB
* @param {string} assetPack The name of the skill/asset pack that the MIM is loaded from.
* @return {Promise<jibo.kb.Node>} The root node for that asset pack.
* @private
*/
/**
* Start loading any assets the Mims need. Called on creation of the first Mim. Mim does not
* wait for asset load to complete before continuing.
* @method jibo.mim~loadMimAssets
* @private
*/
/**
* Attach listeners for HJ and HJ ending events
* @method jibo.mim~attachHJListeners
* @private
*/
/**
* Callback for Hey Jibo events from the listening service.
* @method jibo.mim~onHeyJiboHeard
* @private
*/
/**
* Listener for Hey Jibo Only events, for recovering from the MIM's waitForHJEnd state.
* @method jibo.mim#onHJOnly
* @private
*/
/**
* Listener for Hey Jibo No Match events, for recovering from the MIM's waitForHJEnd state.
* @method jibo.mim#onHJNoMatch
* @private
*/
/**
* Listener for Non Interrupting Global events, for recovering from the MIM's waitForHJEnd state.
* @method jibo.mim#onShortGlobal
* @private
*/
/**
* Listener for the end of HJ listens that don't allow a MIM to continue - skill relaunches,
* interrupting globals, etc.
* @method jibo.mim#onHJEnd
* @private
*/