feat: Add Be and tbd skill, also added Roadmap file

This commit is contained in:
2026-05-10 16:32:12 -04:00
parent 3500ade13f
commit 0bb8885802
29587 changed files with 10611695 additions and 0 deletions

View File

@@ -0,0 +1,86 @@
/**
* @namespace jibo.jetstream.types
*/
/**
* @namespace jibo.jetstream.request
*/
/**
* Initializes client. Connects to WS server in Jetstream
* @method jibo.jetstream#init
* @param options {jibo.jetstream.types.HostOptions}
* @param [log] {JiboLog}
* @returns {Promise<void>}
*/
/**
* Closes client. Disconnects to WS server in Jetstream
* @method jibo.jetstream#close
*/
/**
* Notifies the Proactive Selector of an opportunity for proactive behavior
* @method jibo.jetstream#triggerProactive
* @param {ProactiveRequestData} data See [ProactiveRequestData](https://pegasus-api-docs.jibo.com/index.html#proactiverequestdata)
* @returns {Promise<jibo.jetstream.request.ProactiveRequest>}
*/
/**
* Starts a local listening turn
* @method jibo.jetstream#startLocalTurn
* @param {jibo.jetstream.types.LocalTurnOptions} data Options for the turn.
* @returns {Promise<jibo.jetstream.request.LocalTurnRequest>}
*/
/**
* Mimics a global listening turn. This is primarily for launching cloud skills from the robot.
* @method jibo.jetstream#mimicGlobalTurn
* @param {jibo.jetstream.types.MimicGlobalTurnOptions} data Options for the turn.
* @returns {Promise<jibo.jetstream.request.Request>}
*/
/**
* Subscribes a global handler to a selected set of NLU rules.
* @method jibo.jetstream#subscribeGlobal
* @param {jibo.jetstream.types.SubscribeGlobalOptions} data Options for the turn.
* @returns {Promise<jibo.jetstream.request.SubscribeGlobalRequest>}
*/
/**
* @method jibo.jetstream#cancelAnyTurn
* @return {Promise<void>}
*/
/**
* Enables HJ listening.
* @method jibo.jetstream#setHJMode
* @param {jibo.jetstream.types.HJMode} mode
* @returns {Promise<void>}
* @private
*/
/**
* Queries whether HJ listening is active.
* @method jibo.jetstream#getHJMode
* @returns {Promise<jibo.jetstream.types.HJMode>}
* @private
*/
/**
* Changes how hotword listening is handled, from fully disabled to adding additional API.AI grammars.
* @method jibo.jetstream#setHotwordMode
* @param {jibo.jetstream.types.HotwordListenMode} mode Mode to set to.
* @param {string[]} [rules] Additional grammars
* @returns {jibo.jetstream.HotwordModeToken}
*/
/**
* Resets the hotword mode, releasing all tokens.
* @method jibo.jetstream#resetHotwordMode
* @return {Promise<void>}
*/
/**
* Needed to make a fresh client in tests.
*/

View File

@@ -0,0 +1,56 @@
/**
* @name jibo.jetstream.Client#events
* @type jibo.jetstream.Events
*/
/**
* @name jibo.jetstream.Client#options
* @type {jibo.jetstream.types.HostOptions}
*/
/**
* @name jibo.jetstream.Client._requests
* @type {Map}
* @description `Map<string, Request>`
*/
/**
* Logging object internal to this library
* @private
*/
/**
* Has the instance been initialized?
* @private
*/
/**
* Are we currently connected?
* @private
*/
/**
* Initializes client. Connects to WS server in Jetstream
* @returns {Promise<void>}
* @method jibo.jetstream.Client#init
* @param options {jibo.jetstream.types.HostOptions}
* @param [log] {JiboLog}
*/
/**
* Closes websocket connection
* @method jibo.jetstream.Client#close
*/
/**
* Gets the requestID from the response (if it exists).
* @method jibo.jetstream.Client#getRequestID
* @param {any} response Response from the Jetstream request.
* @return {string}
*/
/**
* Allows emitting of turn result events so that we can sort of clean up robot state in the
* event of something going horribly wrong.
* @private
*/

View File

@@ -0,0 +1,15 @@
/**
* Add a cloud response entry
* @param transID
*/
/**
* Resolve a skill response when it arrives
* @param transID
* @param skillResponse
*/
/**
* Cull all old entries and reject outstanding promises
* @param maxAgeMs
*/

View File

@@ -0,0 +1,83 @@
/**
* @name jibo.jetstream.events#error
* @type {Event<Error>}
* @description `ERROR`
*/
/**
* @name jibo.jetstream.events#sos
* @type {Event}
* @description `Start of speech`
*/
/**
* @name jibo.jetstream.events#eos
* @type {Event}
* @description `End of speech`
*/
/**
* @name jibo.jetstream.events#hjHeard
* @type {Event}
* @description `HJ Heard`
*/
/**
* @name jibo.jetstream.events#hjOnly
* @type {Event}
* @description `HJ Only`
*/
/**
* @name jibo.jetstream.events#speakerID
* @type {Event<jibo.jetstream.types.SpeakerIDData>}
* @description `Speaker ID`
*/
/**
* @name jibo.jetstream.events#localTurnStarted
* @type {Event}
* @description `Local Turn started`
*/
/**
* @name jibo.jetstream.events#localTurnResult
* @type {Event<jibo.jetstream.types#TurnResult>}
* @description `Local Turn result`
*/
/**
* @name jibo.jetstream.events#globalTurnStarted
* @type {Event}
* @description `Global Turn started`
*/
/**
* @name jibo.jetstream.events#globalTurnResult
* @type {Event<jibo.jetstream.types#TurnResult>}
* @description `Global Turn result`
*/
/**
* @name jibo.jetstream.events#skillSwitch
* @type {Event<jibo.jetstream.types.SkillSwitchResult>}
* @description `Skill Switch`
*/
/**
* @name jibo.jetstream.events#speakerEnrollment
* @type {Event<jibo.jetstream.types.EnrollmentCollectionResult>}
* @description `Speaker Enrollment`
*/
/**
* @name jibo.jetstream.events#vad
* @type {Event<jibo.jetstream.types.VADEvent>}
* @description `VAD Event` - Voice activity detection
*/
/**
* @name jibo.jetstream.events#connect
* @type {Event<void>}
* @description `Connect` - When the client connects (or reconnects) to Jetstream
*/

View File

@@ -0,0 +1,65 @@
/**
* @private
*/
/**
* Token representing a call to jibo.jetstream.setHotwordMode().
* @class jibo.jetstream.HotwordModeToken
*/
/**
* @private
*/
/**
* @private
*/
/**
* Promise for when the mode is fully active, if you wanted to wait on it.
* @name jibo.jetstream.HotwordModeToken#activated
* @type {Promise<void>}
*/
/**
* `Global match`
* @name jibo.jetstream.HotwordModeToken#match
* @type {Event<jibo.jetstream.types.SuccessTurnResult>}
*/
/**
* @name jibo.jetstream.HotwordModeToken#globalRequest
* @type {jibo.jetstream.request.SubscribeGlobalRequest}
* @private
*/
/**
* If token has not been released.
* @name jibo.jetstream.HotwordModeToken#valid
* @type {boolean}
* @private
*/
/**
* @hideConstructor
*/
/**
* Releases the token, permanently disabling it.
* @method jibo.jetstream.HotwordModeToken#release
* @returns {Promise<void>}
*/
/**
* Cleanup without modifying hotword mode. This way we can remove tokens en-masse
* and update the mode once at the end.
* @private
*/
/**
* @private
*/
/**
* @private
*/

View File

@@ -0,0 +1,156 @@
/**
* @private
*/
/**
* Enum of request statuses.
* @typedef jibo.jetstream.request#RequestStatus
* @prop ACTIVE Once a request has been sent.
* @prop CANCELED Once a request has been canceled or unsubscribed.
* @prop FINISHED When a request has finished (including due to error).
*/
/**
* @description The base type of request that the client makes to the Jetstream
* service. Keeps track of requestID, status, events and errors
* @class jibo.jetstream.request.Request
* @hideconstructor
*/
/**
* ID of the request.
* @name jibo.jetstream.request.Request#id
* @type {string}
*/
/**
* Status of the request.
* @name jibo.jetstream.request.Request#status
* @type {jibo.jetstream.request#RequestStatus}
* @default RequestStatus.ACTIVE
*/
/**
* Events attached to the request.
* @name jibo.jetstream.request.Request#events
* @type {Event<jibo.jetstream.types#ServiceEvent>}
*/
/**
* Error event attached to the request.
* @name jibo.jetstream.request.Request#error
* @type {Event<Error>}
*/
/**
* @private
*/
/**
* The request object returned by client when proactive request made
* @export
* @class jibo.jetstream.request.ProactiveRequest
* @extends {jibo.jetstream.request.Request}
* @hideconstructor
*/
/**
* @description This promise gets resolved when the proactive session is completed.
* See [ProactiveResponseData](https://pegasus-api-docs.jibo.com/interfaces/proactiveresponsedata.html)
* @name jibo.jetstream.request.ProactiveRequest#promise
* @type {Promise<ProactiveResponseData>}
*/
/**
* The request object returned by client when listening turn is started
* @export
* @class jibo.jetstream.request.LocalTurnRequest
* @extends {jibo.jetstream.request.Request}
* @hideconstructor
*/
/**
* Promise that will yield the results of the Local Turn
* @name jibo.jetstream.request.LocalTurnRequest#promise
* @type {Promise<jibo.jetstream.types#TurnResult>}
*/
/**
* Cancels an ongoing request
* @returns {Promise<boolean>} `false` if the request could not be canceled.
* @method jibo.jetstream.request.LocalTurnRequest#cancel
*/
/**
* Update (that is, force the completion of) an in-progress local turn with the given NLU or
* ASR text information. This function is provided to allow a menu button push to simulate NLU
* input to the skill. When invoked, the audio being streamed to the Hub is stopped and the Hub
* accepts the provided ASR or NLU data as input. There is a potential race condition where the
* given ASR/NLU data is sent to the Hub but the Hub receives the ASR or NLU result first,
* which causes the update command to be ignored.
* @param asrOrNlu {string|jibo.jetstream.types.NLUResult} An ASR string or NLU result to update the turn with.
* See [NLUResult](https://pegasus-api-docs.jibo.com/interfaces/nluresult.html)
* @param [meta] {any} Metadata to be sent along for logging purposes.
* @returns {Promise<void>}
* @method jibo.jetstream.request.LocalTurnRequest#update
*/
/**
* The request object returned by client when global handler is subscribed
* @export
* @class jibo.jetstream.request.SubscribeGlobalRequest
* @extends {jibo.jetstream.request.Request}
* @hideconstructor
*/
/**
* Unsubscribes a global request
* @returns {Promise<boolean>} `false` if the request could not be unsubscribed.
* @method jibo.jetstream.request.SubscribeGlobalRequest#unsubscribe
*/
/**
* The request object returned by client when enrollment turn is started
* @export
* @class jibo.jetstream.request.EnrollmentTurnRequest
* @extends {jibo.jetstream.request.Request}
* @hideconstructor
*/
/**
* Promise that will yield the results of the Enrollment Turn
* @name jibo.jetstream.request.EnrollmentTurnRequest#promise
* @type {Promise<jibo.jetstream.types#EnrollmentTurnResult>}
*/
/**
* Ennrollment turn has started (ready for first HJ to be said)
* @name jibo.jetstream.request.EnrollmentTurnRequest#ready
* @type {Event<jibo.jetstream.types.EnrollmentCollectionResult>}
*/
/**
* Cancels an ongoing request
* @returns {Promise<boolean>} `false` if the request could not be canceled.
* @method jibo.jetstream.request.EnrollmentTurnRequest#cancel
*/
/**
* The request object returned by client when name learning turn is started
* @export
* @class jibo.jetstream.request.NameLearningRequest
* @extends {jibo.jetstream.request.Request}
* @hideconstructor
*/
/**
* Promise that will yield the results of the Name Learning Turn
* @name jibo.jetstream.request.NameLearningRequest#promise
* @type {Promise<jibo.jetstream.types.NameSuccessTurnResult>}
*/
/**
* Cancels an ongoing request
* @returns {Promise<boolean>} `false` if the request could not be canceled.
* @method jibo.jetstream.request.NameLearningRequest#cancel
*/

View File

@@ -0,0 +1,313 @@
/**
* TurnResult type
* ```
* BaseTurnResult<TurnResultType.INTERRUPTED> |
* BaseTurnResult<TurnResultType.CANCELED> |
* BaseTurnResult<TurnResultType.TIMEOUT> |
* FailedTurnResult |
* SuccessTurnResult
* ```
* @typedef jibo.jetstream.types#TurnResult
*/
/**
* NameTurnResult type
* ```
* BaseTurnResult<TurnResultType.INTERRUPTED> |
* BaseTurnResult<TurnResultType.CANCELED> |
* BaseTurnResult<TurnResultType.TIMEOUT> |
* FailedTurnResult |
* NameSuccessTurnResult
* ```
* @typedef jibo.jetstream.types#NameTurnResult
*/
/**
* EnrollnentTurnResult type
* ```
* BaseTurnResult<TurnResultType.INTERRUPTED> |
* BaseTurnResult<TurnResultType.CANCELED> |
* BaseTurnResult<TurnResultType.TIMEOUT> |
* FailedTurnResult |
* EnrollmentSuccessTurnResult
* ```
* @typedef jibo.jetstream.types#EnrollmentTurnResult
*/
/**
* ServiceEvent type. </br>
* ```
* BaseServiceEvent<ServiceEventType.EOS, void> |
* BaseServiceEvent<ServiceEventType.SOS, void> |
* BaseServiceEvent<ServiceEventType.ERROR, ErrorData> |
* BaseServiceEvent<ServiceEventType.SPEAKER_ID, SpeakerIDData> |
* BaseServiceEvent<ServiceEventType.HJ_HEARD, void> |
* BaseServiceEvent<ServiceEventType.HJ_ONLY, void> |
* BaseServiceEvent<ServiceEventType.TURN_STARTED, void> |
* BaseServiceEvent<ServiceEventType.TURN_RESULT, TurnResult> |
* BaseServiceEvent<ServiceEventType.TURN_RESULT, NameTurnResult> |
* BaseServiceEvent<ServiceEventType.TURN_RESULT, EnrollmentTurnResult> |
* BaseServiceEvent<ServiceEventType.SKILL_ACTION, SkillResponseData> |
* BaseServiceEvent<ServiceEventType.PROACTIVE, ProactiveResponseData> |
* BaseServiceEvent<ServiceEventType.SPEAKER_ENROLLMENT, EnrollmentCollectionResult>
* ```
* @typedef jibo.jetstream.types#ServiceEvent
*/
/**
* Enum of hotword listen modes.
* @typedef jibo.jetstream.types.HotwordListenMode
* @prop Disabled `0` HJ listening is disabled entirely, including cloud listening in response.
* @prop HJ_Only HJ listening is enabled, but no cloud listening will take place in response to HJ.
* @prop ASR_Only When cloud listening in response to HJ, no `NLU/API.AI` parsing is done, just the
* ASR is returned.
* @prop Custom_NLU_Only When cloud listening in response to HJ, ONLY rules added at `Custom_NLU_Only`
* levels are used for `API.AI` parsing.
* @prop Custom_NLU_Added When cloud listening in response to HJ, rules added at `Custom_NLU_Added `
* levels are used for `API.AI` parsing on top of the normal globals.
* @prop Normal Default mode, HJ listening is enabled as well as cloud listening with global
* rules in response.
*/
/**
* @typedef jibo.jetstream.types.TurnResultType
* @prop SUCCEEDED
* @prop INTERRUPTED
* @prop CANCELED
* @prop FAILED
* @prop TIMEOUT
*/
/**
* Enum of "Hey Jibo" mode options.
* @typedef jibo.jetstream.types.HJMode
* @prop NORMAL_HJ Normal response to HJ hotword.
* @prop IGNORE_HJ Don't respond to HJ hotword (including events).
* @prop ONLY_HJ Respond to HJ, but don't start an ASR turn.
* @private
*/
/**
* Enum of service event types
* @typedef jibo.jetstream.types.ServiceEventType
* @prop EOS End of speech
* @prop SOS Start of speech
* @prop ERROR Error
* @prop SPEAKER_ID Speaker ID
* @prop HJ_Heard Heard "hey jibo"
* @prop HJ_Only Heard "Hey Jibo" and nothing else
* @prop SKILL_ACTION Cloud skill action
* @prop SKILL_REDIRECT Cloud skill redirect
* @prop TURN_STARTED Turn started
* @prop TURN_RESULT Turn result
* @prop PROACTIVE Proactive
*/
/**
* Information on how to contact Hub.
* @interface jibo.jetstream.types.HostOptions
* @prop hostname {string} Host name of Hub service (ex. `localhost`)
* @prop port {number} Hub port number.
*/
/**
* Base interface for the different Service event types.
* @interface jibo.jetstream.types.BaseServiceEvent
* @prop type {jibo.jetstream.types.ServiceEventType} ServiceEventType enum.
* @prop requestID {string} Either `GLOBAL` or a specific turn requestID.
* @prop transID {string} The transaction ID associated with this hub transaction
* @prop ts {number} Timestamp at sending time.
* @prop data {any} Payload, depending on `type`.
*/
/**
* @interface jibo.jetstream.types.MimicGlobalTurnOptions
* @prop [clientASR] {string} The ASR text result desired from this turn. If present, no audio will be sent to the hub.
* @prop [clientNLU] {jibo.jetstream.types.NLUResult} The semantic result desired from this turn. If present, no audio will be sent to the hub.
* @prop [language] {string} ISO language label, e.g. "en-US"
* @prop [suppressedEvents] {jibo.jetstream.types.ServiceEventType[]} List of event names to suppress during this turn. It is suggested that this not be used by skills.
*/
/**
* Interface for local turn options.
* @interface jibo.jetstream.types.LocalTurnOptions
* @prop nluRules {string[]} A list of API.AI contexts.
* @prop [ignoreHJ] {boolean} If HJ can interrupt cloud listen.
* @prop [rejectIfBusy] {boolean} Reject this request if Jetstream is busy. Default false.
* @prop [meta] {any} An arbitrary JSON object for caller data, passed back in result.
* @prop [earlyEOS] {string[]} A list of phrases that cause EOS to be detected.
* @prop [hintPhrases] {string[]} A list of phrases that ASR will be biased towards detecting.
* @prop [clientASR] {string} The ASR text result desired from this turn. If present, no audio will be sent to the hub.
* @prop [clientNLU] {jibo.jetstream.types.NLUResult} The semantic result desired from this turn.
* If present, no audio will be sent to the hub. </br> See [NLUResult](https://pegasus-api-docs.jibo.com/interfaces/nluresult.html)
* @prop [log] {any} Arbitrary JSON object to be attached to logs related to this turn
* @prop [language] {string} ISO language label, e.g. "en-US"
* @prop [ignoreGlobalRules=false] {boolean} If active global rules should not be allowed during this turn.
* @prop [suppressedEvents] {jibo.jetstream.types.ServiceEventType[]} List of event names to suppress during this turn. It is suggested that this not be used by skills.
* @prop [sosTimeout] {number} The period of time to wait (in seconds) for the Start Of Speech after starting to listen. If speech is not heard within this period, the turn completes with a status of TIMEOUT and message of "sos". If this property is set to -1 (or not provided) the value used is the one found in the jibo-jetstream-service.json file.
* @prop [maxSpeechTimeout] {number} The maximum number of seconds that a user may speak. If the user speaks for more than this number of seconds, the turn completes with a status of TIMEOUT and message of "maxSpeech". As with sosTimeout, a value of -1 causes the config file property to be used.
*/
/**
* Interface for local turn updates.
* @interface jibo.jetstream.types.LocalTurnUpdate
* @prop requestID {string} The requestID of the in-progress turn to be updated.
* If the turn for the given requestID is no longer active, this call is ignored.
* @prop [meta] {any} An arbitrary JSON object for caller data, passed back in result.
* @prop [clientASR] {string} The ASR text result desired from this turn.
* This is a simple string of words, equivalent to what the ASR returns.
* Only one of the clientASR and clientNLU properties should be provided,
* if both are provided only the clientNLU property will be used.
* @prop [clientNLU] {jibo.jetstream.types.NLUResult} The semantic result desired from this turn.
* This will be the same JSON schema that arrives as the `data.result.nlu`
* field in a successful TURN_RESULT message.
* </br> See [NLUResult](https://pegasus-api-docs.jibo.com/interfaces/nluresult.html)
*/
/**
* Interface for speaker recognition results.
* @interface jibo.jetstream.types.SpeakerRecogResult
* @prop speaker {string} The ID string used to enroll this speaker.
* @prop score {number} authentication score (not useful without knowing the threshold)
* @prop accepted {boolean} If true, this speaker's score was high enough to be considered "recognized"
* @prop high_confidence {boolean} If true, this speaker's score was either high enough that the system
* is confident in accepting it, or low enough that it is confident in rejecting it.
*/
/**
* Speaker ID is emitted only if there are enrolled speakers.
* @interface jibo.jetstream.types.SpeakerIDData
* @prop speakers {jibo.jetstream.types.SpeakerRecogResult[]} An array of SpeakerRecogResult
* objects (sorted in descending score order) with one entry for each enrolled speaker
* that states how well that speaker was recognized.
* @prop snr {number} The estimated signal-to-noise ratio of the HJ input used in the
* speaker recognition operation.
*/
/**
* Interface to Hub for an individual speaker recognition result.
* @interface jibo.jetstream.types.HubSpeakerRecogResult
* @prop {string} id - The ID string used to enroll this speaker.
* @prop {number} score - Authentication score (not useful without knowing the threshold)
* @prop {boolean} high_confidence - If `true`, this speaker's score was either high enough that the system
* is confident in accepting it, or low enough that it is confident in rejecting it.
*/
/**
* Interface to Hub for speaker recognition results, filtered and sorted by confidence.
* @interface jibo.jetstream.types.HubSpeakerRecogResults
* @prop {jibo.jetstream.types.HubSpeakerRecogResult[]} accepted - List of speakers ID'd that are
* above a certain confidence threshold.
*/
/**
* Base interface for turn results
* @interface jibo.jetstream.types.BaseTurnResult
*/
/**
* Status of turn result
* @name jibo.jetstream.types.BaseTurnResult#status
* @type {jibo.jetstream.types.TurnResultType}
*/
/**
* Where {@link jibo.jetstream.types.TurnResultType} = `FAILED`
* @interface jibo.jetstream.types.FailedTurnResult
* @extends jibo.jetstream.types.BaseTurnResult
* @prop message {string} Message providing information on error/failure.
*/
/**
* @description Where {@link jibo.jetstream.types.TurnResultType} = `SUCCEEDED` from a local or global turn.
* @interface jibo.jetstream.types.SuccessTurnResult
* @extends jibo.jetstream.types.BaseTurnResult
* @prop result.asr {ASRResult} [ASRResult](https://pegasus-api-docs.jibo.com/interfaces/asrresult.html)
* @prop result.nlu {NLUResult} [NLUResult](https://pegasus-api-docs.jibo.com/interfaces/nluresult.html)
* @prop [result.match] {GlobalMatchResponseData} [GlobalMatchResponseData](https://pegasus-api-docs.jibo.com/interfaces/globalmatchresponsedata.html)
*/
/**
* @description Where {@link jibo.jetstream.types.TurnResultType} = `SUCCEEDED` from a name learning turn.
* @interface jibo.jetstream.types.NameSuccessTurnResult
* @extends jibo.jetstream.types.BaseTurnResult
* @prop message {string} The learned pronunciation
*/
/**
* @description Where {@link jibo.jetstream.types.TurnResultType} = `SUCCEEDED` from a voice enrollment turn.
* @interface jibo.jetstream.types.EnrollmentSuccessTurnResult
* @extends jibo.jetstream.types.BaseTurnResult
*/
/**
* Interface for options around enabling/disabling 'Hey Jibo' listening.
* @interface jibo.jetstream.types.SetHJEnabledOptions
* @prop enabled {boolean} `true` if 'Hey Jibo' listening should be enabled.
*/
/**
* @description Provides the SkillID of the CloudSkill that matched the NLU in addition.
* </br> Extends [GlobalMatchResponseData](https://pegasus-api-docs.jibo.com/interfaces/globalmatchresponsedata.html)
* @interface jibo.jetstream.types.GlobalAndCloudMatchResponseData
* @extends GlobalMatchResponseData
* @prop [cloudSkill] {string} - SkillID of Cloud Skill
*/
/**
* Interface for subscribing to global options.
* @interface jibo.jetstream.types.SubscribeGlobalOptions
* @prop nluRules {string[]} One or more NLU rules to subscribe to.
* @prop [meta] {any} An arbitrary JSON object for caller data, passed back in result.
* @prop [language] {string} The language of transcription: `'en-US'` , `'ja-JP'`, or `'zh-CN'`.
* @prop [exclusive] {boolean} If `true`, only global subscriptions marked as exclusive will be used. Others will be temporarily disabled.
*/
/**
* Interface for the speaker model results
* @interface jibo.jetstream.types.SpeakerModelResult
* @prop [message] {string} In case of `FAILED`, the reason.
*/
/**
* Interface for enrollment collection results
* @interface jibo.jetstream.types.EnrollmentCollectionResult
* @prop good_utterance_count {number} The number of utterances accepted so far during this turn.
* @prop total_utterance_count {number} The total number of utterances seen so far during this turn.
* @prop accepted {boolean} Whether the last enrollment was usable for training
* @prop problems {string[]} If `data.accepted` is `false`, this is a string vector containing
* the problem(s) with the utterance. The possible values are:
* - `CLIPPING`
* - `POOR_SNR`
* - `NOT_SPEECH_LIKE`
* - `NOT_CONSISTENT`
* - `BAD_DURATION`
* @prop final {boolean} `true` if the number of acceptable utterances matches the `numberOfUtterances`
* parameter specified when the enrollment turn was started. After this the turn will complete
* and no further Speaker Enrollment messages will appear.
* @prop speaker {string} The ID of the speaker being enrolled.
* @prop snr {number} The estimated SNR of the HJ utterance.
*/
/**
* Interface describing a Voice Activity Detection (VAD) event.
* @interface jibo.jetstream.types.VADEvent
* @prop name {string} Name of the event. Unlikely to be useful, but present in case of additional events in the future.
* @prop timestamp {number} Timestamp of the event.
* @prop audio_time {number} Timestamp of the audio. Will be slightly off from `timestamp`.
* @prop avg_frame_db {number} Average db of this audio frame.
* @prop VADEvents {jibo.jetstream.types.VADFrame[]} List of VAD frames from the audio data. Due to VAD frames having different durations than audio frames, this will be 2 or 3 frames long.
*/
/**
* Interface describing the data in a Voice Activity Detection (VAD) frame.
* @interface jibo.jetstream.types.VADFrame
* @prop time {number} Timestamp of the frame.
* @prop vad {number} Rating from -1 to 1 of how like human speech this frame is, with 1 being speech-like.
*/
/**
* @class ListenResult
* @memberof jibo.jetstream.types
* @description Results of a turn, with helper getters.
*/

View File

@@ -0,0 +1,8 @@
/**
* @description Helper method to send post requests to a provided location.
* @method jibo.jetstream.Utils#sendPostRequest
* @param hostOptions {jibo.jetstream.types.HostOptions} Hostname and port information.
* @param path {string} Path/URL to make the request to.
* @param postData {any} Data to be posted on the request.
* @return {Promise<any>} Promise containing the result of the request.
*/

View File

@@ -0,0 +1,3 @@
/**
* @namespace jibo.jetstream
*/

View File

@@ -0,0 +1,162 @@
import { Log as JiboLog } from 'jibo-log';
import * as types from './Types';
import * as request from './Request';
import * as events_ns from './Events';
import { HotwordModeToken } from './HotwordMode';
export * from './Client';
export import Events = events_ns.Events;
export { types, request, HotwordModeToken };
/**
* Global events from the jetstream client.
* @name jibo.jetstream#events
* @type jibo.jetstream.Events
* @intdocs
*/
export declare let events: Events;
/**
* Initializes client. Connects to WS server in Jetstream
* @method jibo.jetstream#init
* @param options {jibo.jetstream.types.HostOptions}
* @param [log] {JiboLog}
* @returns {Promise<void>}
*/
export declare function init(options: types.HostOptions, log?: JiboLog): Promise<void>;
/**
* Closes client. Disconnects to WS server in Jetstream
* @method jibo.jetstream#close
*/
export declare function close(): void;
/**
* Notifies the Proactive Selector of an opportunity for proactive behavior
* @method jibo.jetstream#triggerProactive
* @param {ProactiveRequestData} data See [ProactiveRequestData](https://pegasus-api-docs.jibo.com/index.html#proactiverequestdata)
* @returns {Promise<jibo.jetstream.request.ProactiveRequest>}
*/
export declare function triggerProactive(data: types.ProactiveRequestData): Promise<request.ProactiveRequest>;
/**
* Starts a local listening turn
* @method jibo.jetstream#startLocalTurn
* @param {jibo.jetstream.types.LocalTurnOptions} data Options for the turn.
* @returns {Promise<jibo.jetstream.request.LocalTurnRequest>}
*/
export declare function startLocalTurn(data: types.LocalTurnOptions): Promise<request.LocalTurnRequest>;
/**
* Mimics a global listening turn. This is primarily for launching cloud skills from the robot.
* @method jibo.jetstream#mimicGlobalTurn
* @param {jibo.jetstream.types.MimicGlobalTurnOptions} data Options for the turn.
* @returns {Promise<jibo.jetstream.request.Request>}
*/
export declare function mimicGlobalTurn(data: types.MimicGlobalTurnOptions): Promise<request.Request>;
/**
* Subscribes a global handler to a selected set of NLU rules.
* @method jibo.jetstream#subscribeGlobal
* @param {jibo.jetstream.types.SubscribeGlobalOptions} data Options for the turn.
* @returns {Promise<jibo.jetstream.request.SubscribeGlobalRequest>}
*/
export declare function subscribeGlobal(data: types.SubscribeGlobalOptions): Promise<request.SubscribeGlobalRequest>;
/**
* Unsubscribes all global rules.
* @method jibo.jetstream#unsubscribeAllGlobals
* @returns {Promise<void>}
* @intdocs
*/
export declare function unsubscribeAllGlobals(): Promise<void>;
/**
* @method jibo.jetstream#cancelAnyTurn
* @return {Promise<void>}
*/
export declare function cancelAnyTurn(): Promise<void>;
/**
* Changes how hotword listening is handled, from fully disabled to adding additional API.AI grammars.
* @method jibo.jetstream#setHotwordMode
* @param {jibo.jetstream.types.HotwordListenMode} mode Mode to set to.
* @param {string[]} [rules] Additional grammars
* @returns {jibo.jetstream.HotwordModeToken}
*/
export declare function setHotwordMode(mode: types.HotwordListenMode.Disabled): HotwordModeToken;
export declare function setHotwordMode(mode: types.HotwordListenMode.HJ_Only): HotwordModeToken;
export declare function setHotwordMode(mode: types.HotwordListenMode.ASR_Only): HotwordModeToken;
export declare function setHotwordMode(mode: types.HotwordListenMode.Custom_NLU_Only, rules: string[]): HotwordModeToken;
export declare function setHotwordMode(mode: types.HotwordListenMode.Custom_NLU_Added, rules: string[]): HotwordModeToken;
/**
* Resets the hotword mode, releasing all tokens.
* @method jibo.jetstream#resetHotwordMode
* @return {Promise<void>}
*/
export declare function resetHotwordMode(): Promise<void>;
/**
* Gets a promise for a cloud skill response from a skill launch. Provided so that skill
* launches can be handled in the SSM but cloud responses handled in Be.
* @method jibo.jetstream#getCloudSkillResponse
* @param {string} transID Transaction ID from the session from which to retrieve the skill response.
* @return {Promise<any>}
* @intdocs
*/
export declare function getCloudSkillResponse(transId: string): Promise<any>;
/**
* Clear the authentication model and collected utterances for the given speaker.
* @method jibo.jetstream#removeSpeakerModel
* @param {string} speakerID UUID of the speaker whose model is being cleared
* @returns {Promise<void>}
* @intdocs
*/
export declare function removeSpeakerModel(speakerID: string): Promise<void>;
/**
* Collect enrollment utterances from a speaker, waiting for HJ to be said the given number of
* times.
* @method jibo.jetstream#startEnrollmentTurn
* @param {string} speakerID UUID of the speaker being enrolled
* @param {number} number_of_utterances Number of good utterances to collect and use before reporting complete.
* `1` for existing "single HJ capture" behavior.
* @returns {Promise<jibo.jetstream.request.EnrollmentTurnRequest>}
* @intdocs
*/
export declare function startEnrollmentTurn(speakerID: string, number_of_utterances: number): Promise<request.EnrollmentTurnRequest>;
/**
* This prepares the system for listening to the way a user pronounces a particular word. It builds
* data structures that will be used during the listening step. For normal length names this
* completes in under 50ms, but longer names can take several hundred ms.
* @method jibo.jetstream#initNameLearning
* @param {string} looperName Name to learn
* @returns {Promise<void>}
* @intdocs
*/
export declare function initNameLearning(looperName: string): Promise<void>;
/**
* Collect the pronunciation of a given name.
* @method jibo.jetstream#startNameLearningTurn
* @param {string} looperName Name to learn
* @param {boolean} [ignoreHJ=true] If HJ should be ignored during the turn.
* @param {boolean} [rejectIfBusy=false] If this turn should be rejected if there is already an active turn.
* @returns {Promise<jibo.jetstream.request.NameLearningRequest>}
* @intdocs
*/
export declare function startNameLearningTurn(looperName: string, ignoreHJ?: boolean, rejectIfBusy?: boolean): Promise<request.NameLearningRequest>;
/**
* Create a model from all the speakers utterances collected so far.
* @method jibo.jetstream#createSpeakerModel
* @param {string} speakerID UUID of the speaker whose model is being created
* @param {boolean} [append] Use true if you want the samples to be added to the existing speaker model. Use false if you want to replace the existing speaker model.
* @returns {Promise<jibo.jetstream.types.SpeakerModelResult>}
* @intdocs
*/
export declare function createSpeakerModel(speakerID: string, append?: boolean): Promise<types.SpeakerModelResult>;
/**
* Removes sample Hey Jibo utterances that have not been used to create a speaker model.
* @method jibo.jetstream#removePendingSamples
* @param {string} speakerID UUID of the speaker whose unused samples should be cleared
* @returns {Promise<void>}
* @intdocs
*/
export declare function removePendingSamples(speakerID: string): Promise<void>;
/**
* Gets list of speakers enrolled in the system
* @method jibo.jetstream#getEnrolledSpeakers
* @returns {Promise<string[]>} List of speakers enrolled in the system
* @intdocs
*/
export declare function getEnrolledSpeakers(): Promise<string[]>;
/**
* Needed to make a fresh client in tests.
*/
export declare function _resetInstance(): void;

View File

@@ -0,0 +1,65 @@
import * as types from './Types';
import { Request } from './Request';
import { Events } from './Events';
import { Log as JiboLog } from 'jibo-log';
/**
* The Client to the Jetstream on-robot service
* @class jibo.jetstream.Client
* @intdocs
*/
export declare class Client {
/**
* @name jibo.jetstream.Client#events
* @type jibo.jetstream.Events
*/
events: Events;
/**
* @name jibo.jetstream.Client#options
* @type {jibo.jetstream.types.HostOptions}
*/
options: types.HostOptions;
/**
* @name jibo.jetstream.Client._requests
* @type {Map}
* @description `Map<string, Request>`
*/
_requests: Map<string, Request>;
private cloudSkillResponseRegistry;
private cullInterval;
private eventWS;
private vadWS;
/**
* Initializes client. Connects to WS server in Jetstream
* @returns {Promise<void>}
* @method jibo.jetstream.Client#init
* @param options {jibo.jetstream.types.HostOptions}
* @param [log] {JiboLog}
*/
init(options: types.HostOptions, log?: JiboLog): Promise<void>;
/**
* Closes websocket connection
* @method jibo.jetstream.Client#close
*/
close(): void;
/**
* Gets the requestID from the response (if it exists).
* @method jibo.jetstream.Client#getRequestID
* @param {any} response Response from the Jetstream request.
* @return {string}
*/
getRequestID(response: any): string;
/**
* Gets a promise for a cloud skill response from a skill launch. Provided so that skill
* launches can be handled in the SSM but cloud responses handled in Be.
* @method jibo.jetstream.Client#getCloudSkillResponse
* @param {string} transID
* @return {Promise<any>}
* @intdocs
*/
getCloudSkillResponse(transID: string): Promise<any>;
private handleMessage;
private handleVAD;
private emitError(error);
private emitSkillSwitch(match, asr, nlu, transID);
private cancelAllRequests();
}

View File

@@ -0,0 +1,21 @@
import * as types from './Types';
export declare class CloudResponseRegistry {
private registry;
/**
* Add a cloud response entry
* @param transID
*/
add(transID: string): Promise<any>;
/**
* Resolve a skill response when it arrives
* @param transID
* @param skillResponse
*/
resolve(transID: string, skillResponse: types.SkillActionData): void;
/**
* Cull all old entries and reject outstanding promises
* @param maxAgeMs
*/
cull(maxAgeMs: number): void;
private createEntry(id);
}

View File

@@ -0,0 +1,93 @@
import { EventContainer, Event } from 'jibo-typed-events';
import { TurnResult, SpeakerIDData, SkillSwitchResult, EnrollmentCollectionResult, VADEvent } from './Types';
/**
* Describes the global events on the client
* @namespace jibo.jetstream.events
* @intdocs
*/
export declare class Events extends EventContainer {
/**
* @name jibo.jetstream.events#error
* @type {Event<Error>}
* @description `ERROR`
*/
error: Event<Error>;
/**
* @name jibo.jetstream.events#sos
* @type {Event}
* @description `Start of speech`
*/
sos: Event<void>;
/**
* @name jibo.jetstream.events#eos
* @type {Event}
* @description `End of speech`
*/
eos: Event<void>;
/**
* @name jibo.jetstream.events#hjHeard
* @type {Event}
* @description `HJ Heard`
*/
hjHeard: Event<void>;
/**
* @name jibo.jetstream.events#hjOnly
* @type {Event}
* @description `HJ Only`
*/
hjOnly: Event<void>;
/**
* @name jibo.jetstream.events#speakerID
* @type {Event<jibo.jetstream.types.SpeakerIDData>}
* @description `Speaker ID`
*/
speakerID: Event<SpeakerIDData>;
/**
* @name jibo.jetstream.events#localTurnStarted
* @type {Event}
* @description `Local Turn started`
*/
localTurnStarted: Event<void>;
/**
* @name jibo.jetstream.events#localTurnResult
* @type {Event<jibo.jetstream.types#TurnResult>}
* @description `Local Turn result`
*/
localTurnResult: Event<TurnResult>;
/**
* @name jibo.jetstream.events#globalTurnStarted
* @type {Event}
* @description `Global Turn started`
*/
globalTurnStarted: Event<void>;
/**
* @name jibo.jetstream.events#globalTurnResult
* @type {Event<jibo.jetstream.types#TurnResult>}
* @description `Global Turn result`
*/
globalTurnResult: Event<TurnResult>;
/**
* @name jibo.jetstream.events#skillSwitch
* @type {Event<jibo.jetstream.types.SkillSwitchResult>}
* @description `Skill Switch`
*/
skillSwitch: Event<SkillSwitchResult>;
/**
* @name jibo.jetstream.events#speakerEnrollment
* @type {Event<jibo.jetstream.types.EnrollmentCollectionResult>}
* @description `Speaker Enrollment`
*/
speakerEnrollment: Event<EnrollmentCollectionResult>;
/**
* @name jibo.jetstream.events#vad
* @type {Event<jibo.jetstream.types.VADEvent>}
* @description `VAD Event` - Voice activity detection
*/
vad: Event<VADEvent>;
/**
* @name jibo.jetstream.events#connect
* @type {Event<void>}
* @description `Connect` - When the client connects (or reconnects) to Jetstream
*/
connect: Event<void>;
}

View File

@@ -0,0 +1,33 @@
import { Event } from 'jibo-typed-events';
import { HotwordListenMode as Mode, SuccessTurnResult } from './Types';
/**
* Token representing a call to jibo.jetstream.setHotwordMode().
* @class jibo.jetstream.HotwordModeToken
*/
export declare class HotwordModeToken {
/**
* Promise for when the mode is fully active, if you wanted to wait on it.
* @name jibo.jetstream.HotwordModeToken#activated
* @type {Promise<void>}
*/
activated: Promise<void>;
/**
* `Global match`
* @name jibo.jetstream.HotwordModeToken#match
* @type {Event<jibo.jetstream.types.SuccessTurnResult>}
*/
match: Event<SuccessTurnResult>;
/**
* @hideConstructor
*/
constructor(mode: Mode, rules?: string[]);
/**
* Releases the token, permanently disabling it.
* @method jibo.jetstream.HotwordModeToken#release
* @returns {Promise<void>}
*/
release(): Promise<void>;
private onGlobalResult(result);
}
export declare function generateToken(mode: Mode, rules?: string[]): HotwordModeToken;
export declare function resetMode(): Promise<void>;

View File

@@ -0,0 +1,173 @@
import { Event } from 'jibo-typed-events';
import { Client } from './Client';
import { ServiceEvent, TurnResult, NameTurnResult, EnrollmentTurnResult, ProactiveResponseData, NameSuccessTurnResult, NLUResult } from './Types';
/**
* Enum of request statuses.
* @typedef jibo.jetstream.request#RequestStatus
* @prop ACTIVE Once a request has been sent.
* @prop CANCELED Once a request has been canceled or unsubscribed.
* @prop FINISHED When a request has finished (including due to error).
*/
export declare enum RequestStatus {
ACTIVE = "ACTIVE",
CANCELED = "CANCELED",
FINISHED = "FINISHED",
ERROR = "ERROR",
}
/**
* @description The base type of request that the client makes to the Jetstream
* service. Keeps track of requestID, status, events and errors
* @class jibo.jetstream.request.Request
* @hideconstructor
*/
export declare class Request {
protected client: Client;
/**
* ID of the request.
* @name jibo.jetstream.request.Request#id
* @type {string}
*/
id: string;
/**
* Status of the request.
* @name jibo.jetstream.request.Request#status
* @type {jibo.jetstream.request#RequestStatus}
* @default RequestStatus.ACTIVE
*/
status: RequestStatus;
/**
* Events attached to the request.
* @name jibo.jetstream.request.Request#events
* @type {Event<jibo.jetstream.types#ServiceEvent>}
*/
events: Event<ServiceEvent>;
/**
* Error event attached to the request.
* @name jibo.jetstream.request.Request#error
* @type {Event<Error>}
*/
error: Event<Error>;
protected resolve: Function;
constructor(client: Client, id: string);
}
/**
* The request object returned by client when proactive request made
* @export
* @class jibo.jetstream.request.ProactiveRequest
* @extends {jibo.jetstream.request.Request}
* @hideconstructor
*/
export declare class ProactiveRequest extends Request {
/**
* @description This promise gets resolved when the proactive session is completed.
* See [ProactiveResponseData](https://pegasus-api-docs.jibo.com/interfaces/proactiveresponsedata.html)
* @name jibo.jetstream.request.ProactiveRequest#promise
* @type {Promise<ProactiveResponseData>}
*/
promise: Promise<ProactiveResponseData>;
constructor(client: Client, id: string);
}
/**
* The request object returned by client when listening turn is started
* @export
* @class jibo.jetstream.request.LocalTurnRequest
* @extends {jibo.jetstream.request.Request}
* @hideconstructor
*/
export declare class LocalTurnRequest extends Request {
/**
* Promise that will yield the results of the Local Turn
* @name jibo.jetstream.request.LocalTurnRequest#promise
* @type {Promise<jibo.jetstream.types#TurnResult>}
*/
promise: Promise<TurnResult>;
protected resolve: (data: TurnResult) => void;
constructor(client: Client, id: string);
/**
* Cancels an ongoing request
* @returns {Promise<boolean>} `false` if the request could not be canceled.
* @method jibo.jetstream.request.LocalTurnRequest#cancel
*/
cancel(): Promise<boolean>;
/**
* Update (that is, force the completion of) an in-progress local turn with the given NLU or
* ASR text information. This function is provided to allow a menu button push to simulate NLU
* input to the skill. When invoked, the audio being streamed to the Hub is stopped and the Hub
* accepts the provided ASR or NLU data as input. There is a potential race condition where the
* given ASR/NLU data is sent to the Hub but the Hub receives the ASR or NLU result first,
* which causes the update command to be ignored.
* @param asrOrNlu {string|jibo.jetstream.types.NLUResult} An ASR string or NLU result to update the turn with.
* See [NLUResult](https://pegasus-api-docs.jibo.com/interfaces/nluresult.html)
* @param [meta] {any} Metadata to be sent along for logging purposes.
* @returns {Promise<void>}
* @method jibo.jetstream.request.LocalTurnRequest#update
*/
update(asrOrNlu: string | NLUResult, meta?: any): Promise<void>;
}
/**
* The request object returned by client when global handler is subscribed
* @export
* @class jibo.jetstream.request.SubscribeGlobalRequest
* @extends {jibo.jetstream.request.Request}
* @hideconstructor
*/
export declare class SubscribeGlobalRequest extends Request {
/**
* Unsubscribes a global request
* @returns {Promise<boolean>} `false` if the request could not be unsubscribed.
* @method jibo.jetstream.request.SubscribeGlobalRequest#unsubscribe
*/
unsubscribe(): Promise<boolean>;
}
/**
* The request object returned by client when enrollment turn is started
* @export
* @class jibo.jetstream.request.EnrollmentTurnRequest
* @extends {jibo.jetstream.request.Request}
* @hideconstructor
*/
export declare class EnrollmentTurnRequest extends Request {
/**
* Promise that will yield the results of the Enrollment Turn
* @name jibo.jetstream.request.EnrollmentTurnRequest#promise
* @type {Promise<jibo.jetstream.types#EnrollmentTurnResult>}
*/
promise: Promise<EnrollmentTurnResult>;
/**
* Ennrollment turn has started (ready for first HJ to be said)
* @name jibo.jetstream.request.EnrollmentTurnRequest#ready
* @type {Event<jibo.jetstream.types.EnrollmentCollectionResult>}
*/
ready: Event<void>;
protected resolve: (data: EnrollmentTurnResult) => void;
constructor(client: Client, id: string);
/**
* Cancels an ongoing request
* @returns {Promise<boolean>} `false` if the request could not be canceled.
* @method jibo.jetstream.request.EnrollmentTurnRequest#cancel
*/
cancel(): Promise<boolean>;
}
/**
* The request object returned by client when name learning turn is started
* @export
* @class jibo.jetstream.request.NameLearningRequest
* @extends {jibo.jetstream.request.Request}
* @hideconstructor
*/
export declare class NameLearningRequest extends Request {
/**
* Promise that will yield the results of the Name Learning Turn
* @name jibo.jetstream.request.NameLearningRequest#promise
* @type {Promise<jibo.jetstream.types.NameSuccessTurnResult>}
*/
promise: Promise<NameSuccessTurnResult>;
protected resolve: (data: NameTurnResult) => void;
constructor(client: Client, id: string);
/**
* Cancels an ongoing request
* @returns {Promise<boolean>} `false` if the request could not be canceled.
* @method jibo.jetstream.request.NameLearningRequest#cancel
*/
cancel(): Promise<boolean>;
}

View File

@@ -0,0 +1,513 @@
import * as interfaces from '@jibo/interfaces';
export import NewArrivalRequestData = interfaces.proactive.NewArrivalRequestData;
export import SurpriseRequestData = interfaces.proactive.SurpriseRequestData;
export import ProactiveRequestData = interfaces.proactive.ProactiveRequestData;
export import ProactiveResponseData = interfaces.proactive.ProactiveResponseData;
export import ProactiveTriggerSource = interfaces.proactive.TriggerSource;
export import ListenMessageData = interfaces.hub.request.ListenMessageData;
export import ListenMessageMode = interfaces.hub.request.ListenMessageMode;
export import ASRResult = interfaces.asr.ASRResult;
export import NLUResult = interfaces.nlu.NLUResult;
export import GlobalMatchResponseData = interfaces.common.GlobalMatchResponseData;
export import SkillActionData = interfaces.skill.response.SkillActionData;
export import SkillRedirectData = interfaces.hub.response.SkillRedirectData;
export import ListenResultState = interfaces.hub.response.ListenResultState;
import BaseListenResult = interfaces.hub.response.ListenResult;
export declare const GLOBAL_REQUEST = "GLOBAL";
/**
* TurnResult type
* ```
* BaseTurnResult<TurnResultType.INTERRUPTED> |
* BaseTurnResult<TurnResultType.CANCELED> |
* BaseTurnResult<TurnResultType.TIMEOUT> |
* FailedTurnResult |
* SuccessTurnResult
* ```
* @typedef jibo.jetstream.types#TurnResult
*/
export declare type TurnResult = BaseTurnResult<TurnResultType.INTERRUPTED> | BaseTurnResult<TurnResultType.CANCELED> | BaseTurnResult<TurnResultType.TIMEOUT> | FailedTurnResult | SuccessTurnResult;
/**
* NameTurnResult type
* ```
* BaseTurnResult<TurnResultType.INTERRUPTED> |
* BaseTurnResult<TurnResultType.CANCELED> |
* BaseTurnResult<TurnResultType.TIMEOUT> |
* FailedTurnResult |
* NameSuccessTurnResult
* ```
* @typedef jibo.jetstream.types#NameTurnResult
*/
export declare type NameTurnResult = BaseTurnResult<TurnResultType.INTERRUPTED> | BaseTurnResult<TurnResultType.CANCELED> | BaseTurnResult<TurnResultType.TIMEOUT> | FailedTurnResult | NameSuccessTurnResult;
/**
* EnrollnentTurnResult type
* ```
* BaseTurnResult<TurnResultType.INTERRUPTED> |
* BaseTurnResult<TurnResultType.CANCELED> |
* BaseTurnResult<TurnResultType.TIMEOUT> |
* FailedTurnResult |
* EnrollmentSuccessTurnResult
* ```
* @typedef jibo.jetstream.types#EnrollmentTurnResult
*/
export declare type EnrollmentTurnResult = BaseTurnResult<TurnResultType.INTERRUPTED> | BaseTurnResult<TurnResultType.CANCELED> | BaseTurnResult<TurnResultType.TIMEOUT> | FailedTurnResult | EnrollmentSuccessTurnResult;
/**
* ServiceEvent type. </br>
* ```
* BaseServiceEvent<ServiceEventType.EOS, void> |
* BaseServiceEvent<ServiceEventType.SOS, void> |
* BaseServiceEvent<ServiceEventType.ERROR, ErrorData> |
* BaseServiceEvent<ServiceEventType.SPEAKER_ID, SpeakerIDData> |
* BaseServiceEvent<ServiceEventType.HJ_HEARD, void> |
* BaseServiceEvent<ServiceEventType.HJ_ONLY, void> |
* BaseServiceEvent<ServiceEventType.TURN_STARTED, void> |
* BaseServiceEvent<ServiceEventType.TURN_RESULT, TurnResult> |
* BaseServiceEvent<ServiceEventType.TURN_RESULT, NameTurnResult> |
* BaseServiceEvent<ServiceEventType.TURN_RESULT, EnrollmentTurnResult> |
* BaseServiceEvent<ServiceEventType.SKILL_ACTION, SkillResponseData> |
* BaseServiceEvent<ServiceEventType.PROACTIVE, ProactiveResponseData> |
* BaseServiceEvent<ServiceEventType.SPEAKER_ENROLLMENT, EnrollmentCollectionResult>
* ```
* @typedef jibo.jetstream.types#ServiceEvent
*/
export declare type ServiceEvent = BaseServiceEvent<ServiceEventType.EOS, void> | BaseServiceEvent<ServiceEventType.SOS, void> | BaseServiceEvent<ServiceEventType.ERROR, ErrorData> | BaseServiceEvent<ServiceEventType.SPEAKER_ID, SpeakerIDData> | BaseServiceEvent<ServiceEventType.HJ_HEARD, void> | BaseServiceEvent<ServiceEventType.HJ_ONLY, void> | BaseServiceEvent<ServiceEventType.TURN_STARTED, void> | BaseServiceEvent<ServiceEventType.TURN_RESULT, TurnResult> | BaseServiceEvent<ServiceEventType.TURN_RESULT, NameTurnResult> | BaseServiceEvent<ServiceEventType.TURN_RESULT, EnrollmentTurnResult> | BaseServiceEvent<ServiceEventType.SKILL_ACTION, SkillActionData> | BaseServiceEvent<ServiceEventType.SKILL_REDIRECT, SkillRedirectData> | BaseServiceEvent<ServiceEventType.PROACTIVE, ProactiveResponseData> | BaseServiceEvent<ServiceEventType.SPEAKER_ENROLLMENT, EnrollmentCollectionResult>;
/**
* Enum of hotword listen modes.
* @typedef jibo.jetstream.types.HotwordListenMode
* @prop Disabled `0` HJ listening is disabled entirely, including cloud listening in response.
* @prop HJ_Only HJ listening is enabled, but no cloud listening will take place in response to HJ.
* @prop ASR_Only When cloud listening in response to HJ, no `NLU/API.AI` parsing is done, just the
* ASR is returned.
* @prop Custom_NLU_Only When cloud listening in response to HJ, ONLY rules added at `Custom_NLU_Only`
* levels are used for `API.AI` parsing.
* @prop Custom_NLU_Added When cloud listening in response to HJ, rules added at `Custom_NLU_Added `
* levels are used for `API.AI` parsing on top of the normal globals.
* @prop Normal Default mode, HJ listening is enabled as well as cloud listening with global
* rules in response.
*/
export declare enum HotwordListenMode {
Disabled = 0,
HJ_Only = 1,
ASR_Only = 2,
Custom_NLU_Only = 3,
Custom_NLU_Added = 4,
Normal = 5,
}
/**
* @typedef jibo.jetstream.types.TurnResultType
* @prop SUCCEEDED
* @prop INTERRUPTED
* @prop CANCELED
* @prop FAILED
* @prop TIMEOUT
*/
export declare enum TurnResultType {
SUCCEEDED = "SUCCEEDED",
INTERRUPTED = "INTERRUPTED",
CANCELED = "CANCELED",
FAILED = "FAILED",
TIMEOUT = "TIMEDOUT",
}
/**
* Enum of service event types
* @typedef jibo.jetstream.types.ServiceEventType
* @prop EOS End of speech
* @prop SOS Start of speech
* @prop ERROR Error
* @prop SPEAKER_ID Speaker ID
* @prop HJ_Heard Heard "hey jibo"
* @prop HJ_Only Heard "Hey Jibo" and nothing else
* @prop SKILL_ACTION Cloud skill action
* @prop SKILL_REDIRECT Cloud skill redirect
* @prop TURN_STARTED Turn started
* @prop TURN_RESULT Turn result
* @prop PROACTIVE Proactive
*/
export declare enum ServiceEventType {
EOS = "EOS",
SOS = "SOS",
ERROR = "ERROR",
SPEAKER_ID = "SPEAKER_ID",
HJ_HEARD = "HJ_HEARD",
HJ_ONLY = "HJ_ONLY",
SKILL_ACTION = "SKILL_ACTION",
SKILL_REDIRECT = "SKILL_REDIRECT",
TURN_STARTED = "TURN_STARTED",
TURN_RESULT = "TURN_RESULT",
PROACTIVE = "PROACTIVE",
SPEAKER_ENROLLMENT = "SPEAKER_ENROLLMENT",
}
/**
* Information on how to contact Hub.
* @interface jibo.jetstream.types.HostOptions
* @prop hostname {string} Host name of Hub service (ex. `localhost`)
* @prop port {number} Hub port number.
*/
export interface HostOptions {
hostname: string;
port: number;
}
/**
* Base interface for the different Service event types.
* @interface jibo.jetstream.types.BaseServiceEvent
* @prop type {jibo.jetstream.types.ServiceEventType} ServiceEventType enum.
* @prop requestID {string} Either `GLOBAL` or a specific turn requestID.
* @prop transID {string} The transaction ID associated with this hub transaction
* @prop ts {number} Timestamp at sending time.
* @prop data {any} Payload, depending on `type`.
*/
export interface BaseServiceEvent<T extends ServiceEventType, D> {
type: T;
requestID: string;
transID: string;
ts: number;
data: D;
}
/**
* Interface for skill switching results.
* @interface jibo.jetstream.types.SkillSwitchResult
* @prop skillID {string} Unique ID of the skill
* @prop [onRobot] {boolean} `true` if skill is on robot, `false` for cloud skill.
* @prop [isProactive] {boolean} `true` if skill is proactively launched
* @prop [skipSurprises] {boolean} `true` if after this skill exits surprises should be skipped
* @prop [transID] {string} The transaction ID associated with this hub transaction
* @prop data {jibo.jetstream.types.ListenResult} Results from a turn of dialog
* @intdocs
*/
export interface SkillSwitchResult {
skillID: string;
onRobot?: boolean;
isProactive?: boolean;
skipSurprises?: boolean;
transID?: string;
data: ListenResult;
}
/**
* @interface jibo.jetstream.types.MimicGlobalTurnOptions
* @prop [clientASR] {string} The ASR text result desired from this turn. If present, no audio will be sent to the hub.
* @prop [clientNLU] {jibo.jetstream.types.NLUResult} The semantic result desired from this turn. If present, no audio will be sent to the hub.
* @prop [language] {string} ISO language label, e.g. "en-US"
* @prop [suppressedEvents] {jibo.jetstream.types.ServiceEventType[]} List of event names to suppress during this turn. It is suggested that this not be used by skills.
*/
export interface MimicGlobalTurnOptions {
clientASR?: string;
clientNLU?: interfaces.nlu.NLUResult;
language?: string;
suppressedEvents?: ServiceEventType[];
}
/**
* Interface for local turn options.
* @interface jibo.jetstream.types.LocalTurnOptions
* @prop nluRules {string[]} A list of API.AI contexts.
* @prop [ignoreHJ] {boolean} If HJ can interrupt cloud listen.
* @prop [rejectIfBusy] {boolean} Reject this request if Jetstream is busy. Default false.
* @prop [meta] {any} An arbitrary JSON object for caller data, passed back in result.
* @prop [earlyEOS] {string[]} A list of phrases that cause EOS to be detected.
* @prop [hintPhrases] {string[]} A list of phrases that ASR will be biased towards detecting.
* @prop [clientASR] {string} The ASR text result desired from this turn. If present, no audio will be sent to the hub.
* @prop [clientNLU] {jibo.jetstream.types.NLUResult} The semantic result desired from this turn.
* If present, no audio will be sent to the hub. </br> See [NLUResult](https://pegasus-api-docs.jibo.com/interfaces/nluresult.html)
* @prop [log] {any} Arbitrary JSON object to be attached to logs related to this turn
* @prop [language] {string} ISO language label, e.g. "en-US"
* @prop [ignoreGlobalRules=false] {boolean} If active global rules should not be allowed during this turn.
* @prop [suppressedEvents] {jibo.jetstream.types.ServiceEventType[]} List of event names to suppress during this turn. It is suggested that this not be used by skills.
* @prop [sosTimeout] {number} The period of time to wait (in seconds) for the Start Of Speech after starting to listen. If speech is not heard within this period, the turn completes with a status of TIMEOUT and message of "sos". If this property is set to -1 (or not provided) the value used is the one found in the jibo-jetstream-service.json file.
* @prop [maxSpeechTimeout] {number} The maximum number of seconds that a user may speak. If the user speaks for more than this number of seconds, the turn completes with a status of TIMEOUT and message of "maxSpeech". As with sosTimeout, a value of -1 causes the config file property to be used.
*/
export interface LocalTurnOptions {
nluRules: string[];
ignoreHJ?: boolean;
rejectIfBusy?: boolean;
meta?: any;
earlyEOS?: string[];
hintPhrases?: string[];
clientASR?: string;
clientNLU?: interfaces.nlu.NLUResult;
log?: any;
language?: string;
ignoreGlobalRules?: boolean;
suppressedEvents?: ServiceEventType[];
sosTimeout?: number;
maxSpeechTimeout?: number;
}
/**
* Interface for local turn updates.
* @interface jibo.jetstream.types.LocalTurnUpdate
* @prop requestID {string} The requestID of the in-progress turn to be updated.
* If the turn for the given requestID is no longer active, this call is ignored.
* @prop [meta] {any} An arbitrary JSON object for caller data, passed back in result.
* @prop [clientASR] {string} The ASR text result desired from this turn.
* This is a simple string of words, equivalent to what the ASR returns.
* Only one of the clientASR and clientNLU properties should be provided,
* if both are provided only the clientNLU property will be used.
* @prop [clientNLU] {jibo.jetstream.types.NLUResult} The semantic result desired from this turn.
* This will be the same JSON schema that arrives as the `data.result.nlu`
* field in a successful TURN_RESULT message.
* </br> See [NLUResult](https://pegasus-api-docs.jibo.com/interfaces/nluresult.html)
*/
export interface LocalTurnUpdate {
requestID: string;
meta?: any;
clientASR?: string;
clientNLU?: interfaces.nlu.NLUResult;
}
/**
* Interface for speaker recognition results.
* @interface jibo.jetstream.types.SpeakerRecogResult
* @prop speaker {string} The ID string used to enroll this speaker.
* @prop score {number} authentication score (not useful without knowing the threshold)
* @prop accepted {boolean} If true, this speaker's score was high enough to be considered "recognized"
* @prop high_confidence {boolean} If true, this speaker's score was either high enough that the system
* is confident in accepting it, or low enough that it is confident in rejecting it.
*/
export interface SpeakerRecogResult {
speaker: string;
score: number;
accepted: boolean;
high_confidence: boolean;
}
/**
* Speaker ID is emitted only if there are enrolled speakers.
* @interface jibo.jetstream.types.SpeakerIDData
* @prop speakers {jibo.jetstream.types.SpeakerRecogResult[]} An array of SpeakerRecogResult
* objects (sorted in descending score order) with one entry for each enrolled speaker
* that states how well that speaker was recognized.
* @prop snr {number} The estimated signal-to-noise ratio of the HJ input used in the
* speaker recognition operation.
*/
export interface SpeakerIDData {
speakers: SpeakerRecogResult[];
snr: number;
}
/**
* Interface to Hub for an individual speaker recognition result.
* @interface jibo.jetstream.types.HubSpeakerRecogResult
* @prop {string} id - The ID string used to enroll this speaker.
* @prop {number} score - Authentication score (not useful without knowing the threshold)
* @prop {boolean} high_confidence - If `true`, this speaker's score was either high enough that the system
* is confident in accepting it, or low enough that it is confident in rejecting it.
*/
export interface HubSpeakerRecogResult {
id: string;
score: number;
high_confidence: boolean;
}
/**
* Interface to Hub for speaker recognition results, filtered and sorted by confidence.
* @interface jibo.jetstream.types.HubSpeakerRecogResults
* @prop {jibo.jetstream.types.HubSpeakerRecogResult[]} accepted - List of speakers ID'd that are
* above a certain confidence threshold.
*/
export interface HubSpeakerRecogResults {
accepted: HubSpeakerRecogResult[];
}
/**
* Base interface for turn results
* @interface jibo.jetstream.types.BaseTurnResult
*/
export interface BaseTurnResult<T extends TurnResultType> {
/**
* Status of turn result
* @name jibo.jetstream.types.BaseTurnResult#status
* @type {jibo.jetstream.types.TurnResultType}
*/
status: T;
global: boolean;
}
/**
* Where {@link jibo.jetstream.types.TurnResultType} = `FAILED`
* @interface jibo.jetstream.types.FailedTurnResult
* @extends jibo.jetstream.types.BaseTurnResult
* @prop message {string} Message providing information on error/failure.
*/
export interface FailedTurnResult extends BaseTurnResult<TurnResultType.FAILED> {
message: string;
}
/**
* @description Where {@link jibo.jetstream.types.TurnResultType} = `SUCCEEDED` from a local or global turn.
* @interface jibo.jetstream.types.SuccessTurnResult
* @extends jibo.jetstream.types.BaseTurnResult
* @prop result.asr {ASRResult} [ASRResult](https://pegasus-api-docs.jibo.com/interfaces/asrresult.html)
* @prop result.nlu {NLUResult} [NLUResult](https://pegasus-api-docs.jibo.com/interfaces/nluresult.html)
* @prop [result.match] {GlobalMatchResponseData} [GlobalMatchResponseData](https://pegasus-api-docs.jibo.com/interfaces/globalmatchresponsedata.html)
*/
export interface SuccessTurnResult extends BaseTurnResult<TurnResultType.SUCCEEDED> {
result: ListenResult;
}
/**
* @description Where {@link jibo.jetstream.types.TurnResultType} = `SUCCEEDED` from a name learning turn.
* @interface jibo.jetstream.types.NameSuccessTurnResult
* @extends jibo.jetstream.types.BaseTurnResult
* @prop message {string} The learned pronunciation
*/
export interface NameSuccessTurnResult extends BaseTurnResult<TurnResultType.SUCCEEDED> {
message: string;
}
/**
* @description Where {@link jibo.jetstream.types.TurnResultType} = `SUCCEEDED` from a voice enrollment turn.
* @interface jibo.jetstream.types.EnrollmentSuccessTurnResult
* @extends jibo.jetstream.types.BaseTurnResult
*/
export interface EnrollmentSuccessTurnResult extends BaseTurnResult<TurnResultType.SUCCEEDED> {
}
/**
* Interface for options around enabling/disabling 'Hey Jibo' listening.
* @interface jibo.jetstream.types.SetHJEnabledOptions
* @prop enabled {boolean} `true` if 'Hey Jibo' listening should be enabled.
*/
export interface SetHJEnabledOptions {
enabled: boolean;
}
/**
* @description Provides the SkillID of the CloudSkill that matched the NLU in addition.
* </br> Extends [GlobalMatchResponseData](https://pegasus-api-docs.jibo.com/interfaces/globalmatchresponsedata.html)
* @interface jibo.jetstream.types.GlobalAndCloudMatchResponseData
* @extends GlobalMatchResponseData
* @prop [cloudSkill] {string} - SkillID of Cloud Skill
*/
export interface GlobalAndCloudMatchResponseData extends GlobalMatchResponseData {
cloudSkill?: string;
}
/**
* Generic interface for error/failure data.
* @interface jibo.jetstream.types.ErrorData
* @prop message {string} Message providing information on error/failure.
* @intdocs
*/
export interface ErrorData {
message: string;
}
/**
* Interface for subscribing to global options.
* @interface jibo.jetstream.types.SubscribeGlobalOptions
* @prop nluRules {string[]} One or more NLU rules to subscribe to.
* @prop [meta] {any} An arbitrary JSON object for caller data, passed back in result.
* @prop [language] {string} The language of transcription: `'en-US'` , `'ja-JP'`, or `'zh-CN'`.
* @prop [exclusive] {boolean} If `true`, only global subscriptions marked as exclusive will be used. Others will be temporarily disabled.
*/
export interface SubscribeGlobalOptions {
nluRules: string[];
meta?: any;
language?: string;
exclusive?: boolean;
}
/**
* Interface for the speaker model results
* @interface jibo.jetstream.types.SpeakerModelResult
* @prop [message] {string} In case of `FAILED`, the reason.
*/
export interface SpeakerModelResult {
message?: string;
}
/**
* Interface for enrollment collection results
* @interface jibo.jetstream.types.EnrollmentCollectionResult
* @prop good_utterance_count {number} The number of utterances accepted so far during this turn.
* @prop total_utterance_count {number} The total number of utterances seen so far during this turn.
* @prop accepted {boolean} Whether the last enrollment was usable for training
* @prop problems {string[]} If `data.accepted` is `false`, this is a string vector containing
* the problem(s) with the utterance. The possible values are:
* - `CLIPPING`
* - `POOR_SNR`
* - `NOT_SPEECH_LIKE`
* - `NOT_CONSISTENT`
* - `BAD_DURATION`
* @prop final {boolean} `true` if the number of acceptable utterances matches the `numberOfUtterances`
* parameter specified when the enrollment turn was started. After this the turn will complete
* and no further Speaker Enrollment messages will appear.
* @prop speaker {string} The ID of the speaker being enrolled.
* @prop snr {number} The estimated SNR of the HJ utterance.
*/
export interface EnrollmentCollectionResult {
good_utterance_count: number;
total_utterance_count: number;
accepted: boolean;
problems: string[];
final: boolean;
speaker: string;
snr: number;
}
/**
* Interface describing a Voice Activity Detection (VAD) event.
* @interface jibo.jetstream.types.VADEvent
* @prop name {string} Name of the event. Unlikely to be useful, but present in case of additional events in the future.
* @prop timestamp {number} Timestamp of the event.
* @prop audio_time {number} Timestamp of the audio. Will be slightly off from `timestamp`.
* @prop avg_frame_db {number} Average db of this audio frame.
* @prop VADEvents {jibo.jetstream.types.VADFrame[]} List of VAD frames from the audio data. Due to VAD frames having different durations than audio frames, this will be 2 or 3 frames long.
*/
export interface VADEvent {
name: 'VAD_EVENT_DATA';
timestamp: number;
audio_time: number;
avg_frame_db: number;
VADevents: VADFrame[];
}
/**
* Interface describing the data in a Voice Activity Detection (VAD) frame.
* @interface jibo.jetstream.types.VADFrame
* @prop time {number} Timestamp of the frame.
* @prop vad {number} Rating from -1 to 1 of how like human speech this frame is, with 1 being speech-like.
*/
export interface VADFrame {
time: number;
vad: number;
}
/**
* @class ListenResult
* @memberof jibo.jetstream.types
* @description Results of a turn, with helper getters.
*/
export declare class ListenResult extends BaseListenResult {
/**
* Promise for getting the cloud skill response.
* Type is from [SkillResponseData](https://pegasus-api-docs.jibo.com/index.html#skillresponsedata)
* @name jibo.jetstream.types.ListenResult#cloudSkillResponse
* @type {Promise<SkillResponseData>}
* @readOnly
* @intdocs
*/
cloudSkillResponse?: Promise<SkillActionData>;
/**
* Transaction id for the global turn - for getting the cloud skill response.
* @name jibo.jetstream.types.ListenResult#transID
* @type {string}
* @readOnly
* @intdocs
*/
transID?: string;
/**
* Information about a skill launch match from Jetstream
* @name jibo.jetstream.types.ListenResult#match
* @type {jibo.jetstream.types.GlobalAndCloudMatchResponseData}
* @readOnly
* @intdocs
*/
match?: GlobalAndCloudMatchResponseData;
text: string;
intent: string;
/**
* Creates a ListenResult object from a JSON version of one.
* @method jibo.jetstream.types.ListenResult#fromJSON
* @param {any} json The JSON object to turn into a ListenResult.
* @return {jibo.jetstream.types.ListenResult} The new ListenResult object
* @intdocs
*/
static fromJSON(json: any): ListenResult;
/**
* Creates a JSON representation of this object. This method will
* automatically be called by `JSON.stringify()`.
* @intdocs
* @method jibo.jetstream.types.ListenResult#toJSON
* @return {any} JSON representation
* @intdocs
*/
toJSON(): any;
/**
* Creates a stripped down copy of this object with no specific user data in it, so that it
* can be safely logged.
* @method jibo.jetstream.types.ListenResult#toLog
* @return {any} A clean version of the parse result data.
* @intdocs
*/
toLog(): any;
}

View File

@@ -0,0 +1,17 @@
import { HostOptions } from './Types';
/**
* Class containing Jetstream Client Utilities.
* @class jibo.jetstream.Utils
* @intdocs
*/
export declare class Utils {
/**
* @description Helper method to send post requests to a provided location.
* @method jibo.jetstream.Utils#sendPostRequest
* @param hostOptions {jibo.jetstream.types.HostOptions} Hostname and port information.
* @param path {string} Path/URL to make the request to.
* @param postData {any} Data to be posted on the request.
* @return {Promise<any>} Promise containing the result of the request.
*/
static sendPostRequest(hostOptions: HostOptions, path: string, postData: any, retries?: number): Promise<any>;
}

View File

@@ -0,0 +1,8 @@
import * as types from './Types';
import * as request from './Request';
import * as api from './Api';
export * from './Utils';
export * from './Client';
export * from './Events';
export { HotwordModeToken } from './HotwordMode';
export { types, request, api };

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long