@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,252 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ComponentDialog = void 0;
4
+ const dialog_1 = require("./dialog");
5
+ const dialogContext_1 = require("./dialogContext");
6
+ const dialogContainer_1 = require("./dialogContainer");
7
+ const dialogReason_1 = require("./dialogReason");
8
+ const dialogTurnStatus_1 = require("./dialogTurnStatus");
9
+ const PERSISTED_DIALOG_STATE = 'dialogs';
10
+ /**
11
+ * Base class for a dialog that contains other child dialogs.
12
+ *
13
+ * @remarks
14
+ * Component dialogs let you break your agent's logic up into components that can themselves be added
15
+ * as a dialog to another `ComponentDialog` or `DialogSet`. Components can also be exported as part
16
+ * of a node package and used within other agents.
17
+ *
18
+ * @param O (Optional) options that can be passed into the `DialogContext.beginDialog()` method.
19
+ */
20
+ class ComponentDialog extends dialogContainer_1.DialogContainer {
21
+ /**
22
+ * Called when the dialog is started and pushed onto the parent's dialog stack.
23
+ * By default, this calls the
24
+ * Dialog.BeginDialogAsync(DialogContext, object, CancellationToken) method
25
+ * of the component dialog's initial dialog, as defined by InitialDialogId.
26
+ * Override this method in a derived class to implement interrupt logic.
27
+ *
28
+ * @param outerDialogContext The parent DialogContext for the current turn of conversation.
29
+ * @param options Optional, initial information to pass to the dialog.
30
+ * @returns A Promise representing the asynchronous operation.
31
+ * @remarks
32
+ * If the task is successful, the result indicates whether the dialog is still
33
+ * active after the turn has been processed by the dialog.
34
+ */
35
+ async beginDialog(outerDialogContext, options) {
36
+ await this.checkForVersionChange(outerDialogContext);
37
+ // Start the inner dialog.
38
+ const innerDC = this.createChildContext(outerDialogContext);
39
+ const turnResult = await this.onBeginDialog(innerDC, options);
40
+ // Check for end of inner dialog
41
+ if (turnResult.status !== dialogTurnStatus_1.DialogTurnStatus.waiting) {
42
+ if (turnResult.status === dialogTurnStatus_1.DialogTurnStatus.cancelled) {
43
+ await this.endComponent(outerDialogContext, turnResult.result);
44
+ const cancelledTurnResult = {
45
+ status: dialogTurnStatus_1.DialogTurnStatus.cancelled,
46
+ result: turnResult.result,
47
+ };
48
+ return cancelledTurnResult;
49
+ }
50
+ // Return result to calling dialog
51
+ return await this.endComponent(outerDialogContext, turnResult.result);
52
+ }
53
+ // Just signal end of turn
54
+ return dialog_1.Dialog.EndOfTurn;
55
+ }
56
+ /**
57
+ * Called when the dialog is _continued_, where it is the active dialog and the
58
+ * user replies with a new Activity.
59
+ * If this method is *not* overridden, the dialog automatically ends when the user replies.
60
+ *
61
+ * @param outerDialogContext The parent DialogContext for the current turn of conversation.
62
+ * @returns A Promise representing the asynchronous operation.
63
+ * @remarks
64
+ * If the task is successful, the result indicates whether the dialog is still
65
+ * active after the turn has been processed by the dialog. The result may also contain a
66
+ * return value.
67
+ */
68
+ async continueDialog(outerDialogContext) {
69
+ await this.checkForVersionChange(outerDialogContext);
70
+ // Continue execution of inner dialog.
71
+ const innerDC = this.createChildContext(outerDialogContext);
72
+ const turnResult = await this.onContinueDialog(innerDC);
73
+ // Check for end of inner dialog
74
+ if (turnResult.status !== dialogTurnStatus_1.DialogTurnStatus.waiting) {
75
+ // Return result to calling dialog
76
+ return await this.endComponent(outerDialogContext, turnResult.result);
77
+ }
78
+ // Just signal end of turn
79
+ return dialog_1.Dialog.EndOfTurn;
80
+ }
81
+ /**
82
+ * Called when a child dialog on the parent's dialog stack completed this turn, returning
83
+ * control to this dialog component.
84
+ *
85
+ * @param outerDialogContext The DialogContext for the current turn of conversation.
86
+ * @param _reason Reason why the dialog resumed.
87
+ * @param _result Optional, value returned from the dialog that was called. The type
88
+ * of the value returned is dependent on the child dialog.
89
+ * @returns A Promise representing the asynchronous operation.
90
+ * @remarks
91
+ * If the task is successful, the result indicates whether this dialog is still
92
+ * active after this dialog turn has been processed.
93
+ * Generally, the child dialog was started with a call to
94
+ * beginDialog(DialogContext, object) in the parent's
95
+ * context. However, if the DialogContext.replaceDialog(string, object) method
96
+ * is called, the logical child dialog may be different than the original.
97
+ * If this method is *not* overridden, the dialog automatically calls its
98
+ * RepromptDialog(ITurnContext, DialogInstance) when the user replies.
99
+ */
100
+ async resumeDialog(outerDialogContext, _reason, _result) {
101
+ await this.checkForVersionChange(outerDialogContext);
102
+ // Containers are typically leaf nodes on the stack but the dev is free to push other dialogs
103
+ // on top of the stack which will result in the container receiving an unexpected call to
104
+ // resumeDialog() when the pushed on dialog ends.
105
+ // To avoid the container prematurely ending we need to implement this method and simply
106
+ // ask our inner dialog stack to re-prompt.
107
+ await this.repromptDialog(outerDialogContext.context, outerDialogContext.activeDialog);
108
+ return dialog_1.Dialog.EndOfTurn;
109
+ }
110
+ /**
111
+ * Called when the dialog should re-prompt the user for input.
112
+ *
113
+ * @param context The TurnContext object for this turn.
114
+ * @param instance State information for this dialog.
115
+ * @returns A Promise representing the asynchronous operation.
116
+ */
117
+ async repromptDialog(context, instance) {
118
+ // Forward to inner dialogs
119
+ const innerDC = this.createInnerDC(context, instance);
120
+ await innerDC.repromptDialog();
121
+ // Notify component.
122
+ await this.onRepromptDialog(context, instance);
123
+ }
124
+ /**
125
+ * Called when the Dialog is ending.
126
+ *
127
+ * @param context The TurnContext object for this turn.
128
+ * @param instance State information associated with the instance of this component Dialog on its parent's dialog stack.
129
+ * @param reason Reason why the Dialog ended.
130
+ * @returns A Promise representing the asynchronous operation.
131
+ * @remarks When this method is called from the parent dialog's context, the component Dialog
132
+ * cancels all of the dialogs on its inner dialog stack before ending.
133
+ */
134
+ async endDialog(context, instance, reason) {
135
+ // Forward cancel to inner dialogs
136
+ if (reason === dialogReason_1.DialogReason.cancelCalled) {
137
+ const innerDC = this.createInnerDC(context, instance);
138
+ await innerDC.cancelAllDialogs();
139
+ }
140
+ // Notify component
141
+ await this.onEndDialog(context, instance, reason);
142
+ }
143
+ /**
144
+ * Adds a child Dialog or prompt to the components internal DialogSet.
145
+ *
146
+ * @param dialog The child Dialog or prompt to add.
147
+ * @returns The ComponentDialog after the operation is complete.
148
+ * @remarks
149
+ * The Dialog.id of the first child added to the component will be assigned to the initialDialogId property.
150
+ */
151
+ addDialog(dialog) {
152
+ this.dialogs.add(dialog);
153
+ if (this.initialDialogId === undefined) {
154
+ this.initialDialogId = dialog.id;
155
+ }
156
+ return this;
157
+ }
158
+ /**
159
+ * Creates the inner dialog context
160
+ *
161
+ * @param outerDialogContext the outer dialog context
162
+ * @returns The created Dialog Context.
163
+ */
164
+ createChildContext(outerDialogContext) {
165
+ return this.createInnerDC(outerDialogContext, outerDialogContext.activeDialog);
166
+ }
167
+ /**
168
+ * Called anytime an instance of the component has been started.
169
+ *
170
+ * @remarks
171
+ * SHOULD be overridden by components that wish to perform custom interruption logic. The
172
+ * default implementation calls `innerDC.beginDialog()` with the dialog assigned to
173
+ * initialdialogid.
174
+ * @param innerDialogContext Dialog context for the components internal `DialogSet`.
175
+ * @param options (Optional) options that were passed to the component by its parent.
176
+ * @returns {Promise<DialogTurnResult>} A promise resolving to the dialog turn result.
177
+ */
178
+ onBeginDialog(innerDialogContext, options) {
179
+ return innerDialogContext.beginDialog(this.initialDialogId, options);
180
+ }
181
+ /**
182
+ * Called anytime a multi-turn component receives additional activities.
183
+ *
184
+ * @remarks
185
+ * SHOULD be overridden by components that wish to perform custom interruption logic. The
186
+ * default implementation calls `innerDC.continueDialog()`.
187
+ * @param innerDC Dialog context for the components internal `DialogSet`.
188
+ * @returns {Promise<DialogTurnResult>} A promise resolving to the dialog turn result.
189
+ */
190
+ onContinueDialog(innerDC) {
191
+ return innerDC.continueDialog();
192
+ }
193
+ /**
194
+ * Called when the component is ending.
195
+ *
196
+ * @remarks
197
+ * If the `reason` code is equal to `DialogReason.cancelCalled`, then any active child dialogs
198
+ * will be cancelled before this method is called.
199
+ * @param _context Context for the current turn of conversation.
200
+ * @param _instance The components instance data within its parents dialog stack.
201
+ * @param _reason The reason the component is ending.
202
+ * @returns A promise representing the asynchronous operation.
203
+ */
204
+ onEndDialog(_context, _instance, _reason) {
205
+ return Promise.resolve();
206
+ }
207
+ /**
208
+ * Called when the component has been requested to re-prompt the user for input.
209
+ *
210
+ * @remarks
211
+ * The active child dialog will have already been asked to reprompt before this method is called.
212
+ * @param _context Context for the current turn of conversation.
213
+ * @param _instance The instance of the current dialog.
214
+ * @returns A promise representing the asynchronous operation.
215
+ */
216
+ onRepromptDialog(_context, _instance) {
217
+ return Promise.resolve();
218
+ }
219
+ /**
220
+ * Called when the components last active child dialog ends and the component is ending.
221
+ *
222
+ * @remarks
223
+ * SHOULD be overridden by components that wish to perform custom logic before the component
224
+ * ends. The default implementation calls `outerDC.endDialog()` with the `result` returned
225
+ * from the last active child dialog.
226
+ * @param outerDC Dialog context for the parents `DialogSet`.
227
+ * @param result Result returned by the last active child dialog. Can be a value of `undefined`.
228
+ * @returns {Promise<DialogTurnResult>} A promise resolving to the dialog turn result.
229
+ */
230
+ endComponent(outerDC, result) {
231
+ return outerDC.endDialog(result);
232
+ }
233
+ /**
234
+ * @private
235
+ * @param context TurnContext or DialogContext for the current turn of conversation with the user.
236
+ * @param instance DialogInstance which contains the current state information for this dialog.
237
+ * @returns A new DialogContext instance.
238
+ * @remarks
239
+ * You should only call this if you don't have a dc to work with (such as OnResume())
240
+ */
241
+ createInnerDC(context, instance) {
242
+ if (!instance) {
243
+ const dialogInstance = { state: {} };
244
+ instance = dialogInstance;
245
+ }
246
+ const dialogState = instance.state[PERSISTED_DIALOG_STATE] || { dialogStack: [] };
247
+ instance.state[PERSISTED_DIALOG_STATE] = dialogState;
248
+ return new dialogContext_1.DialogContext(this.dialogs, context, dialogState);
249
+ }
250
+ }
251
+ exports.ComponentDialog = ComponentDialog;
252
+ //# sourceMappingURL=componentDialog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"componentDialog.js","sourceRoot":"","sources":["../../src/componentDialog.ts"],"names":[],"mappings":";;;AAKA,qCAAiC;AACjC,mDAA+C;AAC/C,uDAAmD;AAEnD,iDAA6C;AAE7C,yDAAqD;AAErD,MAAM,sBAAsB,GAAG,SAAS,CAAA;AAExC;;;;;;;;;GASG;AACH,MAAa,eAAuC,SAAQ,iCAAkB;IAS5E;;;;;;;;;;;;;SAaK;IACL,KAAK,CAAC,WAAW,CAAE,kBAAiC,EAAE,OAAW;QAC/D,MAAM,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AAW,EAAE,EAAE,EAAE,CAAA;QACjF,QAAQ,CAAC,KAAK,CAAC,sBAAsB,CAAC,GAAG,WAAW,CAAA;QAEpD,OAAO,IAAI,6BAAa,CAAC,IAAI,CAAC,OAAO,EAAE,OAAsB,EAAE,WAAW,CAAC,CAAA;IAC7E,CAAC;CACF;AAxRD,0CAwRC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ /**
6
+ * ComponentRegistration is a signature class for discovering assets from components.
7
+ */
8
+ export declare class ComponentRegistration {
9
+ private static readonly _components;
10
+ /**
11
+ * Gets list of all ComponentRegistration objects registered.
12
+ *
13
+ * @returns A list of ComponentRegistration objects.
14
+ */
15
+ static get components(): ComponentRegistration[];
16
+ /**
17
+ * Add a component, only one instance per type is allowed for components.
18
+ *
19
+ * @param componentRegistration The component to be registered.
20
+ */
21
+ static add(componentRegistration: ComponentRegistration): void;
22
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Microsoft Corporation. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.ComponentRegistration = void 0;
8
+ /**
9
+ * ComponentRegistration is a signature class for discovering assets from components.
10
+ */
11
+ class ComponentRegistration {
12
+ /**
13
+ * Gets list of all ComponentRegistration objects registered.
14
+ *
15
+ * @returns A list of ComponentRegistration objects.
16
+ */
17
+ static get components() {
18
+ return Array.from(ComponentRegistration._components.values());
19
+ }
20
+ /**
21
+ * Add a component, only one instance per type is allowed for components.
22
+ *
23
+ * @param componentRegistration The component to be registered.
24
+ */
25
+ static add(componentRegistration) {
26
+ const name = componentRegistration.constructor.name;
27
+ ComponentRegistration._components.set(name, componentRegistration);
28
+ }
29
+ }
30
+ exports.ComponentRegistration = ComponentRegistration;
31
+ ComponentRegistration._components = new Map();
32
+ //# sourceMappingURL=componentRegistration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"componentRegistration.js","sourceRoot":"","sources":["../../src/componentRegistration.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;GAEG;AACH,MAAa,qBAAqB;IAGhC;;;;SAIK;IACL,MAAM,KAAK,UAAU;QACnB,OAAO,KAAK,CAAC,IAAI,CAAC,qBAAqB,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC,CAAA;IAC/D,CAAC;IAED;;;;SAIK;IACL,MAAM,CAAC,GAAG,CAAE,qBAA4C;QACtD,MAAM,IAAI,GAAG,qBAAqB,CAAC,WAAW,CAAC,IAAI,CAAA;QACnD,qBAAqB,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,EAAE,qBAAqB,CAAC,CAAA;IACpE,CAAC;;AApBH,sDAqBC;AApByB,iCAAW,GAAuC,IAAI,GAAG,EAAiC,CAAA"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { Converter, ConverterFactory } from './converter';
6
+ /**
7
+ * Base class for all configurable classes.
8
+ */
9
+ export declare abstract class Configurable {
10
+ /**
11
+ * Fluent method for configuring the object.
12
+ *
13
+ * @param config Configuration settings to apply.
14
+ * @returns The Configurable after the operation is complete.
15
+ */
16
+ configure(config: Record<string, unknown>): this;
17
+ /**
18
+ * @param _property The key of the conditional selector configuration.
19
+ * @returns The converter for the selector configuration.
20
+ */
21
+ getConverter(_property: string): Converter | ConverterFactory;
22
+ }
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Microsoft Corporation. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.Configurable = void 0;
8
+ /**
9
+ * Base class for all configurable classes.
10
+ */
11
+ class Configurable {
12
+ /**
13
+ * Fluent method for configuring the object.
14
+ *
15
+ * @param config Configuration settings to apply.
16
+ * @returns The Configurable after the operation is complete.
17
+ */
18
+ configure(config) {
19
+ for (const key in config) {
20
+ if (Object.prototype.hasOwnProperty.call(config, key)) {
21
+ const setting = config[`${key}`];
22
+ const converter = this.getConverter(key);
23
+ if (converter && typeof converter === 'object') {
24
+ this[`${key}`] = converter.convert(setting);
25
+ }
26
+ else {
27
+ if (Array.isArray(setting)) {
28
+ this[`${key}`] = setting;
29
+ }
30
+ else if (typeof setting === 'object') {
31
+ if (typeof this[`${key}`] === 'object') {
32
+ // Apply as a map update
33
+ for (const child in setting) {
34
+ if (Object.prototype.hasOwnProperty.call(setting, child)) {
35
+ this[`${key}`][`${child}`] = setting[`${child}`];
36
+ }
37
+ }
38
+ }
39
+ else {
40
+ this[`${key}`] = setting;
41
+ }
42
+ }
43
+ else if (setting !== undefined) {
44
+ this[`${key}`] = setting;
45
+ }
46
+ }
47
+ }
48
+ }
49
+ return this;
50
+ }
51
+ /**
52
+ * @param _property The key of the conditional selector configuration.
53
+ * @returns The converter for the selector configuration.
54
+ */
55
+ getConverter(_property) {
56
+ return undefined;
57
+ }
58
+ }
59
+ exports.Configurable = Configurable;
60
+ //# sourceMappingURL=configurable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configurable.js","sourceRoot":"","sources":["../../src/configurable.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH;;GAEG;AACH,MAAsB,YAAY;IAChC;;;;;SAKK;IACL,SAAS,CAAE,MAA+B;QACxC,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;YACzB,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;gBACtD,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,GAAG,EAAE,CAAC,CAAA;gBAChC,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAA;gBACxC,IAAI,SAAS,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE,CAAC;oBAC/C,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;gBAC7C,CAAC;qBAAM,CAAC;oBACN,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;wBAC3B,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,OAAO,CAAA;oBAC1B,CAAC;yBAAM,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;wBACvC,IAAI,OAAO,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC,KAAK,QAAQ,EAAE,CAAC;4BACvC,wBAAwB;4BACxB,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;gCAC5B,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC;oCACzD,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,GAAG,KAAK,EAAE,CAAC,CAAA;gCAClD,CAAC;4BACH,CAAC;wBACH,CAAC;6BAAM,CAAC;4BACN,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,OAAO,CAAA;wBAC1B,CAAC;oBACH,CAAC;yBAAM,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;wBACjC,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,OAAO,CAAA;oBAC1B,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;IAED;;;SAGK;IACL,YAAY,CAAE,SAAiB;QAC7B,OAAO,SAAS,CAAA;IAClB,CAAC;CACF;AA5CD,oCA4CC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Configuration is an interface that is used to obtain configurable values
3
+ */
4
+ export interface Configuration {
5
+ get<T = unknown>(path?: string[]): T | undefined;
6
+ set(path: string[], value: unknown): void;
7
+ }
8
+ /**
9
+ * Useful for shimming Components into ComponentRegistrations
10
+ */
11
+ export declare const noOpConfiguration: Configuration;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ // Copyright (c) Microsoft Corporation.
3
+ // Licensed under the MIT License.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.noOpConfiguration = void 0;
6
+ /**
7
+ * Useful for shimming Components into ComponentRegistrations
8
+ */
9
+ exports.noOpConfiguration = {
10
+ get(_path) {
11
+ return undefined;
12
+ },
13
+ set(_path, _value) {
14
+ // no-op
15
+ },
16
+ };
17
+ //# sourceMappingURL=configuration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configuration.js","sourceRoot":"","sources":["../../src/configuration.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAUlC;;GAEG;AACU,QAAA,iBAAiB,GAAkB;IAC9C,GAAG,CAAE,KAAK;QACR,OAAO,SAAS,CAAA;IAClB,CAAC;IACD,GAAG,CAAE,KAAK,EAAE,MAAM;QAChB,QAAQ;IACV,CAAC;CACF,CAAA"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ /**
6
+ * The converter converts object from one type to another.
7
+ */
8
+ export interface Converter<From = unknown, To = unknown> {
9
+ convert(value: From | To): To;
10
+ }
11
+ export type ConverterFactory<From = unknown, To = unknown> = {
12
+ new (...args: unknown[]): Converter<From, To>;
13
+ };
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Microsoft Corporation. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ //# sourceMappingURL=converter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"converter.js","sourceRoot":"","sources":["../../src/converter.ts"],"names":[],"mappings":";AAAA;;;GAGG"}
@@ -0,0 +1,184 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { TurnContext } from '@microsoft/agents-hosting';
6
+ import { DialogContext } from './dialogContext';
7
+ import { Configurable } from './configurable';
8
+ import { DialogTurnResult } from './dialogTurnResult';
9
+ import { DialogEvent } from './dialogEvent';
10
+ import { DialogReason } from './dialogReason';
11
+ import { DialogInstance } from './dialogInstance';
12
+ /**
13
+ * Defines the core behavior for all dialogs.
14
+ */
15
+ export declare abstract class Dialog<O extends object = {}> extends Configurable {
16
+ private _id;
17
+ /**
18
+ * Gets a default end-of-turn result.
19
+ *
20
+ * @remarks
21
+ * This result indicates that a dialog (or a logical step within a dialog) has completed
22
+ * processing for the current turn, is still active, and is waiting for more input.
23
+ */
24
+ static EndOfTurn: DialogTurnResult;
25
+ /**
26
+ * Creates a new instance of the Dialog class.
27
+ *
28
+ * @param dialogId Optional. unique ID of the dialog.
29
+ */
30
+ constructor(dialogId?: string);
31
+ /**
32
+ * Unique ID of the dialog.
33
+ *
34
+ * @remarks
35
+ * This will be automatically generated if not specified.
36
+ * @returns The Id for the dialog.
37
+ */
38
+ get id(): string;
39
+ /**
40
+ * Sets the unique ID of the dialog.
41
+ */
42
+ set id(value: string);
43
+ /**
44
+ * An encoded string used to aid in the detection of agent changes on re-deployment.
45
+ *
46
+ * @remarks
47
+ * This defaults to returning the dialogs [id](#id) but can be overridden to provide more
48
+ * precise change detection logic. Any dialog on the stack that has its version change will
49
+ * result in a `versionChanged` event will be raised. If this event is not handled by the agent,
50
+ * an error will be thrown resulting in the agent error handler logic being run.
51
+ *
52
+ * Returning an empty string will disable version tracking for the component all together.
53
+ * @returns Unique string which should only change when dialog has changed in a way that should restart the dialog.
54
+ */
55
+ getVersion(): string;
56
+ /**
57
+ * When overridden in a derived class, starts the dialog.
58
+ *
59
+ * @param dc The context for the current dialog turn.
60
+ * @param options Optional. Arguments to use when the dialog starts.
61
+ *
62
+ * @remarks
63
+ * Derived dialogs must override this method.
64
+ *
65
+ * The DialogContext calls this method when it creates
66
+ * a new DialogInstance for this dialog, pushes it
67
+ * onto the dialog stack, and starts the dialog.
68
+ *
69
+ * A dialog that represents a single-turn conversation should await
70
+ * DialogContext.endDialog before exiting this method.
71
+ *
72
+ */
73
+ abstract beginDialog(dc: DialogContext, options?: O): Promise<DialogTurnResult>;
74
+ /**
75
+ * When overridden in a derived class, continues the dialog.
76
+ *
77
+ * @param dc The context for the current dialog turn.
78
+ *
79
+ * @remarks
80
+ * Derived dialogs that support multiple-turn conversations should override this method.
81
+ * By default, this method signals that the dialog is complete and returns.
82
+ *
83
+ * The DialogContext calls this method when it continues
84
+ * the dialog.
85
+ *
86
+ * To signal to the dialog context that this dialog has completed, await
87
+ * DialogContext.endDialog before exiting this method.
88
+ *
89
+ * @returns {Promise<DialogTurnResult>} A promise resolving to the dialog turn result.
90
+ */
91
+ continueDialog(dc: DialogContext): Promise<DialogTurnResult>;
92
+ /**
93
+ * When overridden in a derived class, resumes the dialog after the dialog above it on the stack completes.
94
+ *
95
+ * @param dc The context for the current dialog turn.
96
+ * @param reason The reason the dialog is resuming. This will typically be DialogReason.endCalled
97
+ * @param result Optional. The return value, if any, from the dialog that ended.
98
+ *
99
+ * @remarks
100
+ * Derived dialogs that support multiple-turn conversations should override this method.
101
+ * By default, this method signals that the dialog is complete and returns.
102
+ *
103
+ * The DialogContext calls this method when it resumes
104
+ * the dialog. If the previous dialog on the stack returned a value, that value is in the `result`
105
+ * parameter.
106
+ *
107
+ * To start a _child_ dialog, use DialogContext.beginDialog or DialogContext.prompt; however, this dialog will not
108
+ * necessarily be the one that started the child dialog.
109
+ * To signal to the dialog context that this dialog has completed, await DialogContext.endDialog before exiting this method.
110
+ *
111
+ * @returns {Promise<DialogTurnResult>} A promise resolving to the dialog turn result.
112
+ */
113
+ resumeDialog(dc: DialogContext, reason: DialogReason, result?: any): Promise<DialogTurnResult>;
114
+ /**
115
+ * When overridden in a derived class, reprompts the user for input.
116
+ *
117
+ * @param _context The context object for the turn.
118
+ * @param _instance Current state information for this dialog.
119
+ *
120
+ * @remarks
121
+ * Derived dialogs that support validation and re-prompt logic should override this method.
122
+ * By default, this method has no effect.
123
+ *
124
+ * The DialogContext calls this method when the current
125
+ * dialog should re-request input from the user. This method is implemented for prompt dialogs.
126
+ *
127
+ */
128
+ repromptDialog(_context: TurnContext, _instance: DialogInstance): Promise<void>;
129
+ /**
130
+ * When overridden in a derived class, performs clean up for the dialog before it ends.
131
+ *
132
+ * @param _context The context object for the turn.
133
+ * @param _instance Current state information for this dialog.
134
+ * @param _reason The reason the dialog is ending.
135
+ *
136
+ * @remarks
137
+ * Derived dialogs that need to perform logging or cleanup before ending should override this method.
138
+ * By default, this method has no effect.
139
+ *
140
+ * The DialogContext calls this method when the current
141
+ * dialog is ending.
142
+ *
143
+ */
144
+ endDialog(_context: TurnContext, _instance: DialogInstance, _reason: DialogReason): Promise<void>;
145
+ /**
146
+ * Called when an event has been raised, using `DialogContext.emitEvent()`, by either the current dialog or a dialog that the current dialog started.
147
+ *
148
+ * @param dialogContext - The dialog context for the current turn of conversation.
149
+ * @param event - The event being raised.
150
+ * @returns True if the event is handled by the current dialog and bubbling should stop.
151
+ */
152
+ onDialogEvent(dialogContext: DialogContext, event: DialogEvent): Promise<boolean>;
153
+ /**
154
+ * Called before an event is bubbled to its parent.
155
+ *
156
+ * @remarks
157
+ * This is a good place to perform interception of an event as returning `true` will prevent
158
+ * any further bubbling of the event to the dialogs parents and will also prevent any child
159
+ * dialogs from performing their default processing.
160
+ * @param _dc The dialog context for the current turn of conversation.
161
+ * @param _e The event being raised.
162
+ * @returns Whether the event is handled by the current dialog and further processing should stop.
163
+ */
164
+ protected onPreBubbleEvent(_dc: DialogContext, _e: DialogEvent): Promise<boolean>;
165
+ /**
166
+ * Called after an event was bubbled to all parents and wasn't handled.
167
+ *
168
+ * @remarks
169
+ * This is a good place to perform default processing logic for an event. Returning `true` will
170
+ * prevent any processing of the event by child dialogs.
171
+ * @param _dc The dialog context for the current turn of conversation.
172
+ * @param _e The event being raised.
173
+ * @returns Whether the event is handled by the current dialog and further processing should stop.
174
+ */
175
+ protected onPostBubbleEvent(_dc: DialogContext, _e: DialogEvent): Promise<boolean>;
176
+ /**
177
+ * Called when a unique ID needs to be computed for a dialog.
178
+ *
179
+ * @remarks
180
+ * SHOULD be overridden to provide a more contextually relevant ID. The preferred pattern for
181
+ * ID's is `<dialog type>(this.hashedLabel('<dialog args>'))`.
182
+ */
183
+ protected onComputeId(): string;
184
+ }