botium-core 1.14.3 → 1.14.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/botium-cjs.js +87 -63
- package/dist/botium-cjs.js.map +1 -1
- package/dist/botium-es.js +105 -81
- package/dist/botium-es.js.map +1 -1
- package/package.json +1 -1
- package/src/scripting/CompilerMarkdown.js +2 -1
- package/src/scripting/CompilerTxt.js +1 -4
- package/src/scripting/MatchFunctions.js +30 -8
- package/src/scripting/ScriptingProvider.js +12 -10
- package/src/scripting/helper.js +3 -2
- package/test/compiler/compilermarkdown.spec.js +3 -3
- package/test/compiler/compilertxt.spec.js +1 -1
- package/test/compiler/convos/txt/convos_emptyrow_just_emptyrow.convo.txt +1 -1
- package/test/scripting/asserters/convoStepParameters.spec.js +11 -0
- package/test/scripting/asserters/convos/convo_step_parameter_matchmode_failed_wer.convo.txt +9 -0
- package/test/scripting/logichooks/convos/scripting_memory_overwrite_and_check.convo.txt +2 -2
package/dist/botium-cjs.js
CHANGED
|
@@ -14,7 +14,7 @@ var randomatic = require('randomatic');
|
|
|
14
14
|
var lodash = require('lodash');
|
|
15
15
|
var boolean$1 = require('boolean');
|
|
16
16
|
var events = require('events');
|
|
17
|
-
var debug$
|
|
17
|
+
var debug$o = require('debug');
|
|
18
18
|
var isClass = require('is-class');
|
|
19
19
|
var crypto = require('crypto');
|
|
20
20
|
var globby = require('globby');
|
|
@@ -52,7 +52,7 @@ var randomatic__default = /*#__PURE__*/_interopDefaultLegacy(randomatic);
|
|
|
52
52
|
var lodash__default = /*#__PURE__*/_interopDefaultLegacy(lodash);
|
|
53
53
|
var boolean__default = /*#__PURE__*/_interopDefaultLegacy(boolean$1);
|
|
54
54
|
var events__default = /*#__PURE__*/_interopDefaultLegacy(events);
|
|
55
|
-
var debug__default = /*#__PURE__*/_interopDefaultLegacy(debug$
|
|
55
|
+
var debug__default = /*#__PURE__*/_interopDefaultLegacy(debug$o);
|
|
56
56
|
var isClass__default = /*#__PURE__*/_interopDefaultLegacy(isClass);
|
|
57
57
|
var crypto__default = /*#__PURE__*/_interopDefaultLegacy(crypto);
|
|
58
58
|
var globby__default = /*#__PURE__*/_interopDefaultLegacy(globby);
|
|
@@ -77,7 +77,7 @@ var express__default = /*#__PURE__*/_interopDefaultLegacy(express);
|
|
|
77
77
|
var bodyParser__default = /*#__PURE__*/_interopDefaultLegacy(bodyParser);
|
|
78
78
|
|
|
79
79
|
var name = "botium-core";
|
|
80
|
-
var version$1 = "1.14.
|
|
80
|
+
var version$1 = "1.14.4";
|
|
81
81
|
var description = "The Selenium for Chatbots";
|
|
82
82
|
var main = "index.js";
|
|
83
83
|
var module$1 = "dist/botium-es.js";
|
|
@@ -1104,7 +1104,7 @@ LogicHookConsts.DEFAULT_LOGIC_HOOKS;
|
|
|
1104
1104
|
LogicHookConsts.DEFAULT_USER_INPUTS;
|
|
1105
1105
|
LogicHookConsts.LOGIC_HOOK_EVENTS;
|
|
1106
1106
|
|
|
1107
|
-
const debug$
|
|
1107
|
+
const debug$n = debug__default["default"]('botium-core-asserterUtils');
|
|
1108
1108
|
const {
|
|
1109
1109
|
DEFAULT_ASSERTERS,
|
|
1110
1110
|
DEFAULT_LOGIC_HOOKS,
|
|
@@ -1156,7 +1156,7 @@ var LogicHookUtils_1 = class LogicHookUtils {
|
|
|
1156
1156
|
_fetchAsserters() {
|
|
1157
1157
|
this.caps[Capabilities.ASSERTERS].forEach(asserter => {
|
|
1158
1158
|
if (this.asserters[asserter.ref]) {
|
|
1159
|
-
debug$
|
|
1159
|
+
debug$n(`${asserter.ref} asserter already exists, overwriting.`);
|
|
1160
1160
|
}
|
|
1161
1161
|
this.asserters[asserter.ref] = this._loadClass(asserter, 'asserter');
|
|
1162
1162
|
if (asserter.global) {
|
|
@@ -1167,7 +1167,7 @@ var LogicHookUtils_1 = class LogicHookUtils {
|
|
|
1167
1167
|
_fetchLogicHooks() {
|
|
1168
1168
|
this.caps[Capabilities.LOGIC_HOOKS].forEach(logicHook => {
|
|
1169
1169
|
if (this.logicHooks[logicHook.ref]) {
|
|
1170
|
-
debug$
|
|
1170
|
+
debug$n(`${logicHook.ref} logic hook already exists, overwriting.`);
|
|
1171
1171
|
}
|
|
1172
1172
|
this.logicHooks[logicHook.ref] = this._loadClass(logicHook, 'logichook');
|
|
1173
1173
|
if (logicHook.global) {
|
|
@@ -1178,7 +1178,7 @@ var LogicHookUtils_1 = class LogicHookUtils {
|
|
|
1178
1178
|
_fetchUserInputs() {
|
|
1179
1179
|
this.caps[Capabilities.USER_INPUTS].forEach(userInput => {
|
|
1180
1180
|
if (this.userInputs[userInput.ref]) {
|
|
1181
|
-
debug$
|
|
1181
|
+
debug$n(`${userInput.ref} userinput already exists, overwriting.`);
|
|
1182
1182
|
}
|
|
1183
1183
|
this.userInputs[userInput.ref] = this._loadClass(userInput, 'userinput');
|
|
1184
1184
|
});
|
|
@@ -1364,7 +1364,7 @@ var LogicHookUtils_1 = class LogicHookUtils {
|
|
|
1364
1364
|
}
|
|
1365
1365
|
}
|
|
1366
1366
|
}
|
|
1367
|
-
loadErr.forEach(debug$
|
|
1367
|
+
loadErr.forEach(debug$n);
|
|
1368
1368
|
}
|
|
1369
1369
|
throw new Error(`${typeAsText} specification ${ref} ${hookType} from "${util__default["default"].inspect(src)}" invalid : no loader available`);
|
|
1370
1370
|
}
|
|
@@ -1575,10 +1575,11 @@ var Enums = {
|
|
|
1575
1575
|
};
|
|
1576
1576
|
Enums.E_SCRIPTING_MEMORY_COLUMN_MODE;
|
|
1577
1577
|
|
|
1578
|
-
const debug$
|
|
1578
|
+
const debug$m = debug__default["default"]('botium-core-scripting-helper');
|
|
1579
1579
|
const {
|
|
1580
1580
|
E_SCRIPTING_MEMORY_COLUMN_MODE: E_SCRIPTING_MEMORY_COLUMN_MODE$1
|
|
1581
1581
|
} = Enums;
|
|
1582
|
+
const WHITE_SPACES_EXCEPT_SPACE_CHAR_AT_THE_END = /[\n\t\r]+$/;
|
|
1582
1583
|
const normalizeText$1 = (str, doCleanup) => {
|
|
1583
1584
|
if (str && lodash__default["default"].isArray(str)) {
|
|
1584
1585
|
str = str.join(' ');
|
|
@@ -1820,7 +1821,7 @@ const linesToConvoStep$5 = (lines, sender, context, eol, singleLineMode = false)
|
|
|
1820
1821
|
if (eol === null) {
|
|
1821
1822
|
throw new Error('eol cant be null');
|
|
1822
1823
|
}
|
|
1823
|
-
convoStep.messageText = textLines.join(eol).
|
|
1824
|
+
convoStep.messageText = textLines.join(eol).replace(WHITE_SPACES_EXCEPT_SPACE_CHAR_AT_THE_END, '');
|
|
1824
1825
|
}
|
|
1825
1826
|
}
|
|
1826
1827
|
} else {
|
|
@@ -2037,7 +2038,7 @@ const convoStepToLines$2 = step => {
|
|
|
2037
2038
|
lines.push(logicHook.name + _formatAppendArgs(logicHook.args));
|
|
2038
2039
|
});
|
|
2039
2040
|
}
|
|
2040
|
-
return lines
|
|
2041
|
+
return lines;
|
|
2041
2042
|
};
|
|
2042
2043
|
const linesToScriptingMemories$2 = (lines, columnMode = null) => {
|
|
2043
2044
|
const guessScriptingMemoryColumnMode = lines => {
|
|
@@ -2151,7 +2152,7 @@ const calculateWer$2 = (str, pattern) => {
|
|
|
2151
2152
|
errCount += err.filter(err => err === true).length;
|
|
2152
2153
|
allCount += err.length;
|
|
2153
2154
|
}
|
|
2154
|
-
debug$
|
|
2155
|
+
debug$m(`Word Error Rate Asserter - Compared Bot Message '${botMessage}' / '${utt}': ${(errCount / allCount).toFixed(2)}`);
|
|
2155
2156
|
return (errCount / allCount).toFixed(2);
|
|
2156
2157
|
};
|
|
2157
2158
|
const toPercent$1 = s => `${(s * 100).toFixed(0)}%`;
|
|
@@ -2349,7 +2350,7 @@ var BotiumError_1 = {
|
|
|
2349
2350
|
botiumErrorFromList: botiumErrorFromList$2
|
|
2350
2351
|
};
|
|
2351
2352
|
|
|
2352
|
-
const debug$
|
|
2353
|
+
const debug$l = debug__default["default"]('botium-core-ScriptingMemory');
|
|
2353
2354
|
const {
|
|
2354
2355
|
v1: uuidv1
|
|
2355
2356
|
} = uuid__default["default"];
|
|
@@ -2609,7 +2610,7 @@ const extractVarNames = text => {
|
|
|
2609
2610
|
return (lodash__default["default"].isString(text) ? text.match(/\$[A-Za-z]\w+/g) : false) || [];
|
|
2610
2611
|
};
|
|
2611
2612
|
const fill = (container, scriptingMemory, result, utterance, scriptingEvents) => {
|
|
2612
|
-
debug$
|
|
2613
|
+
debug$l(`fill start: ${util__default["default"].inspect(scriptingMemory)}`);
|
|
2613
2614
|
let varRegex;
|
|
2614
2615
|
switch (container.caps[Capabilities.SCRIPTING_MEMORY_MATCHING_MODE]) {
|
|
2615
2616
|
case 'word':
|
|
@@ -2643,14 +2644,14 @@ const fill = (container, scriptingMemory, result, utterance, scriptingEvents) =>
|
|
|
2643
2644
|
if (i <= varMatches.length) {
|
|
2644
2645
|
const varName = varMatches[i - 1];
|
|
2645
2646
|
if (RESERVED_WORDS.indexOf(varName) >= 0) {
|
|
2646
|
-
debug$
|
|
2647
|
+
debug$l(`fill Variable "${varName}" is not overwritten, because it is reserved word. `);
|
|
2647
2648
|
} else {
|
|
2648
2649
|
scriptingMemory[varName] = resultMatches[i];
|
|
2649
2650
|
}
|
|
2650
2651
|
}
|
|
2651
2652
|
}
|
|
2652
2653
|
});
|
|
2653
|
-
debug$
|
|
2654
|
+
debug$l(`fill end: ${util__default["default"].inspect(scriptingMemory)}`);
|
|
2654
2655
|
}
|
|
2655
2656
|
};
|
|
2656
2657
|
var ScriptingMemory = {
|
|
@@ -2668,7 +2669,7 @@ ScriptingMemory.extractVarNames;
|
|
|
2668
2669
|
ScriptingMemory.RESERVED_WORDS;
|
|
2669
2670
|
ScriptingMemory.SCRIPTING_FUNCTIONS;
|
|
2670
2671
|
|
|
2671
|
-
const debug$
|
|
2672
|
+
const debug$k = debug__default["default"]('botium-core-Convo');
|
|
2672
2673
|
const {
|
|
2673
2674
|
BotiumError: BotiumError$2,
|
|
2674
2675
|
botiumErrorFromErr: botiumErrorFromErr$1,
|
|
@@ -2822,10 +2823,10 @@ class TranscriptError extends Error {
|
|
|
2822
2823
|
class Convo$6 {
|
|
2823
2824
|
constructor(context, fromJson = {}) {
|
|
2824
2825
|
if (fromJson instanceof Convo$6) {
|
|
2825
|
-
debug$
|
|
2826
|
+
debug$k('Illegal state!!! Parameter should be a JSON, but it is a Convo');
|
|
2826
2827
|
} else if (fromJson.beginAsserter) {
|
|
2827
2828
|
// beginAsserter is one of the fields which are lost
|
|
2828
|
-
debug$
|
|
2829
|
+
debug$k('Illegal state!!! Parameter should be a native JSON, but looks as a Convo converted to JSON');
|
|
2829
2830
|
}
|
|
2830
2831
|
this.scriptingEvents = context.scriptingEvents;
|
|
2831
2832
|
this.context = context;
|
|
@@ -2989,7 +2990,7 @@ class Convo$6 {
|
|
|
2989
2990
|
try {
|
|
2990
2991
|
params = JSON.parse(rawConvoStepParameters[0]);
|
|
2991
2992
|
} catch (e) {
|
|
2992
|
-
debug$
|
|
2993
|
+
debug$k(`${this.header.name}/${convoStep.stepTag}: Failed to parse convo step parameters from JSON ${rawConvoStepParameters[0]}`);
|
|
2993
2994
|
}
|
|
2994
2995
|
}
|
|
2995
2996
|
if (!params || !Object.keys(params).length) {
|
|
@@ -3002,7 +3003,7 @@ class Convo$6 {
|
|
|
3002
3003
|
const value = param.substring(semicolon + 1);
|
|
3003
3004
|
params[name] = value;
|
|
3004
3005
|
} catch (e) {
|
|
3005
|
-
debug$
|
|
3006
|
+
debug$k(`${this.header.name}/${convoStep.stepTag}: Failed to parse convo step parameter from arg ${param}`);
|
|
3006
3007
|
}
|
|
3007
3008
|
}
|
|
3008
3009
|
}
|
|
@@ -3018,7 +3019,7 @@ class Convo$6 {
|
|
|
3018
3019
|
}
|
|
3019
3020
|
}
|
|
3020
3021
|
if (Object.keys(convoStepParameters).length) {
|
|
3021
|
-
debug$
|
|
3022
|
+
debug$k(`${this.header.name}: using convo step parameters ${JSON.stringify(convoStepParameters)}`);
|
|
3022
3023
|
}
|
|
3023
3024
|
const currentStepIndex = i;
|
|
3024
3025
|
container.eventEmitter.emit(Events.CONVO_STEP_NEXT, container, convoStep, i);
|
|
@@ -3081,7 +3082,7 @@ class Convo$6 {
|
|
|
3081
3082
|
});
|
|
3082
3083
|
await this._checkBotRepliesConsumed(container);
|
|
3083
3084
|
const coreMsg = lodash__default["default"].omit(removeBuffers(meMsg), ['sourceData']);
|
|
3084
|
-
debug$
|
|
3085
|
+
debug$k(`${this.header.name}/${convoStep.stepTag}: user says (cleaned by binary and base64 data and sourceData) ${JSON.stringify(coreMsg, null, 2)}`);
|
|
3085
3086
|
await new Promise(resolve => {
|
|
3086
3087
|
if (container.caps[Capabilities.SIMULATE_WRITING_SPEED] && meMsg.messageText && meMsg.messageText.length) {
|
|
3087
3088
|
setTimeout(() => resolve(), container.caps[Capabilities.SIMULATE_WRITING_SPEED] * meMsg.messageText.length);
|
|
@@ -3117,7 +3118,7 @@ class Convo$6 {
|
|
|
3117
3118
|
});
|
|
3118
3119
|
continue;
|
|
3119
3120
|
} else {
|
|
3120
|
-
debug$
|
|
3121
|
+
debug$k(`${this.header.name}/${convoStep.stepTag}: message not found in #me section, message not sent to container ${util__default["default"].inspect(convoStep)}`);
|
|
3121
3122
|
transcriptStep.botEnd = new Date();
|
|
3122
3123
|
await this.scriptingEvents.onMeEnd({
|
|
3123
3124
|
convo: this,
|
|
@@ -3133,7 +3134,7 @@ class Convo$6 {
|
|
|
3133
3134
|
} catch (err) {
|
|
3134
3135
|
transcriptStep.botEnd = new Date();
|
|
3135
3136
|
const failErr = botiumErrorFromErr$1(`${this.header.name}/${convoStep.stepTag}: error sending to bot - ${err.message || err}`, err);
|
|
3136
|
-
debug$
|
|
3137
|
+
debug$k(failErr);
|
|
3137
3138
|
try {
|
|
3138
3139
|
this.scriptingEvents.fail && this.scriptingEvents.fail(failErr);
|
|
3139
3140
|
} catch (failErr) {}
|
|
@@ -3146,7 +3147,7 @@ class Convo$6 {
|
|
|
3146
3147
|
waitForBotSays = true;
|
|
3147
3148
|
}
|
|
3148
3149
|
try {
|
|
3149
|
-
debug$
|
|
3150
|
+
debug$k(`${this.header.name} wait for bot ${convoStep.channel || ''}`);
|
|
3150
3151
|
await this.scriptingEvents.onBotStart({
|
|
3151
3152
|
convo: this,
|
|
3152
3153
|
convoStep,
|
|
@@ -3162,11 +3163,11 @@ class Convo$6 {
|
|
|
3162
3163
|
transcriptStep.botEnd = new Date();
|
|
3163
3164
|
transcriptStep.actual = new BotiumMockMessage_1(botMsg);
|
|
3164
3165
|
const coreMsg = lodash__default["default"].omit(removeBuffers(botMsg), ['sourceData']);
|
|
3165
|
-
debug$
|
|
3166
|
+
debug$k(`${this.header.name}: bot says (cleaned by binary and base64 data and sourceData) ${JSON.stringify(coreMsg, null, 2)}`);
|
|
3166
3167
|
} catch (err) {
|
|
3167
3168
|
transcriptStep.botEnd = new Date();
|
|
3168
3169
|
const failErr = botiumErrorFromErr$1(`${this.header.name}/${convoStep.stepTag}: error waiting for bot - ${err.message}`, err);
|
|
3169
|
-
debug$
|
|
3170
|
+
debug$k(failErr);
|
|
3170
3171
|
try {
|
|
3171
3172
|
this.scriptingEvents.fail && this.scriptingEvents.fail(failErr, lastMeConvoStep);
|
|
3172
3173
|
} catch (failErr) {}
|
|
@@ -3185,11 +3186,11 @@ class Convo$6 {
|
|
|
3185
3186
|
if (prepared) {
|
|
3186
3187
|
transcriptStep.actual = new BotiumMockMessage_1(botMsg);
|
|
3187
3188
|
const coreMsg = lodash__default["default"].omit(removeBuffers(botMsg), ['sourceData']);
|
|
3188
|
-
debug$
|
|
3189
|
+
debug$k(`${this.header.name}: onBotPrepare (cleaned by binary and base64 data and sourceData) ${JSON.stringify(coreMsg, null, 2)}`);
|
|
3189
3190
|
}
|
|
3190
3191
|
} catch (err) {
|
|
3191
3192
|
const failErr = botiumErrorFromErr$1(`${this.header.name}/${convoStep.stepTag}: onBotPrepare error - ${err.message || err}`, err);
|
|
3192
|
-
debug$
|
|
3193
|
+
debug$k(failErr);
|
|
3193
3194
|
try {
|
|
3194
3195
|
this.scriptingEvents.fail && this.scriptingEvents.fail(failErr, lastMeConvoStep);
|
|
3195
3196
|
} catch (failErr) {}
|
|
@@ -3210,7 +3211,7 @@ class Convo$6 {
|
|
|
3210
3211
|
skipTranscriptStep = true;
|
|
3211
3212
|
if (endOfConditionalGroup && !conditionMetInGroup && !convoStep.optional) {
|
|
3212
3213
|
const failErr = new BotiumError$2(`${this.header.name}/${convoStep.stepTag}: Non of the conditions are met in ${conditionalGroupId ? `'${conditionalGroupId}' ` : ''}condition group`);
|
|
3213
|
-
debug$
|
|
3214
|
+
debug$k(failErr);
|
|
3214
3215
|
throw failErr;
|
|
3215
3216
|
}
|
|
3216
3217
|
if (endOfConditionalGroup) {
|
|
@@ -3230,7 +3231,7 @@ class Convo$6 {
|
|
|
3230
3231
|
}
|
|
3231
3232
|
if (!botMsg || !botMsg.messageText && !botMsg.media && !botMsg.buttons && !botMsg.cards && !botMsg.sourceData && !botMsg.nlp) {
|
|
3232
3233
|
const failErr = new BotiumError$2(`${this.header.name}/${convoStep.stepTag}: bot says nothing`);
|
|
3233
|
-
debug$
|
|
3234
|
+
debug$k(failErr);
|
|
3234
3235
|
try {
|
|
3235
3236
|
this.scriptingEvents.fail && this.scriptingEvents.fail(failErr, lastMeConvoStep);
|
|
3236
3237
|
} catch (failErr) {}
|
|
@@ -3242,7 +3243,7 @@ class Convo$6 {
|
|
|
3242
3243
|
const retryOn = convoStep.sender === 'bot' && retryConfig && retryConfig.timeout && retryConfig.mainAsserter;
|
|
3243
3244
|
if (convoStep.optional && nextConvoStep && nextConvoStep.sender === 'bot') {
|
|
3244
3245
|
if (retryOn) {
|
|
3245
|
-
debug$
|
|
3246
|
+
debug$k(`${this.header.name}/${convoStep.stepTag}: Retry failed asserter is ignored on optional convo`);
|
|
3246
3247
|
}
|
|
3247
3248
|
waitForBotSays = false;
|
|
3248
3249
|
skipTranscriptStep = true;
|
|
@@ -3255,11 +3256,11 @@ class Convo$6 {
|
|
|
3255
3256
|
const now = new Date().getTime();
|
|
3256
3257
|
const timeoutRemaining = retryBotMessageTimeoutEnd - now;
|
|
3257
3258
|
if (timeoutRemaining > 0) {
|
|
3258
|
-
debug$
|
|
3259
|
+
debug$k(`${this.header.name}/${convoStep.stepTag}: Convo step retry on, timeout remaining: ${timeoutRemaining}, error: "${err.message}"`);
|
|
3259
3260
|
retryBotMessageDropBotResponse = true;
|
|
3260
3261
|
return false;
|
|
3261
3262
|
} else {
|
|
3262
|
-
debug$
|
|
3263
|
+
debug$k(`${this.header.name}/${convoStep.stepTag}: Convo step retry on, but timeout is over. error: "${err.message}"`);
|
|
3263
3264
|
}
|
|
3264
3265
|
}
|
|
3265
3266
|
if (container.caps[Capabilities.SCRIPTING_ENABLE_MULTIPLE_ASSERT_ERRORS]) {
|
|
@@ -3343,14 +3344,14 @@ class Convo$6 {
|
|
|
3343
3344
|
const now = new Date().getTime();
|
|
3344
3345
|
const timeoutRemaining = retryOn && retryBotMessageTimeoutEnd - now;
|
|
3345
3346
|
if (retryOn && timeoutRemaining > 0) {
|
|
3346
|
-
debug$
|
|
3347
|
+
debug$k(`${this.header.name}/${convoStep.stepTag}: Convo step retry on, timeout remaining: ${timeoutRemaining}, error: "${err.message}"`);
|
|
3347
3348
|
retryBotMessageDropBotResponse = true;
|
|
3348
3349
|
} else {
|
|
3349
3350
|
if (retryOn && timeoutRemaining <= 0) {
|
|
3350
|
-
debug$
|
|
3351
|
+
debug$k(`${this.header.name}/${convoStep.stepTag}: Convo step retry on, but timeout is over. error: "${err.message}"`);
|
|
3351
3352
|
}
|
|
3352
3353
|
const failErr = botiumErrorFromErr$1(`${this.header.name}/${convoStep.stepTag}: assertion error - ${err.message || err}`, err);
|
|
3353
|
-
debug$
|
|
3354
|
+
debug$k(failErr);
|
|
3354
3355
|
try {
|
|
3355
3356
|
this.scriptingEvents.fail && this.scriptingEvents.fail(failErr, lastMeConvoStep);
|
|
3356
3357
|
} catch (failErr) {}
|
|
@@ -3374,7 +3375,7 @@ class Convo$6 {
|
|
|
3374
3375
|
}
|
|
3375
3376
|
} else {
|
|
3376
3377
|
const failErr = new BotiumError$2(`${this.header.name}/${convoStep.stepTag}: invalid sender - ${util__default["default"].inspect(convoStep.sender)}`);
|
|
3377
|
-
debug$
|
|
3378
|
+
debug$k(failErr);
|
|
3378
3379
|
try {
|
|
3379
3380
|
this.scriptingEvents.fail && this.scriptingEvents.fail(failErr);
|
|
3380
3381
|
} catch (failErr) {}
|
|
@@ -3580,7 +3581,7 @@ class Convo$6 {
|
|
|
3580
3581
|
throw new BotiumError$2(`Cant find partial convo with name ${includeLogicHook} (available partial convos: ${Object.keys(partialConvos).join(',')})`);
|
|
3581
3582
|
}
|
|
3582
3583
|
_getEffectiveConversationRecursive(partialConvo.conversation, [...parentPConvos, includeLogicHook], result, true);
|
|
3583
|
-
debug$
|
|
3584
|
+
debug$k(`Partial convo ${includeLogicHook} included`);
|
|
3584
3585
|
});
|
|
3585
3586
|
});
|
|
3586
3587
|
return result;
|
|
@@ -3601,7 +3602,7 @@ var Convo_1 = {
|
|
|
3601
3602
|
TranscriptError
|
|
3602
3603
|
};
|
|
3603
3604
|
|
|
3604
|
-
const debug$
|
|
3605
|
+
const debug$j = debug__default["default"]('botium-core-RetryHelper');
|
|
3605
3606
|
var RetryHelper_1 = class RetryHelper {
|
|
3606
3607
|
constructor(caps, section, options = {}) {
|
|
3607
3608
|
this.retryErrorPatterns = [];
|
|
@@ -3625,7 +3626,7 @@ var RetryHelper_1 = class RetryHelper {
|
|
|
3625
3626
|
minTimeout: caps[`RETRY_${section.toUpperCase()}_MINTIMEOUT`] || (lodash__default["default"].isNil(options.minTimeout) ? 1000 : options.minTimeout)
|
|
3626
3627
|
};
|
|
3627
3628
|
if (this.retrySettings.retries > 0) {
|
|
3628
|
-
debug$
|
|
3629
|
+
debug$j(`Retry for ${section} is enabled. Settings: ${JSON.stringify(this.retrySettings)} Patterns: ${JSON.stringify(this.retryErrorPatterns.map(r => r.toString()))}`);
|
|
3629
3630
|
}
|
|
3630
3631
|
}
|
|
3631
3632
|
shouldRetry(err) {
|
|
@@ -3639,26 +3640,36 @@ var RetryHelper_1 = class RetryHelper {
|
|
|
3639
3640
|
}
|
|
3640
3641
|
};
|
|
3641
3642
|
|
|
3643
|
+
const debug$i = debug__default["default"]('botium-core-MatchFunctions');
|
|
3642
3644
|
const {
|
|
3643
3645
|
toString,
|
|
3644
3646
|
quoteRegexpString,
|
|
3645
3647
|
calculateWer: calculateWer$1
|
|
3646
3648
|
} = helper;
|
|
3647
|
-
const _normalize = botresponse => {
|
|
3649
|
+
const _normalize = (botresponse, args, convoStepParameters) => {
|
|
3650
|
+
if (!convoStepParameters) {
|
|
3651
|
+
debug$i('Convo step parameters might be missing!');
|
|
3652
|
+
}
|
|
3648
3653
|
if (lodash__default["default"].isUndefined(botresponse) || lodash__default["default"].isNil(botresponse)) return '';
|
|
3649
3654
|
if (lodash__default["default"].isObject(botresponse) && lodash__default["default"].has(botresponse, 'messageText')) {
|
|
3650
3655
|
return toString(botresponse.messageText) || '';
|
|
3651
3656
|
}
|
|
3652
3657
|
return toString(botresponse);
|
|
3653
3658
|
};
|
|
3654
|
-
const regexp = ignoreCase => (botresponse, utterance) => {
|
|
3659
|
+
const regexp = ignoreCase => (botresponse, utterance, args, convoStepParameters) => {
|
|
3660
|
+
if (!convoStepParameters) {
|
|
3661
|
+
debug$i('Convo step parameters might be missing!');
|
|
3662
|
+
}
|
|
3655
3663
|
if (lodash__default["default"].isUndefined(botresponse)) return false;
|
|
3656
3664
|
utterance = toString(utterance);
|
|
3657
3665
|
botresponse = _normalize(botresponse);
|
|
3658
3666
|
const regexp = ignoreCase ? new RegExp(utterance, 'i') : new RegExp(utterance, '');
|
|
3659
3667
|
return regexp.test(botresponse);
|
|
3660
3668
|
};
|
|
3661
|
-
const wildcard = ignoreCase => (botresponse, utterance) => {
|
|
3669
|
+
const wildcard = ignoreCase => (botresponse, utterance, args, convoStepParameters) => {
|
|
3670
|
+
if (!convoStepParameters) {
|
|
3671
|
+
debug$i('Convo step parameters might be missing!');
|
|
3672
|
+
}
|
|
3662
3673
|
if (lodash__default["default"].isUndefined(botresponse)) {
|
|
3663
3674
|
if (utterance.trim() === '*') return true;else return false;
|
|
3664
3675
|
}
|
|
@@ -3672,7 +3683,10 @@ const wildcard = ignoreCase => (botresponse, utterance) => {
|
|
|
3672
3683
|
const regexp = ignoreCase ? new RegExp(utteranceRe, 'i') : new RegExp(utteranceRe, '');
|
|
3673
3684
|
return regexp.test(botresponse);
|
|
3674
3685
|
};
|
|
3675
|
-
const wildcardExact = ignoreCase => (botresponse, utterance) => {
|
|
3686
|
+
const wildcardExact = ignoreCase => (botresponse, utterance, args, convoStepParameters) => {
|
|
3687
|
+
if (!convoStepParameters) {
|
|
3688
|
+
debug$i('Convo step parameters might be missing!');
|
|
3689
|
+
}
|
|
3676
3690
|
if (lodash__default["default"].isUndefined(botresponse)) {
|
|
3677
3691
|
if (utterance.trim() === '*') return true;else return false;
|
|
3678
3692
|
}
|
|
@@ -3686,7 +3700,10 @@ const wildcardExact = ignoreCase => (botresponse, utterance) => {
|
|
|
3686
3700
|
const regexp = ignoreCase ? new RegExp(utteranceRe, 'i') : new RegExp(utteranceRe, '');
|
|
3687
3701
|
return regexp.test(botresponse);
|
|
3688
3702
|
};
|
|
3689
|
-
const include = ignoreCase => (botresponse, utterance) => {
|
|
3703
|
+
const include = ignoreCase => (botresponse, utterance, args, convoStepParameters) => {
|
|
3704
|
+
if (!convoStepParameters) {
|
|
3705
|
+
debug$i('Convo step parameters might be missing!');
|
|
3706
|
+
}
|
|
3690
3707
|
if (lodash__default["default"].isUndefined(botresponse)) return false;
|
|
3691
3708
|
utterance = toString(utterance);
|
|
3692
3709
|
botresponse = _normalize(botresponse);
|
|
@@ -3696,7 +3713,10 @@ const include = ignoreCase => (botresponse, utterance) => {
|
|
|
3696
3713
|
}
|
|
3697
3714
|
return botresponse.indexOf(utterance) >= 0;
|
|
3698
3715
|
};
|
|
3699
|
-
const equals = ignoreCase => (botresponse, utterance) => {
|
|
3716
|
+
const equals = ignoreCase => (botresponse, utterance, args, convoStepParameters) => {
|
|
3717
|
+
if (!convoStepParameters) {
|
|
3718
|
+
debug$i('Convo step parameters might be missing!');
|
|
3719
|
+
}
|
|
3700
3720
|
if (lodash__default["default"].isUndefined(botresponse)) return false;
|
|
3701
3721
|
utterance = toString(utterance);
|
|
3702
3722
|
botresponse = _normalize(botresponse);
|
|
@@ -3706,10 +3726,13 @@ const equals = ignoreCase => (botresponse, utterance) => {
|
|
|
3706
3726
|
}
|
|
3707
3727
|
return botresponse === utterance;
|
|
3708
3728
|
};
|
|
3709
|
-
const wer = () => (botresponse, utterance, args) => {
|
|
3729
|
+
const wer = () => (botresponse, utterance, args, convoStepParameters) => {
|
|
3730
|
+
if (!convoStepParameters) {
|
|
3731
|
+
debug$i('Convo step parameters might be missing!');
|
|
3732
|
+
}
|
|
3710
3733
|
botresponse = _normalize(botresponse || '');
|
|
3711
3734
|
utterance = toString(utterance || '');
|
|
3712
|
-
const threshold = [',', '.'].find(p => `${args[0]}`.includes(p)) ? parseFloat(args[0]) : parseInt(args[0]) / 100;
|
|
3735
|
+
const threshold = !lodash__default["default"].isNil(convoStepParameters?.matchingModeWer) ? convoStepParameters?.matchingModeWer / 100 : [',', '.'].find(p => `${args[0]}`.includes(p)) ? parseFloat(args[0]) : parseInt(args[0]) / 100;
|
|
3713
3736
|
return calculateWer$1(botresponse, utterance) <= threshold;
|
|
3714
3737
|
};
|
|
3715
3738
|
const getMatchFunction$1 = matchingMode => {
|
|
@@ -4868,7 +4891,7 @@ var CompilerTxt_1 = class CompilerTxt extends CompilerBase_1 {
|
|
|
4868
4891
|
Compile(scriptBuffer, scriptType = Constants.SCRIPTING_TYPE_CONVO) {
|
|
4869
4892
|
let scriptData = scriptBuffer;
|
|
4870
4893
|
if (Buffer.isBuffer(scriptBuffer)) scriptData = scriptData.toString();
|
|
4871
|
-
const lines =
|
|
4894
|
+
const lines = scriptData.split(this.eol);
|
|
4872
4895
|
if (scriptType === Constants.SCRIPTING_TYPE_CONVO) {
|
|
4873
4896
|
return this._compileConvo(lines, false);
|
|
4874
4897
|
} else if (scriptType === Constants.SCRIPTING_TYPE_PCONVO) {
|
|
@@ -4918,7 +4941,6 @@ var CompilerTxt_1 = class CompilerTxt extends CompilerBase_1 {
|
|
|
4918
4941
|
};
|
|
4919
4942
|
lines.forEach(line => {
|
|
4920
4943
|
currentLineIndex++;
|
|
4921
|
-
line = line.trim();
|
|
4922
4944
|
if (isValidTagLine(line)) {
|
|
4923
4945
|
pushPrev();
|
|
4924
4946
|
convoStepSender = line.substr(1).trim();
|
|
@@ -5430,7 +5452,7 @@ var CompilerMarkdown_1 = class CompilerMarkdown extends CompilerBase_1 {
|
|
|
5430
5452
|
conversation.push(Object.assign({
|
|
5431
5453
|
sender,
|
|
5432
5454
|
stepTag: 'Line ' + (step.map[0] + 1)
|
|
5433
|
-
}, linesToConvoStep(step.children.map(child => child.content + (child.children ? ' ' + child.children.map(child => child.content).join('|') : '')), sender, this.context, this.eol)));
|
|
5455
|
+
}, linesToConvoStep(step.children.map(child => child.content + (child.children && child.children.length > 0 ? ' ' + child.children.map(child => child.content).join('|') : '')), sender, this.context, this.eol)));
|
|
5434
5456
|
} else {
|
|
5435
5457
|
debug$a(`Expected sender ${validSenders.map(s => `'${s}'`).join(' or ')} but found ${sender}`);
|
|
5436
5458
|
}
|
|
@@ -5731,25 +5753,26 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
5731
5753
|
resolveEmptyIfUnknown
|
|
5732
5754
|
});
|
|
5733
5755
|
},
|
|
5734
|
-
assertBotResponse: (botresponse, tomatch, stepTag, meMsg, convoStepParameters) => {
|
|
5756
|
+
assertBotResponse: (botresponse, tomatch, stepTag, meMsg, convoStepParameters = {}) => {
|
|
5735
5757
|
if (!lodash__default["default"].isArray(tomatch)) {
|
|
5736
5758
|
tomatch = [tomatch];
|
|
5737
5759
|
}
|
|
5738
5760
|
debug$9(`assertBotResponse ${stepTag} ${meMsg ? `(${meMsg}) ` : ''}BOT: ${botresponse} = ${tomatch} ...`);
|
|
5739
5761
|
const matchFn = convoStepParameters.matchingMode ? getMatchFunction(convoStepParameters.matchingMode) || this.matchFn : this.matchFn;
|
|
5740
|
-
const found = lodash__default["default"].find(tomatch, utt => matchFn(botresponse, utt, this.caps[Capabilities.SCRIPTING_MATCHING_MODE_ARGS]));
|
|
5762
|
+
const found = lodash__default["default"].find(tomatch, utt => matchFn(botresponse, utt, this.caps[Capabilities.SCRIPTING_MATCHING_MODE_ARGS], convoStepParameters));
|
|
5741
5763
|
const asserterType = this.caps[Capabilities.SCRIPTING_MATCHING_MODE] === 'wer' ? 'Word Error Rate Asserter' : 'Text Match Asserter';
|
|
5742
5764
|
if (lodash__default["default"].isNil(found)) {
|
|
5743
|
-
|
|
5765
|
+
const matchingMode = convoStepParameters.matchingMode || this.caps[Capabilities.SCRIPTING_MATCHING_MODE];
|
|
5766
|
+
if (matchingMode === 'wer') {
|
|
5744
5767
|
const wer = calculateWer(botresponse, tomatch[0]);
|
|
5745
5768
|
const werArgs = this.caps[Capabilities.SCRIPTING_MATCHING_MODE_ARGS];
|
|
5746
|
-
const threshold = [',', '.'].find(p => `${werArgs[0]}`.includes(p)) ? parseFloat(werArgs[0]) : parseInt(werArgs[0]) / 100;
|
|
5769
|
+
const threshold = !lodash__default["default"].isNil(convoStepParameters.matchingModeWer) ? convoStepParameters.matchingModeWer / 100 : [',', '.'].find(p => `${werArgs[0]}`.includes(p)) ? parseFloat(werArgs[0]) : parseInt(werArgs[0]) / 100;
|
|
5747
5770
|
const message = `${stepTag}: Word Error Rate (${toPercent(wer)}) higher than accepted (${toPercent(threshold)})`;
|
|
5748
5771
|
throw new BotiumError$1(message, {
|
|
5749
5772
|
type: 'asserter',
|
|
5750
5773
|
source: asserterType,
|
|
5751
5774
|
params: {
|
|
5752
|
-
matchingMode
|
|
5775
|
+
matchingMode,
|
|
5753
5776
|
args: this.caps[Capabilities.SCRIPTING_MATCHING_MODE_ARGS] || null
|
|
5754
5777
|
},
|
|
5755
5778
|
context: {
|
|
@@ -5787,25 +5810,26 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
5787
5810
|
}
|
|
5788
5811
|
}
|
|
5789
5812
|
},
|
|
5790
|
-
assertBotNotResponse: (botresponse, nottomatch, stepTag, meMsg, convoStepParameters) => {
|
|
5813
|
+
assertBotNotResponse: (botresponse, nottomatch, stepTag, meMsg, convoStepParameters = {}) => {
|
|
5791
5814
|
if (!lodash__default["default"].isArray(nottomatch)) {
|
|
5792
5815
|
nottomatch = [nottomatch];
|
|
5793
5816
|
}
|
|
5794
5817
|
debug$9(`assertBotNotResponse ${stepTag} ${meMsg ? `(${meMsg}) ` : ''}BOT: ${botresponse} != ${nottomatch} ...`);
|
|
5795
5818
|
const matchFn = convoStepParameters.matchingMode ? getMatchFunction(convoStepParameters.matchingMode) || this.matchFn : this.matchFn;
|
|
5796
|
-
const found = lodash__default["default"].find(nottomatch, utt => matchFn(botresponse, utt, this.caps[Capabilities.SCRIPTING_MATCHING_MODE_ARGS]));
|
|
5819
|
+
const found = lodash__default["default"].find(nottomatch, utt => matchFn(botresponse, utt, this.caps[Capabilities.SCRIPTING_MATCHING_MODE_ARGS], convoStepParameters));
|
|
5797
5820
|
const asserterType = this.caps[Capabilities.SCRIPTING_MATCHING_MODE] === 'wer' ? 'Word Error Rate Asserter' : 'Text Match Asserter';
|
|
5798
5821
|
if (!lodash__default["default"].isNil(found)) {
|
|
5799
|
-
|
|
5822
|
+
const matchingMode = convoStepParameters.matchingMode || this.caps[Capabilities.SCRIPTING_MATCHING_MODE];
|
|
5823
|
+
if (matchingMode === 'wer') {
|
|
5800
5824
|
const wer = calculateWer(botresponse, nottomatch[0]);
|
|
5801
5825
|
const werArgs = this.caps[Capabilities.SCRIPTING_MATCHING_MODE_ARGS];
|
|
5802
|
-
const threshold = [',', '.'].find(p => `${werArgs[0]}`.includes(p)) ? parseFloat(werArgs[0]) : parseInt(werArgs[0]) / 100;
|
|
5826
|
+
const threshold = !lodash__default["default"].isNil(convoStepParameters.matchingModeWer) ? convoStepParameters.matchingModeWer / 100 : [',', '.'].find(p => `${werArgs[0]}`.includes(p)) ? parseFloat(werArgs[0]) : parseInt(werArgs[0]) / 100;
|
|
5803
5827
|
const message = `${stepTag}: Word Error Rate (${toPercent(wer)}) lower than accepted (${toPercent(threshold)})`;
|
|
5804
5828
|
throw new BotiumError$1(message, {
|
|
5805
5829
|
type: 'asserter',
|
|
5806
5830
|
source: asserterType,
|
|
5807
5831
|
params: {
|
|
5808
|
-
matchingMode
|
|
5832
|
+
matchingMode,
|
|
5809
5833
|
args: this.caps[Capabilities.SCRIPTING_MATCHING_MODE_ARGS] || null
|
|
5810
5834
|
},
|
|
5811
5835
|
context: {
|