@microsoft/agents-hosting-dialogs 0.1.49

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 (325) hide show
  1. package/dist/index.js +20 -0
  2. package/dist/src/agentComponent.d.ts +18 -0
  3. package/dist/src/agentComponent.js +55 -0
  4. package/dist/src/agentComponent.js.map +1 -0
  5. package/dist/src/agentStateSet.d.ts +48 -0
  6. package/dist/src/agentStateSet.js +66 -0
  7. package/dist/src/agentStateSet.js.map +1 -0
  8. package/dist/src/choices/choice.d.ts +14 -0
  9. package/dist/src/choices/choice.js +7 -0
  10. package/dist/src/choices/choice.js.map +1 -0
  11. package/dist/src/choices/choiceFactory.d.ts +81 -0
  12. package/dist/src/choices/choiceFactory.js +133 -0
  13. package/dist/src/choices/choiceFactory.js.map +1 -0
  14. package/dist/src/choices/findChoices.d.ts +28 -0
  15. package/dist/src/choices/findChoices.js +46 -0
  16. package/dist/src/choices/findChoices.js.map +1 -0
  17. package/dist/src/choices/findValues.d.ts +36 -0
  18. package/dist/src/choices/findValues.js +129 -0
  19. package/dist/src/choices/findValues.js.map +1 -0
  20. package/dist/src/choices/index.d.ts +11 -0
  21. package/dist/src/choices/index.js +28 -0
  22. package/dist/src/choices/index.js.map +1 -0
  23. package/dist/src/choices/modelResult.d.ts +11 -0
  24. package/dist/src/choices/modelResult.js +3 -0
  25. package/dist/src/choices/modelResult.js.map +1 -0
  26. package/dist/src/choices/recognizeChoices.d.ts +16 -0
  27. package/dist/src/choices/recognizeChoices.js +81 -0
  28. package/dist/src/choices/recognizeChoices.js.map +1 -0
  29. package/dist/src/choices/tokenizer.d.ts +25 -0
  30. package/dist/src/choices/tokenizer.js +73 -0
  31. package/dist/src/choices/tokenizer.js.map +1 -0
  32. package/dist/src/componentDialog.d.ts +178 -0
  33. package/dist/src/componentDialog.js +252 -0
  34. package/dist/src/componentDialog.js.map +1 -0
  35. package/dist/src/componentRegistration.d.ts +22 -0
  36. package/dist/src/componentRegistration.js +32 -0
  37. package/dist/src/componentRegistration.js.map +1 -0
  38. package/dist/src/configurable.d.ts +22 -0
  39. package/dist/src/configurable.js +60 -0
  40. package/dist/src/configurable.js.map +1 -0
  41. package/dist/src/configuration.d.ts +11 -0
  42. package/dist/src/configuration.js +17 -0
  43. package/dist/src/configuration.js.map +1 -0
  44. package/dist/src/converter.d.ts +13 -0
  45. package/dist/src/converter.js +7 -0
  46. package/dist/src/converter.js.map +1 -0
  47. package/dist/src/dialog.d.ts +184 -0
  48. package/dist/src/dialog.js +201 -0
  49. package/dist/src/dialog.js.map +1 -0
  50. package/dist/src/dialogContainer.d.ts +61 -0
  51. package/dist/src/dialogContainer.js +82 -0
  52. package/dist/src/dialogContainer.js.map +1 -0
  53. package/dist/src/dialogContext.d.ts +272 -0
  54. package/dist/src/dialogContext.js +444 -0
  55. package/dist/src/dialogContext.js.map +1 -0
  56. package/dist/src/dialogContextError.d.ts +27 -0
  57. package/dist/src/dialogContextError.js +39 -0
  58. package/dist/src/dialogContextError.js.map +1 -0
  59. package/dist/src/dialogEvent.d.ts +20 -0
  60. package/dist/src/dialogEvent.js +3 -0
  61. package/dist/src/dialogEvent.js.map +1 -0
  62. package/dist/src/dialogEvents.d.ts +15 -0
  63. package/dist/src/dialogEvents.js +20 -0
  64. package/dist/src/dialogEvents.js.map +1 -0
  65. package/dist/src/dialogHelper.d.ts +32 -0
  66. package/dist/src/dialogHelper.js +116 -0
  67. package/dist/src/dialogHelper.js.map +1 -0
  68. package/dist/src/dialogInstance.d.ts +30 -0
  69. package/dist/src/dialogInstance.js +3 -0
  70. package/dist/src/dialogInstance.js.map +1 -0
  71. package/dist/src/dialogManager.d.ts +73 -0
  72. package/dist/src/dialogManager.js +156 -0
  73. package/dist/src/dialogManager.js.map +1 -0
  74. package/dist/src/dialogReason.d.ts +35 -0
  75. package/dist/src/dialogReason.js +40 -0
  76. package/dist/src/dialogReason.js.map +1 -0
  77. package/dist/src/dialogSet.d.ts +85 -0
  78. package/dist/src/dialogSet.js +138 -0
  79. package/dist/src/dialogSet.js.map +1 -0
  80. package/dist/src/dialogTurnResult.d.ts +34 -0
  81. package/dist/src/dialogTurnResult.js +3 -0
  82. package/dist/src/dialogTurnResult.js.map +1 -0
  83. package/dist/src/dialogTurnStateConstants.d.ts +12 -0
  84. package/dist/src/dialogTurnStateConstants.js +17 -0
  85. package/dist/src/dialogTurnStateConstants.js.map +1 -0
  86. package/dist/src/dialogTurnStatus.d.ts +34 -0
  87. package/dist/src/dialogTurnStatus.js +39 -0
  88. package/dist/src/dialogTurnStatus.js.map +1 -0
  89. package/dist/src/dialogsAgentComponent.d.ts +17 -0
  90. package/dist/src/dialogsAgentComponent.js +65 -0
  91. package/dist/src/dialogsAgentComponent.js.map +1 -0
  92. package/dist/src/dialogsComponentRegistration.d.ts +28 -0
  93. package/dist/src/dialogsComponentRegistration.js +45 -0
  94. package/dist/src/dialogsComponentRegistration.js.map +1 -0
  95. package/dist/src/i18n.d.ts +15 -0
  96. package/dist/src/i18n.js +28 -0
  97. package/dist/src/i18n.js.map +1 -0
  98. package/dist/src/index.d.ts +29 -0
  99. package/dist/src/index.js +48 -0
  100. package/dist/src/index.js.map +1 -0
  101. package/dist/src/intentScore.d.ts +11 -0
  102. package/dist/src/intentScore.js +3 -0
  103. package/dist/src/intentScore.js.map +1 -0
  104. package/dist/src/memory/componentMemoryScopes.d.ts +18 -0
  105. package/dist/src/memory/componentMemoryScopes.js +54 -0
  106. package/dist/src/memory/componentMemoryScopes.js.map +1 -0
  107. package/dist/src/memory/componentPathResolvers.d.ts +18 -0
  108. package/dist/src/memory/componentPathResolvers.js +52 -0
  109. package/dist/src/memory/componentPathResolvers.js.map +1 -0
  110. package/dist/src/memory/dialogPath.d.ts +17 -0
  111. package/dist/src/memory/dialogPath.js +30 -0
  112. package/dist/src/memory/dialogPath.js.map +1 -0
  113. package/dist/src/memory/dialogStateManager.d.ts +156 -0
  114. package/dist/src/memory/dialogStateManager.js +598 -0
  115. package/dist/src/memory/dialogStateManager.js.map +1 -0
  116. package/dist/src/memory/index.d.ts +12 -0
  117. package/dist/src/memory/index.js +29 -0
  118. package/dist/src/memory/index.js.map +1 -0
  119. package/dist/src/memory/pathResolvers/aliasPathResolver.d.ts +25 -0
  120. package/dist/src/memory/pathResolvers/aliasPathResolver.js +37 -0
  121. package/dist/src/memory/pathResolvers/aliasPathResolver.js.map +1 -0
  122. package/dist/src/memory/pathResolvers/atAtPathResolver.d.ts +11 -0
  123. package/dist/src/memory/pathResolvers/atAtPathResolver.js +18 -0
  124. package/dist/src/memory/pathResolvers/atAtPathResolver.js.map +1 -0
  125. package/dist/src/memory/pathResolvers/atPathResolver.d.ts +20 -0
  126. package/dist/src/memory/pathResolvers/atPathResolver.js +46 -0
  127. package/dist/src/memory/pathResolvers/atPathResolver.js.map +1 -0
  128. package/dist/src/memory/pathResolvers/dollarPathResolver.d.ts +11 -0
  129. package/dist/src/memory/pathResolvers/dollarPathResolver.js +18 -0
  130. package/dist/src/memory/pathResolvers/dollarPathResolver.js.map +1 -0
  131. package/dist/src/memory/pathResolvers/hashPathResolver.d.ts +11 -0
  132. package/dist/src/memory/pathResolvers/hashPathResolver.js +18 -0
  133. package/dist/src/memory/pathResolvers/hashPathResolver.js.map +1 -0
  134. package/dist/src/memory/pathResolvers/index.d.ts +11 -0
  135. package/dist/src/memory/pathResolvers/index.js +28 -0
  136. package/dist/src/memory/pathResolvers/index.js.map +1 -0
  137. package/dist/src/memory/pathResolvers/pathResolver.d.ts +13 -0
  138. package/dist/src/memory/pathResolvers/pathResolver.js +7 -0
  139. package/dist/src/memory/pathResolvers/pathResolver.js.map +1 -0
  140. package/dist/src/memory/pathResolvers/percentPathResolver.d.ts +11 -0
  141. package/dist/src/memory/pathResolvers/percentPathResolver.js +18 -0
  142. package/dist/src/memory/pathResolvers/percentPathResolver.js.map +1 -0
  143. package/dist/src/memory/scopePath.d.ts +18 -0
  144. package/dist/src/memory/scopePath.js +23 -0
  145. package/dist/src/memory/scopePath.js.map +1 -0
  146. package/dist/src/memory/scopes/agentStateMemoryScope.d.ts +53 -0
  147. package/dist/src/memory/scopes/agentStateMemoryScope.js +82 -0
  148. package/dist/src/memory/scopes/agentStateMemoryScope.js.map +1 -0
  149. package/dist/src/memory/scopes/classMemoryScope.d.ts +29 -0
  150. package/dist/src/memory/scopes/classMemoryScope.js +65 -0
  151. package/dist/src/memory/scopes/classMemoryScope.js.map +1 -0
  152. package/dist/src/memory/scopes/conversationMemoryScope.d.ts +15 -0
  153. package/dist/src/memory/scopes/conversationMemoryScope.js +23 -0
  154. package/dist/src/memory/scopes/conversationMemoryScope.js.map +1 -0
  155. package/dist/src/memory/scopes/dialogClassMemoryScope.d.ts +19 -0
  156. package/dist/src/memory/scopes/dialogClassMemoryScope.js +42 -0
  157. package/dist/src/memory/scopes/dialogClassMemoryScope.js.map +1 -0
  158. package/dist/src/memory/scopes/dialogContextMemoryScope.d.ts +19 -0
  159. package/dist/src/memory/scopes/dialogContextMemoryScope.js +48 -0
  160. package/dist/src/memory/scopes/dialogContextMemoryScope.js.map +1 -0
  161. package/dist/src/memory/scopes/dialogMemoryScope.d.ts +32 -0
  162. package/dist/src/memory/scopes/dialogMemoryScope.js +74 -0
  163. package/dist/src/memory/scopes/dialogMemoryScope.js.map +1 -0
  164. package/dist/src/memory/scopes/index.d.ts +15 -0
  165. package/dist/src/memory/scopes/index.js +32 -0
  166. package/dist/src/memory/scopes/index.js.map +1 -0
  167. package/dist/src/memory/scopes/memoryScope.d.ts +52 -0
  168. package/dist/src/memory/scopes/memoryScope.js +54 -0
  169. package/dist/src/memory/scopes/memoryScope.js.map +1 -0
  170. package/dist/src/memory/scopes/settingsMemoryScope.d.ts +68 -0
  171. package/dist/src/memory/scopes/settingsMemoryScope.js +216 -0
  172. package/dist/src/memory/scopes/settingsMemoryScope.js.map +1 -0
  173. package/dist/src/memory/scopes/thisMemoryScope.d.ts +26 -0
  174. package/dist/src/memory/scopes/thisMemoryScope.js +43 -0
  175. package/dist/src/memory/scopes/thisMemoryScope.js.map +1 -0
  176. package/dist/src/memory/scopes/turnMemoryScope.d.ts +29 -0
  177. package/dist/src/memory/scopes/turnMemoryScope.js +52 -0
  178. package/dist/src/memory/scopes/turnMemoryScope.js.map +1 -0
  179. package/dist/src/memory/scopes/userMemoryScope.d.ts +15 -0
  180. package/dist/src/memory/scopes/userMemoryScope.js +23 -0
  181. package/dist/src/memory/scopes/userMemoryScope.js.map +1 -0
  182. package/dist/src/memory/turnPath.d.ts +21 -0
  183. package/dist/src/memory/turnPath.js +38 -0
  184. package/dist/src/memory/turnPath.js.map +1 -0
  185. package/dist/src/prompts/activityPrompt.d.ts +101 -0
  186. package/dist/src/prompts/activityPrompt.js +166 -0
  187. package/dist/src/prompts/activityPrompt.js.map +1 -0
  188. package/dist/src/prompts/attachmentPrompt.d.ts +37 -0
  189. package/dist/src/prompts/attachmentPrompt.js +55 -0
  190. package/dist/src/prompts/attachmentPrompt.js.map +1 -0
  191. package/dist/src/prompts/choicePrompt.d.ts +83 -0
  192. package/dist/src/prompts/choicePrompt.js +116 -0
  193. package/dist/src/prompts/choicePrompt.js.map +1 -0
  194. package/dist/src/prompts/confirmPrompt.d.ts +82 -0
  195. package/dist/src/prompts/confirmPrompt.js +163 -0
  196. package/dist/src/prompts/confirmPrompt.js.map +1 -0
  197. package/dist/src/prompts/datetimePrompt.d.ts +65 -0
  198. package/dist/src/prompts/datetimePrompt.js +109 -0
  199. package/dist/src/prompts/datetimePrompt.js.map +1 -0
  200. package/dist/src/prompts/index.d.ts +13 -0
  201. package/dist/src/prompts/index.js +30 -0
  202. package/dist/src/prompts/index.js.map +1 -0
  203. package/dist/src/prompts/numberPrompt.d.ts +55 -0
  204. package/dist/src/prompts/numberPrompt.js +134 -0
  205. package/dist/src/prompts/numberPrompt.js.map +1 -0
  206. package/dist/src/prompts/prompt.d.ts +256 -0
  207. package/dist/src/prompts/prompt.js +260 -0
  208. package/dist/src/prompts/prompt.js.map +1 -0
  209. package/dist/src/prompts/promptCultureModels.d.ts +72 -0
  210. package/dist/src/prompts/promptCultureModels.js +123 -0
  211. package/dist/src/prompts/promptCultureModels.js.map +1 -0
  212. package/dist/src/prompts/textPrompt.d.ts +54 -0
  213. package/dist/src/prompts/textPrompt.js +72 -0
  214. package/dist/src/prompts/textPrompt.js.map +1 -0
  215. package/dist/src/recognizer.d.ts +43 -0
  216. package/dist/src/recognizer.js +104 -0
  217. package/dist/src/recognizer.js.map +1 -0
  218. package/dist/src/recognizerResult.d.ts +19 -0
  219. package/dist/src/recognizerResult.js +24 -0
  220. package/dist/src/recognizerResult.js.map +1 -0
  221. package/dist/src/serviceCollection.d.ts +112 -0
  222. package/dist/src/serviceCollection.js +209 -0
  223. package/dist/src/serviceCollection.js.map +1 -0
  224. package/dist/src/stringUtils.d.ts +36 -0
  225. package/dist/src/stringUtils.js +62 -0
  226. package/dist/src/stringUtils.js.map +1 -0
  227. package/dist/src/template.d.ts +18 -0
  228. package/dist/src/template.js +7 -0
  229. package/dist/src/template.js.map +1 -0
  230. package/dist/src/waterfallDialog.d.ts +101 -0
  231. package/dist/src/waterfallDialog.js +179 -0
  232. package/dist/src/waterfallDialog.js.map +1 -0
  233. package/dist/src/waterfallStepContext.d.ts +71 -0
  234. package/dist/src/waterfallStepContext.js +78 -0
  235. package/dist/src/waterfallStepContext.js.map +1 -0
  236. package/package.json +49 -0
  237. package/src/agentComponent.ts +23 -0
  238. package/src/agentStateSet.ts +75 -0
  239. package/src/choices/choice.ts +16 -0
  240. package/src/choices/choiceFactory.ts +189 -0
  241. package/src/choices/findChoices.ts +70 -0
  242. package/src/choices/findValues.ts +179 -0
  243. package/src/choices/index.ts +11 -0
  244. package/src/choices/modelResult.ts +11 -0
  245. package/src/choices/recognizeChoices.ts +94 -0
  246. package/src/choices/tokenizer.ts +93 -0
  247. package/src/componentDialog.ts +306 -0
  248. package/src/componentRegistration.ts +30 -0
  249. package/src/configurable.ts +55 -0
  250. package/src/configuration.ts +22 -0
  251. package/src/converter.ts +15 -0
  252. package/src/dialog.ts +243 -0
  253. package/src/dialogContainer.ts +90 -0
  254. package/src/dialogContext.ts +607 -0
  255. package/src/dialogContextError.ts +50 -0
  256. package/src/dialogEvent.ts +23 -0
  257. package/src/dialogEvents.ts +16 -0
  258. package/src/dialogHelper.ts +154 -0
  259. package/src/dialogInstance.ts +32 -0
  260. package/src/dialogManager.ts +202 -0
  261. package/src/dialogReason.ts +40 -0
  262. package/src/dialogSet.ts +168 -0
  263. package/src/dialogTurnResult.ts +37 -0
  264. package/src/dialogTurnStateConstants.ts +13 -0
  265. package/src/dialogTurnStatus.ts +38 -0
  266. package/src/dialogsAgentComponent.ts +71 -0
  267. package/src/dialogsComponentRegistration.ts +49 -0
  268. package/src/i18n.ts +17 -0
  269. package/src/index.ts +31 -0
  270. package/src/intentScore.ts +11 -0
  271. package/src/memory/componentMemoryScopes.ts +28 -0
  272. package/src/memory/componentPathResolvers.ts +29 -0
  273. package/src/memory/dialogPath.ts +33 -0
  274. package/src/memory/dialogStateManager.ts +661 -0
  275. package/src/memory/index.ts +12 -0
  276. package/src/memory/pathResolvers/aliasPathResolver.ts +44 -0
  277. package/src/memory/pathResolvers/atAtPathResolver.ts +14 -0
  278. package/src/memory/pathResolvers/atPathResolver.ts +45 -0
  279. package/src/memory/pathResolvers/dollarPathResolver.ts +14 -0
  280. package/src/memory/pathResolvers/hashPathResolver.ts +14 -0
  281. package/src/memory/pathResolvers/index.ts +11 -0
  282. package/src/memory/pathResolvers/pathResolver.ts +14 -0
  283. package/src/memory/pathResolvers/percentPathResolver.ts +14 -0
  284. package/src/memory/scopePath.ts +19 -0
  285. package/src/memory/scopes/agentStateMemoryScope.ts +92 -0
  286. package/src/memory/scopes/classMemoryScope.ts +71 -0
  287. package/src/memory/scopes/conversationMemoryScope.ts +19 -0
  288. package/src/memory/scopes/dialogClassMemoryScope.ts +43 -0
  289. package/src/memory/scopes/dialogContextMemoryScope.ts +51 -0
  290. package/src/memory/scopes/dialogMemoryScope.ts +79 -0
  291. package/src/memory/scopes/index.ts +15 -0
  292. package/src/memory/scopes/memoryScope.ts +70 -0
  293. package/src/memory/scopes/settingsMemoryScope.ts +239 -0
  294. package/src/memory/scopes/thisMemoryScope.ts +44 -0
  295. package/src/memory/scopes/turnMemoryScope.ts +54 -0
  296. package/src/memory/scopes/userMemoryScope.ts +19 -0
  297. package/src/memory/turnPath.ts +45 -0
  298. package/src/prompts/activityPrompt.ts +202 -0
  299. package/src/prompts/attachmentPrompt.ts +62 -0
  300. package/src/prompts/choicePrompt.ts +176 -0
  301. package/src/prompts/confirmPrompt.ts +182 -0
  302. package/src/prompts/datetimePrompt.ts +110 -0
  303. package/src/prompts/index.ts +13 -0
  304. package/src/prompts/numberPrompt.ts +117 -0
  305. package/src/prompts/prompt.ts +459 -0
  306. package/src/prompts/promptCultureModels.ts +178 -0
  307. package/src/prompts/textPrompt.ts +82 -0
  308. package/src/recognizer.ts +127 -0
  309. package/src/recognizerResult.ts +37 -0
  310. package/src/serviceCollection.ts +305 -0
  311. package/src/stringUtils.ts +62 -0
  312. package/src/template.ts +20 -0
  313. package/src/waterfallDialog.ts +215 -0
  314. package/src/waterfallStepContext.ts +96 -0
  315. package/vendor/cldr-data/README.md +5 -0
  316. package/vendor/cldr-data/main/de/numbers.json +156 -0
  317. package/vendor/cldr-data/main/en/numbers.json +159 -0
  318. package/vendor/cldr-data/main/es/numbers.json +156 -0
  319. package/vendor/cldr-data/main/fr/numbers.json +157 -0
  320. package/vendor/cldr-data/main/ja/numbers.json +120 -0
  321. package/vendor/cldr-data/main/nl/numbers.json +156 -0
  322. package/vendor/cldr-data/main/pt/numbers.json +156 -0
  323. package/vendor/cldr-data/main/zh/numbers.json +214 -0
  324. package/vendor/cldr-data/supplemental/likelySubtags.json +1844 -0
  325. package/vendor/cldr-data/supplemental/numberingSystems.json +343 -0
@@ -0,0 +1,256 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { Activity, TurnContext } from '@microsoft/agents-hosting';
6
+ import { Choice, ChoiceFactoryOptions } from '../choices';
7
+ import { Dialog } from '../dialog';
8
+ import { DialogContext } from '../dialogContext';
9
+ import { DialogInstance } from '../dialogInstance';
10
+ import { DialogTurnResult } from '../dialogTurnResult';
11
+ import { DialogReason } from '../dialogReason';
12
+ import { DialogEvent } from '../dialogEvent';
13
+ /**
14
+ * Controls the way that choices for a `ChoicePrompt` or yes/no options for a `ConfirmPrompt` are
15
+ * presented to a user.
16
+ */
17
+ export declare enum ListStyle {
18
+ /**
19
+ * Don't include any choices for prompt.
20
+ */
21
+ none = 0,
22
+ /**
23
+ * Automatically select the appropriate style for the current channel.
24
+ */
25
+ auto = 1,
26
+ /**
27
+ * Add choices to prompt as an inline list.
28
+ */
29
+ inline = 2,
30
+ /**
31
+ * Add choices to prompt as a numbered list.
32
+ */
33
+ list = 3,
34
+ /**
35
+ * Add choices to prompt as suggested actions.
36
+ */
37
+ suggestedAction = 4,
38
+ /**
39
+ * Add choices to prompt as a HeroCard with buttons.
40
+ */
41
+ heroCard = 5
42
+ }
43
+ /**
44
+ * Basic configuration options supported by all prompts.
45
+ */
46
+ export interface PromptOptions {
47
+ /**
48
+ * (Optional) Initial prompt to send the user.
49
+ */
50
+ prompt?: string | Activity;
51
+ /**
52
+ * (Optional) Retry prompt to send the user.
53
+ */
54
+ retryPrompt?: string | Activity;
55
+ /**
56
+ * (Optional) List of choices associated with the prompt.
57
+ */
58
+ choices?: (string | Choice)[];
59
+ /**
60
+ * (Optional) Property that can be used to override or set the value of ChoicePrompt.Style
61
+ * when the prompt is executed using DialogContext.prompt.
62
+ */
63
+ style?: ListStyle;
64
+ /**
65
+ * (Optional) Additional validation rules to pass the prompts validator routine.
66
+ */
67
+ validations?: object;
68
+ /**
69
+ * The locale to be use for recognizing the utterance.
70
+ */
71
+ recognizeLanguage?: string;
72
+ }
73
+ /**
74
+ * Result returned by a prompts recognizer function.
75
+ *
76
+ * @param T Type of value being recognized.
77
+ */
78
+ export interface PromptRecognizerResult<T> {
79
+ /**
80
+ * If `true` the users utterance was successfully recognized and [value](#value) contains the
81
+ * recognized result.
82
+ */
83
+ succeeded: boolean;
84
+ /**
85
+ * Value that was recognized if [succeeded](#succeeded) is `true`.
86
+ */
87
+ value?: T;
88
+ }
89
+ /**
90
+ * Function signature for providing a custom prompt validator.
91
+ *
92
+ * ```TypeScript
93
+ * type PromptValidator<T> = (prompt: PromptValidatorContext<T>) => Promise<boolean>;
94
+ * ```
95
+ *
96
+ * @remarks
97
+ * The validator should be an asynchronous function that returns `true` if
98
+ * `prompt.recognized.value` is valid and the prompt should end.
99
+ *
100
+ * > [!NOTE]
101
+ * > If the validator returns `false` the prompts default re-prompt logic will be run unless the
102
+ * > validator sends a custom re-prompt to the user using `prompt.context.sendActivity()`. In that
103
+ * > case the prompts default re-rpompt logic will not be run.
104
+ * @param T Type of recognizer result being validated.
105
+ * @param PromptValidator.prompt Contextual information containing the recognizer result and original options passed to the prompt.
106
+ */
107
+ export type PromptValidator<T> = (prompt: PromptValidatorContext<T>) => Promise<boolean>;
108
+ /**
109
+ * Contextual information passed to a custom `PromptValidator`.
110
+ *
111
+ * @param T Type of recognizer result being validated.
112
+ */
113
+ export interface PromptValidatorContext<T> {
114
+ /**
115
+ * The context for the current turn of conversation with the user.
116
+ *
117
+ * @remarks
118
+ * The validator can use this to re-prompt the user.
119
+ */
120
+ readonly context: TurnContext;
121
+ /**
122
+ * Result returned from the prompts recognizer function.
123
+ *
124
+ * @remarks
125
+ * The `prompt.recognized.succeeded` field can be checked to determine of the recognizer found
126
+ * anything and then the value can be retrieved from `prompt.recognized.value`.
127
+ */
128
+ readonly recognized: PromptRecognizerResult<T>;
129
+ /**
130
+ * A dictionary of values persisted for each conversational turn while the prompt is active.
131
+ *
132
+ * @remarks
133
+ * The validator can use this to persist things like turn counts or other state information.
134
+ */
135
+ readonly state: object;
136
+ /**
137
+ * Original set of options passed to the prompt by the calling dialog.
138
+ *
139
+ * @remarks
140
+ * The validator can extend this interface to support additional prompt options.
141
+ */
142
+ readonly options: PromptOptions;
143
+ /**
144
+ * A count of the number of times the prompt has been executed.
145
+ *
146
+ * A number indicating how many times the prompt was invoked (starting at 1 for the first time it was invoked).
147
+ */
148
+ readonly attemptCount: number;
149
+ }
150
+ /**
151
+ * Base class for all prompts.
152
+ *
153
+ * @param T Type of value being returned by the prompts recognizer function.
154
+ */
155
+ export declare abstract class Prompt<T> extends Dialog {
156
+ private validator?;
157
+ /**
158
+ * Creates a new Prompt instance.
159
+ *
160
+ * @param dialogId Unique ID of the prompt within its parent `DialogSet` or `ComponentDialog`.
161
+ * @param validator (Optional) custom validator used to provide additional validation and re-prompting logic for the prompt.
162
+ */
163
+ protected constructor(dialogId: string, validator?: PromptValidator<T>);
164
+ /**
165
+ * Called when a prompt dialog is pushed onto the dialog stack and is being activated.
166
+ *
167
+ * @param dialogContext The DialogContext for the current
168
+ * turn of the conversation.
169
+ * @param options Optional. PromptOptions,
170
+ * additional information to pass to the prompt being started.
171
+ * @returns A `Promise` representing the asynchronous operation.
172
+ * @remarks
173
+ * If the task is successful, the result indicates whether the prompt is still
174
+ * active after the turn has been processed by the prompt.
175
+ */
176
+ beginDialog(dialogContext: DialogContext, options: PromptOptions): Promise<DialogTurnResult>;
177
+ /**
178
+ * Called when a prompt dialog is the active dialog and the user replied with a new activity.
179
+ *
180
+ * @param dialogContext The DialogContext for the current turn of conversation.
181
+ * @returns A `Promise` representing the asynchronous operation.
182
+ * @remarks
183
+ * If the task is successful, the result indicates whether the dialog is still
184
+ * active after the turn has been processed by the dialog.
185
+ * The prompt generally continues to receive the user's replies until it accepts the
186
+ * user's reply as valid input for the prompt.
187
+ */
188
+ continueDialog(dialogContext: DialogContext): Promise<DialogTurnResult>;
189
+ /**
190
+ * Called before an event is bubbled to its parent.
191
+ *
192
+ * @param dialogContext The DialogContext for the current turn of conversation.
193
+ * @param event DialogEvent, the event being raised.
194
+ * @returns Whether the event is handled by the current dialog and further processing should stop.
195
+ * @remarks
196
+ * This is a good place to perform interception of an event as returning `true` will prevent
197
+ * any further bubbling of the event to the dialogs parents and will also prevent any child
198
+ * dialogs from performing their default processing.
199
+ */
200
+ protected onPreBubbleEvent(dialogContext: DialogContext, event: DialogEvent): Promise<boolean>;
201
+ /**
202
+ * Called when a prompt dialog resumes being the active dialog on the dialog stack, such as
203
+ * when the previous active dialog on the stack completes.
204
+ *
205
+ * @param dialogContext The DialogContext for the current turn of the conversation.
206
+ * @param _reason An enum indicating why the dialog resumed.
207
+ * @param _result Optional, value returned from the previous dialog on the stack.
208
+ * The type of the value returned is dependent on the previous dialog.
209
+ * @returns A Promise representing the asynchronous operation.
210
+ * @remarks
211
+ * If the task is successful, the result indicates whether the dialog is still
212
+ * active after the turn has been processed by the dialog.
213
+ */
214
+ resumeDialog(dialogContext: DialogContext, _reason: DialogReason, _result?: any): Promise<DialogTurnResult>;
215
+ /**
216
+ * Called when a prompt dialog has been requested to re-prompt the user for input.
217
+ *
218
+ * @param context TurnContext, context for the current
219
+ * turn of conversation with the user.
220
+ * @param instance DialogInstance, the instance
221
+ * of the dialog on the stack.
222
+ * @returns A `Promise` representing the asynchronous operation.
223
+ */
224
+ repromptDialog(context: TurnContext, instance: DialogInstance): Promise<void>;
225
+ /**
226
+ * Called anytime the derived class should send the user a prompt.
227
+ *
228
+ * @param context Context for the current turn of conversation with the user.
229
+ * @param state Additional state being persisted for the prompt.
230
+ * @param options Options that the prompt was started with in the call to `DialogContext.prompt()`.
231
+ * @param isRetry If `true` the users response wasn't recognized and the re-prompt should be sent.
232
+ */
233
+ protected abstract onPrompt(context: TurnContext, state: object, options: PromptOptions, isRetry: boolean): Promise<void>;
234
+ /**
235
+ * Called to recognize an utterance received from the user.
236
+ *
237
+ * @remarks
238
+ * The Prompt class filters out non-message activities so its safe to assume that the users
239
+ * utterance can be retrieved from `context.activity.text`.
240
+ * @param context Context for the current turn of conversation with the user.
241
+ * @param state Additional state being persisted for the prompt.
242
+ * @param options Options that the prompt was started with in the call to `DialogContext.prompt()`.
243
+ */
244
+ protected abstract onRecognize(context: TurnContext, state: object, options: PromptOptions): Promise<PromptRecognizerResult<T>>;
245
+ /**
246
+ * Helper function to compose an output activity containing a set of choices.
247
+ *
248
+ * @param prompt The prompt to append the users choices to.
249
+ * @param channelId ID of the channel the prompt is being sent to.
250
+ * @param choices List of choices to append.
251
+ * @param style Configured style for the list of choices.
252
+ * @param options (Optional) options to configure the underlying ChoiceFactory call.
253
+ * @returns The composed activity ready to send to the user.
254
+ */
255
+ protected appendChoices(prompt: string | Activity, channelId: string, choices: (string | Choice)[], style: ListStyle, options?: ChoiceFactoryOptions): Activity;
256
+ }
@@ -0,0 +1,260 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Prompt = exports.ListStyle = void 0;
4
+ /**
5
+ * Copyright (c) Microsoft Corporation. All rights reserved.
6
+ * Licensed under the MIT License.
7
+ */
8
+ const agents_hosting_1 = require("@microsoft/agents-hosting");
9
+ const choices_1 = require("../choices");
10
+ const dialog_1 = require("../dialog");
11
+ /**
12
+ * Controls the way that choices for a `ChoicePrompt` or yes/no options for a `ConfirmPrompt` are
13
+ * presented to a user.
14
+ */
15
+ var ListStyle;
16
+ (function (ListStyle) {
17
+ /**
18
+ * Don't include any choices for prompt.
19
+ */
20
+ ListStyle[ListStyle["none"] = 0] = "none";
21
+ /**
22
+ * Automatically select the appropriate style for the current channel.
23
+ */
24
+ ListStyle[ListStyle["auto"] = 1] = "auto";
25
+ /**
26
+ * Add choices to prompt as an inline list.
27
+ */
28
+ ListStyle[ListStyle["inline"] = 2] = "inline";
29
+ /**
30
+ * Add choices to prompt as a numbered list.
31
+ */
32
+ ListStyle[ListStyle["list"] = 3] = "list";
33
+ /**
34
+ * Add choices to prompt as suggested actions.
35
+ */
36
+ ListStyle[ListStyle["suggestedAction"] = 4] = "suggestedAction";
37
+ /**
38
+ * Add choices to prompt as a HeroCard with buttons.
39
+ */
40
+ ListStyle[ListStyle["heroCard"] = 5] = "heroCard";
41
+ })(ListStyle || (exports.ListStyle = ListStyle = {}));
42
+ /**
43
+ * Base class for all prompts.
44
+ *
45
+ * @param T Type of value being returned by the prompts recognizer function.
46
+ */
47
+ class Prompt extends dialog_1.Dialog {
48
+ /**
49
+ * Creates a new Prompt instance.
50
+ *
51
+ * @param dialogId Unique ID of the prompt within its parent `DialogSet` or `ComponentDialog`.
52
+ * @param validator (Optional) custom validator used to provide additional validation and re-prompting logic for the prompt.
53
+ */
54
+ constructor(dialogId, validator) {
55
+ super(dialogId);
56
+ this.validator = validator;
57
+ }
58
+ /**
59
+ * Called when a prompt dialog is pushed onto the dialog stack and is being activated.
60
+ *
61
+ * @param dialogContext The DialogContext for the current
62
+ * turn of the conversation.
63
+ * @param options Optional. PromptOptions,
64
+ * additional information to pass to the prompt being started.
65
+ * @returns A `Promise` representing the asynchronous operation.
66
+ * @remarks
67
+ * If the task is successful, the result indicates whether the prompt is still
68
+ * active after the turn has been processed by the prompt.
69
+ */
70
+ async beginDialog(dialogContext, options) {
71
+ // Ensure prompts have input hint set
72
+ const opt = { ...options };
73
+ if (opt.prompt && typeof opt.prompt === 'object' && typeof opt.prompt.inputHint !== 'string') {
74
+ opt.prompt.inputHint = agents_hosting_1.InputHints.ExpectingInput;
75
+ }
76
+ if (opt.retryPrompt && typeof opt.retryPrompt === 'object' && typeof opt.retryPrompt.inputHint !== 'string') {
77
+ opt.retryPrompt.inputHint = agents_hosting_1.InputHints.ExpectingInput;
78
+ }
79
+ // Initialize prompt state
80
+ const state = dialogContext.activeDialog.state;
81
+ state.options = opt;
82
+ state.state = {};
83
+ // Send initial prompt
84
+ await this.onPrompt(dialogContext.context, state.state, state.options, false);
85
+ return dialog_1.Dialog.EndOfTurn;
86
+ }
87
+ /**
88
+ * Called when a prompt dialog is the active dialog and the user replied with a new activity.
89
+ *
90
+ * @param dialogContext The DialogContext for the current turn of conversation.
91
+ * @returns A `Promise` representing the asynchronous operation.
92
+ * @remarks
93
+ * If the task is successful, the result indicates whether the dialog is still
94
+ * active after the turn has been processed by the dialog.
95
+ * The prompt generally continues to receive the user's replies until it accepts the
96
+ * user's reply as valid input for the prompt.
97
+ */
98
+ async continueDialog(dialogContext) {
99
+ // Don't do anything for non-message activities
100
+ if (dialogContext.context.activity.type !== agents_hosting_1.ActivityTypes.Message) {
101
+ return dialog_1.Dialog.EndOfTurn;
102
+ }
103
+ // Are we being continued after an interruption?
104
+ // - The stepCount will be 1 or more if we're running in the context of an AdaptiveDialog
105
+ // and we're coming back from an interruption.
106
+ const stepCount = dialogContext.state.getValue('turn.stepCount');
107
+ if (typeof stepCount === 'number' && stepCount > 0) {
108
+ // re-prompt and then end
109
+ await this.repromptDialog(dialogContext.context, dialogContext.activeDialog);
110
+ return dialog_1.Dialog.EndOfTurn;
111
+ }
112
+ // Perform base recognition
113
+ const state = dialogContext.activeDialog.state;
114
+ const recognized = await this.onRecognize(dialogContext.context, state.state, state.options);
115
+ // Validate the return value
116
+ let isValid = false;
117
+ if (this.validator) {
118
+ if (state.state['attemptCount'] === undefined) {
119
+ state.state['attemptCount'] = 0;
120
+ }
121
+ isValid = await this.validator({
122
+ context: dialogContext.context,
123
+ recognized,
124
+ state: state.state,
125
+ options: state.options,
126
+ attemptCount: ++state.state['attemptCount'],
127
+ });
128
+ }
129
+ else if (recognized.succeeded) {
130
+ isValid = true;
131
+ }
132
+ // Return recognized value or re-prompt
133
+ if (isValid) {
134
+ return await dialogContext.endDialog(recognized.value);
135
+ }
136
+ else {
137
+ if (!dialogContext.context.responded) {
138
+ await this.onPrompt(dialogContext.context, state.state, state.options, true);
139
+ }
140
+ return dialog_1.Dialog.EndOfTurn;
141
+ }
142
+ }
143
+ /**
144
+ * Called before an event is bubbled to its parent.
145
+ *
146
+ * @param dialogContext The DialogContext for the current turn of conversation.
147
+ * @param event DialogEvent, the event being raised.
148
+ * @returns Whether the event is handled by the current dialog and further processing should stop.
149
+ * @remarks
150
+ * This is a good place to perform interception of an event as returning `true` will prevent
151
+ * any further bubbling of the event to the dialogs parents and will also prevent any child
152
+ * dialogs from performing their default processing.
153
+ */
154
+ async onPreBubbleEvent(dialogContext, event) {
155
+ if (event.name === 'activityReceived' && dialogContext.context.activity.type === agents_hosting_1.ActivityTypes.Message) {
156
+ // Perform base recognition
157
+ const state = dialogContext.activeDialog.state;
158
+ const recognized = await this.onRecognize(dialogContext.context, state.state, state.options);
159
+ return recognized.succeeded;
160
+ }
161
+ return false;
162
+ }
163
+ /**
164
+ * Called when a prompt dialog resumes being the active dialog on the dialog stack, such as
165
+ * when the previous active dialog on the stack completes.
166
+ *
167
+ * @param dialogContext The DialogContext for the current turn of the conversation.
168
+ * @param _reason An enum indicating why the dialog resumed.
169
+ * @param _result Optional, value returned from the previous dialog on the stack.
170
+ * The type of the value returned is dependent on the previous dialog.
171
+ * @returns A Promise representing the asynchronous operation.
172
+ * @remarks
173
+ * If the task is successful, the result indicates whether the dialog is still
174
+ * active after the turn has been processed by the dialog.
175
+ */
176
+ async resumeDialog(dialogContext, _reason, _result) {
177
+ // Prompts are typically leaf nodes on the stack but the dev is free to push other dialogs
178
+ // on top of the stack which will result in the prompt receiving an unexpected call to
179
+ // resumeDialog() when the pushed on dialog ends.
180
+ // To avoid the prompt prematurely ending we need to implement this method and
181
+ // simply re-prompt the user.
182
+ await this.repromptDialog(dialogContext.context, dialogContext.activeDialog);
183
+ return dialog_1.Dialog.EndOfTurn;
184
+ }
185
+ /**
186
+ * Called when a prompt dialog has been requested to re-prompt the user for input.
187
+ *
188
+ * @param context TurnContext, context for the current
189
+ * turn of conversation with the user.
190
+ * @param instance DialogInstance, the instance
191
+ * of the dialog on the stack.
192
+ * @returns A `Promise` representing the asynchronous operation.
193
+ */
194
+ async repromptDialog(context, instance) {
195
+ const state = instance.state;
196
+ await this.onPrompt(context, state.state, state.options, false);
197
+ }
198
+ /**
199
+ * Helper function to compose an output activity containing a set of choices.
200
+ *
201
+ * @param prompt The prompt to append the users choices to.
202
+ * @param channelId ID of the channel the prompt is being sent to.
203
+ * @param choices List of choices to append.
204
+ * @param style Configured style for the list of choices.
205
+ * @param options (Optional) options to configure the underlying ChoiceFactory call.
206
+ * @returns The composed activity ready to send to the user.
207
+ */
208
+ appendChoices(prompt, channelId, choices, style, options) {
209
+ // Get base prompt text (if any)
210
+ let text = '';
211
+ if (typeof prompt === 'string') {
212
+ text = prompt;
213
+ }
214
+ else if (prompt && prompt.text) {
215
+ text = prompt.text;
216
+ }
217
+ // Create temporary msg
218
+ let msg;
219
+ switch (style) {
220
+ case ListStyle.inline:
221
+ msg = choices_1.ChoiceFactory.inline(choices, text, undefined, options);
222
+ break;
223
+ case ListStyle.list:
224
+ msg = choices_1.ChoiceFactory.list(choices, text, undefined, options);
225
+ break;
226
+ case ListStyle.none:
227
+ msg = agents_hosting_1.MessageFactory.text(text);
228
+ break;
229
+ default:
230
+ msg = choices_1.ChoiceFactory.forChannel(channelId, choices, text, undefined, options);
231
+ break;
232
+ }
233
+ // Update prompt with text, actions and attachments
234
+ if (typeof prompt === 'object') {
235
+ // Clone the prompt Activity as to not modify the original prompt.
236
+ prompt = JSON.parse(JSON.stringify(prompt));
237
+ prompt.text = msg.text;
238
+ if (msg.suggestedActions &&
239
+ Array.isArray(msg.suggestedActions.actions) &&
240
+ msg.suggestedActions.actions.length > 0) {
241
+ prompt.suggestedActions = msg.suggestedActions;
242
+ }
243
+ if (msg.attachments) {
244
+ if (prompt.attachments) {
245
+ prompt.attachments = prompt.attachments.concat(msg.attachments);
246
+ }
247
+ else {
248
+ prompt.attachments = msg.attachments;
249
+ }
250
+ }
251
+ return prompt;
252
+ }
253
+ else {
254
+ msg.inputHint = agents_hosting_1.InputHints.ExpectingInput;
255
+ return msg;
256
+ }
257
+ }
258
+ }
259
+ exports.Prompt = Prompt;
260
+ //# sourceMappingURL=prompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../../src/prompts/prompt.ts"],"names":[],"mappings":";;;AAAA;;;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 +1,72 @@
1
+ export interface PromptCultureModel {
2
+ /**
3
+ * Culture Model's Locale.
4
+ *
5
+ * @example
6
+ * "en-US"
7
+ */
8
+ locale: string;
9
+ /**
10
+ * Culture Model's InlineSeparator.
11
+ *
12
+ * @example
13
+ * ", "
14
+ */
15
+ separator: string;
16
+ /**
17
+ * Culture Model's InlineOr.
18
+ *
19
+ * @example
20
+ * " or "
21
+ */
22
+ inlineOr: string;
23
+ /**
24
+ * Culture Model's InlineOrMore.
25
+ *
26
+ * @example
27
+ * ", or "
28
+ */
29
+ inlineOrMore: string;
30
+ /**
31
+ * Equivalent of "Yes" in Culture Model's Language.
32
+ *
33
+ * @example
34
+ * "Yes"
35
+ */
36
+ yesInLanguage: string;
37
+ /**
38
+ * Equivalent of "No" in Culture Model's Language.
39
+ *
40
+ * @example
41
+ * "No"
42
+ */
43
+ noInLanguage: string;
44
+ }
45
+ /**
46
+ * Class container for currently-supported Culture Models in Confirm and Choice Prompt.
47
+ */
48
+ export declare class PromptCultureModels {
49
+ static Chinese: PromptCultureModel;
50
+ static Dutch: PromptCultureModel;
51
+ static English: PromptCultureModel;
52
+ static French: PromptCultureModel;
53
+ static German: PromptCultureModel;
54
+ static Italian: PromptCultureModel;
55
+ static Japanese: PromptCultureModel;
56
+ static Portuguese: PromptCultureModel;
57
+ static Spanish: PromptCultureModel;
58
+ /**
59
+ * @private
60
+ */
61
+ private static getSupportedCultureCodes;
62
+ /**
63
+ * Use Recognizers-Text to normalize various potential Locale strings to a standard.
64
+ *
65
+ * @remarks This is mostly a copy/paste from https://github.com/microsoft/Recognizers-Text/blob/master/JavaScript/packages/recognizers-text/src/culture.ts#L39
66
+ * This doesn't directly use Recognizers-Text's MapToNearestLanguage because if they add language support before we do, it will break our prompts.
67
+ * @param cultureCode Represents locale. Examples: "en-US, en-us, EN".
68
+ * @returns Normalized locale.
69
+ */
70
+ static mapToNearestLanguage(cultureCode: string): string;
71
+ static getSupportedCultures: () => PromptCultureModel[];
72
+ }