wingbot 3.71.6 → 3.72.0

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.
Files changed (152) hide show
  1. package/.babelrc +0 -0
  2. package/.github/workflows/deploy.yml +2 -2
  3. package/.github/workflows/pullRequest.yml +2 -2
  4. package/LICENSE +0 -0
  5. package/README.md +0 -0
  6. package/index.js +0 -0
  7. package/jsconfig.json +0 -0
  8. package/package.json +1 -1
  9. package/plugins/ai.wingbot.clearMessageSequences/plugin.js +0 -0
  10. package/plugins/ai.wingbot.conditionIfGoBackPossible/plugin.js +0 -0
  11. package/plugins/ai.wingbot.disambiguation/plugin.js +0 -0
  12. package/plugins/ai.wingbot.goBack/plugin.js +0 -0
  13. package/plugins/ai.wingbot.goToLastBreadcrumb/plugin.js +0 -0
  14. package/plugins/ai.wingbot.ifImageDetected/plugin.js +0 -0
  15. package/plugins/ai.wingbot.ifStickerDetected/plugin.js +0 -0
  16. package/plugins/ai.wingbot.jumpBack/plugin.js +0 -0
  17. package/plugins/ai.wingbot.jumpTo/plugin.js +0 -0
  18. package/plugins/ai.wingbot.keepInInteraction/plugin.js +0 -0
  19. package/plugins/ai.wingbot.keepInInteractionJustOnce/plugin.js +0 -0
  20. package/plugins/ai.wingbot.keepPreviousHandlers/plugin.js +0 -0
  21. package/plugins/ai.wingbot.keepPreviousHandlersJustOnce/plugin.js +0 -0
  22. package/plugins/ai.wingbot.oneTimeNotificationRequest/plugin.js +0 -0
  23. package/plugins/ai.wingbot.openai/plugin.js +0 -0
  24. package/plugins/ai.wingbot.passThreadToBot/plugin.js +0 -0
  25. package/plugins/ai.wingbot.persona/plugin.js +0 -0
  26. package/plugins/ai.wingbot.putABreadcrumb/plugin.js +0 -0
  27. package/plugins/ai.wingbot.regexp/plugin.js +0 -0
  28. package/plugins/ai.wingbot.setState/plugin.js +0 -0
  29. package/plugins/ai.wingbot.setStateFromInput/plugin.js +0 -0
  30. package/plugins/ai.wingbot.slotsContinue/plugin.js +0 -0
  31. package/plugins/ai.wingbot.slotsRegister/plugin.js +0 -0
  32. package/plugins/ai.wingbot.stopResponding/plugin.js +0 -0
  33. package/plugins/ai.wingbot.trackingEvent/plugin.js +0 -0
  34. package/plugins/ai.wingbot.upload/plugin.js +0 -0
  35. package/plugins/ai.wingbot.waitASecond/plugin.js +0 -0
  36. package/plugins/index.js +0 -0
  37. package/plugins/plugins.json +0 -0
  38. package/src/Ai.js +44 -3
  39. package/src/AiMatching.js +66 -40
  40. package/src/BatchConversationTester.js +0 -0
  41. package/src/BotApp.js +0 -0
  42. package/src/BotAppSender.js +0 -0
  43. package/src/BuildRouter.js +2 -0
  44. package/src/CallbackAuditLog.js +0 -0
  45. package/src/ChatGpt.js +0 -0
  46. package/src/ConversationTester.js +0 -0
  47. package/src/LLM.js +183 -2
  48. package/src/LLMMockProvider.js +0 -0
  49. package/src/LLMSession.js +90 -3
  50. package/src/MockAiModel.js +0 -0
  51. package/src/OrchestratorClient.js +0 -0
  52. package/src/Plugins.js +0 -0
  53. package/src/Processor.js +1 -1
  54. package/src/ReducerWrapper.js +0 -0
  55. package/src/Request.js +0 -0
  56. package/src/Responder.js +143 -3
  57. package/src/ReturnSender.js +4 -4
  58. package/src/Router.js +0 -0
  59. package/src/RouterWrap.js +0 -0
  60. package/src/SecurityMiddleware.js +0 -0
  61. package/src/Tester.js +44 -2
  62. package/src/analytics/GA4.js +0 -0
  63. package/src/analytics/consts.js +0 -0
  64. package/src/analytics/onInteractionHandler.js +0 -0
  65. package/src/defaultResourceMap.js +0 -0
  66. package/src/features.js +0 -0
  67. package/src/flags.js +0 -0
  68. package/src/fuzzy/factoryFuzzySearch.js +0 -0
  69. package/src/fuzzy/fuzzyUtils.js +0 -0
  70. package/src/fuzzy/index.js +0 -0
  71. package/src/fuzzy/levenshtein.js +0 -0
  72. package/src/fuzzy/normalize.js +0 -0
  73. package/src/fuzzy/prepareFuzzyIndex.js +0 -0
  74. package/src/graphApi/GraphApi.js +0 -0
  75. package/src/graphApi/WingbotApiConnector.js +0 -0
  76. package/src/graphApi/apiAuthorizer.js +0 -0
  77. package/src/graphApi/conversationTestApi.js +0 -0
  78. package/src/graphApi/conversationsApi.js +0 -0
  79. package/src/graphApi/index.js +0 -0
  80. package/src/graphApi/postBackApi.js +0 -0
  81. package/src/graphApi/schema.gql +0 -0
  82. package/src/graphApi/validateBotApi.js +0 -0
  83. package/src/notifications/Notifications.js +0 -0
  84. package/src/notifications/NotificationsStorage.js +0 -0
  85. package/src/notifications/api/index.js +0 -0
  86. package/src/notifications/api/notificationsApiFactory.js +0 -0
  87. package/src/notifications/index.js +0 -0
  88. package/src/resolvers/bounce.js +0 -0
  89. package/src/resolvers/button.js +0 -0
  90. package/src/resolvers/carousel.js +0 -0
  91. package/src/resolvers/contextMessage.js +21 -4
  92. package/src/resolvers/expected.js +0 -0
  93. package/src/resolvers/expectedInput.js +0 -0
  94. package/src/resolvers/hbs.js +0 -0
  95. package/src/resolvers/include.js +0 -0
  96. package/src/resolvers/index.js +0 -0
  97. package/src/resolvers/media.js +0 -0
  98. package/src/resolvers/message.js +43 -1
  99. package/src/resolvers/passThread.js +0 -0
  100. package/src/resolvers/path.js +0 -0
  101. package/src/resolvers/plugin.js +0 -0
  102. package/src/resolvers/postback.js +0 -0
  103. package/src/resolvers/resolverTags.js +0 -0
  104. package/src/resolvers/setState.js +0 -0
  105. package/src/resolvers/skip.js +0 -0
  106. package/src/resolvers/subscribtions.js +0 -0
  107. package/src/resolvers/utils.js +14 -5
  108. package/src/systemEntities/email.js +0 -0
  109. package/src/systemEntities/index.js +0 -0
  110. package/src/systemEntities/phone.js +0 -0
  111. package/src/systemEntities/regexps.js +0 -0
  112. package/src/templates/BaseTemplate.js +0 -0
  113. package/src/templates/ButtonTemplate.js +0 -0
  114. package/src/templates/GenericTemplate.js +0 -0
  115. package/src/templates/ListTemplate.js +0 -0
  116. package/src/templates/ReceiptTemplate.js +0 -0
  117. package/src/testTools/AnyResponseAssert.js +0 -0
  118. package/src/testTools/PromptAssert.js +184 -0
  119. package/src/testTools/ResponseAssert.js +0 -0
  120. package/src/testTools/asserts.js +42 -4
  121. package/src/testTools/index.js +0 -0
  122. package/src/tools/MemoryBotConfigStorage.js +0 -0
  123. package/src/tools/MemoryChatLogStorage.js +0 -0
  124. package/src/tools/MemoryStateStorage.js +0 -0
  125. package/src/tools/bufferloader.js +0 -0
  126. package/src/tools/index.js +0 -0
  127. package/src/tools/routeToEvents.js +0 -0
  128. package/src/transcript/extractText.js +0 -0
  129. package/src/transcript/textBodyFromTranscript.js +0 -0
  130. package/src/transcript/transcriptFromHistory.js +0 -0
  131. package/src/utils/ai.js +0 -0
  132. package/src/utils/compileWithState.js +0 -0
  133. package/src/utils/customCondition.js +14 -1
  134. package/src/utils/customFn.js +0 -0
  135. package/src/utils/datetime.js +0 -0
  136. package/src/utils/deepMapTools.js +0 -0
  137. package/src/utils/generateToken.js +0 -0
  138. package/src/utils/getCondition.js +16 -4
  139. package/src/utils/getUpdate.js +4 -4
  140. package/src/utils/headersToAuditMeta.js +0 -0
  141. package/src/utils/index.js +0 -0
  142. package/src/utils/pathUtils.js +0 -0
  143. package/src/utils/quickReplies.js +0 -0
  144. package/src/utils/slots.js +0 -0
  145. package/src/utils/stateData.js +2 -0
  146. package/src/utils/stateVariables.js +0 -0
  147. package/src/utils/tokenizer.js +0 -0
  148. package/src/utils/wrapPluginFunction.js +0 -0
  149. package/src/wingbot/CachedModel.js +0 -0
  150. package/src/wingbot/CustomEntityDetectionModel.js +0 -0
  151. package/src/wingbot/WingbotModel.js +0 -0
  152. package/src/wingbot/index.js +0 -0
package/src/utils/ai.js CHANGED
File without changes
File without changes
@@ -175,9 +175,22 @@ const compare = (variable, operator, value = undefined) => {
175
175
  }
176
176
  };
177
177
 
178
+ /** @typedef {'if'|'it'|'c'|'nc'|'mr'|'nmr'|'st'|'gt'|'set'|'get'|'eq'|'neq'} ConditionOperator */
179
+
180
+ /**
181
+ * @typedef {object} EditableConditionRule
182
+ * @prop {string} value
183
+ * @prop {ConditionOperator} operator
184
+ * @prop {string} variable
185
+ */
186
+
187
+ /**
188
+ * @typedef {EditableConditionRule[][]} EditableCondition
189
+ */
190
+
178
191
  /**
179
192
  *
180
- * @param {{value:string, operator:string, variable:string}[][]} condition
193
+ * @param {EditableCondition} condition
181
194
  * @param {object} configuration
182
195
  * @param {string} description
183
196
  */
File without changes
File without changes
File without changes
File without changes
@@ -7,11 +7,23 @@ const customCondition = require('./customCondition');
7
7
  const customFn = require('./customFn');
8
8
 
9
9
  /** @typedef {import('../BuildRouter').BotContext} BotContext */
10
+ /** @typedef {import('./customCondition').EditableCondition} EditableCondition */
11
+
12
+ // eslint-disable-next-line max-len
13
+ /** @typedef {Pick<BotContext,'configuration'|'allowForbiddenSnippetWords'|'linksMap'|'ai'>} ConditionContext */
14
+
15
+ /**
16
+ * @typedef {object} ConditionDefinition
17
+ * @prop {boolean} [hasCondition]
18
+ * @prop {string} [conditionFn]
19
+ * @prop {boolean} [hasEditableCondition]
20
+ * @prop {EditableCondition} [editableCondition]
21
+ */
10
22
 
11
23
  /**
12
24
  *
13
- * @param {object} params
14
- * @param {BotContext} context
25
+ * @param {ConditionDefinition} params
26
+ * @param {ConditionContext} context
15
27
  * @param {string} description
16
28
  * @returns {Function}
17
29
  */
@@ -27,7 +39,7 @@ module.exports = function getCondition (params, context, description = '') {
27
39
  editableCondition = []
28
40
  } = params;
29
41
 
30
- let condition = null;
42
+ let condition;
31
43
 
32
44
  if (hasCondition) {
33
45
  if (hasEditableCondition) {
@@ -36,7 +48,7 @@ module.exports = function getCondition (params, context, description = '') {
36
48
  condition = customFn(conditionFn, description, allowForbiddenSnippetWords);
37
49
  }
38
50
  } else {
39
- condition = customFn('(req,res)=>true', description, allowForbiddenSnippetWords);
51
+ condition = () => true;
40
52
  }
41
53
  return condition;
42
54
  };
@@ -88,7 +88,7 @@ function toArray (previousValue) {
88
88
  const ENTITY_HBS_REGEXP = /^\s*\{\{\[?@([^@[\]{}\s]+)(\])?\}\}\s*$/;
89
89
  const VARIABLE_HBS_REGEXP = /^\s*\{\{\[?([^$@[\]{}\s]+)\]?\}\}\s*$/;
90
90
 
91
- function getSetState (setState, req, res = null, useState = null, configuration = null) {
91
+ function getSetState (setState, req, res = null, stateOverride = null, configuration = null) {
92
92
  if (!setState) {
93
93
  return {};
94
94
  }
@@ -96,7 +96,7 @@ function getSetState (setState, req, res = null, useState = null, configuration
96
96
  .filter((k) => k !== '_');
97
97
 
98
98
  let obj = {};
99
- let state = stateData(req, res, configuration, useState);
99
+ let state = stateData(req, res, configuration, stateOverride);
100
100
 
101
101
  keys.forEach((k) => {
102
102
  const val = setState[k];
@@ -166,8 +166,8 @@ function getSetState (setState, req, res = null, useState = null, configuration
166
166
  if (entity && (!rear || req.entities.some((e) => e.entity === entity))) {
167
167
  values = req.entities.filter((e) => e.entity === entity)
168
168
  .map((e) => e.value);
169
- if (values.length === 0 && useState && useState[`@${entity}`]) {
170
- values = [useState[`@${entity}`]];
169
+ if (values.length === 0 && stateOverride && stateOverride[`@${entity}`]) {
170
+ values = [stateOverride[`@${entity}`]];
171
171
  }
172
172
  } else if (variable) {
173
173
  values = toArray(getValue(variable, state));
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -16,6 +16,7 @@ const { dateToISO8601String, zeroHourDate } = require('./datetime');
16
16
  * @prop {object} [configuration]
17
17
  * @prop {Function} text
18
18
  * @prop {Function} [actionData]
19
+ * @prop {Function} [isConfidentInput]
19
20
  */
20
21
 
21
22
  /**
@@ -68,6 +69,7 @@ module.exports = function stateData (
68
69
  $today,
69
70
  $tomorrow,
70
71
  $yesterday,
72
+ $llmResult: res?.llm?.lastResult?.content,
71
73
  // yes - res because of circular dependency
72
74
  ...(res && req && req.actionData()),
73
75
  ...(res ? res.data : {}),
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes