@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,71 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { DialogContext } from './dialogContext';
6
+ import { DialogReason } from './dialogReason';
7
+ import { DialogTurnResult } from './dialogTurnResult';
8
+ /**
9
+ * Values passed to the `WaterfallStepContext` constructor.
10
+ */
11
+ export interface WaterfallStepInfo<O extends object> {
12
+ index: number;
13
+ options: O;
14
+ reason: DialogReason;
15
+ result: any;
16
+ values: object;
17
+ onNext(result?: any): Promise<DialogTurnResult>;
18
+ }
19
+ /**
20
+ * Context object passed in to a `WaterfallStep`.
21
+ *
22
+ * @param O (Optional) type of options passed to the steps waterfall dialog in the call to `DialogContext.beginDialog()`.
23
+ */
24
+ export declare class WaterfallStepContext<O extends object = {}> extends DialogContext {
25
+ private _stepInfo;
26
+ /**
27
+ * Creates a new WaterfallStepContext instance.
28
+ *
29
+ * @param dialogContext The dialog context for the current turn of conversation.
30
+ * @param stepInfo Values to initialize the step context with.
31
+ */
32
+ constructor(dialogContext: DialogContext, stepInfo: WaterfallStepInfo<O>);
33
+ /**
34
+ * The index of the current waterfall step being executed.
35
+ *
36
+ * @returns The index of the current waterfall step being executed.
37
+ */
38
+ get index(): number;
39
+ /**
40
+ * Any options passed to the steps waterfall dialog when it was started with
41
+ * `DialogContext.beginDialog()`.
42
+ *
43
+ * @returns Any options the waterfall dialog was called with.
44
+ */
45
+ get options(): O;
46
+ /**
47
+ * The reason the waterfall step is being executed.
48
+ *
49
+ * @returns The reason the waterfall step is being executed.
50
+ */
51
+ get reason(): DialogReason;
52
+ /**
53
+ * Results returned by a dialog or prompt that was called in the previous waterfall step.
54
+ *
55
+ * @returns The result from the previous waterfall step.
56
+ */
57
+ get result(): any;
58
+ /**
59
+ * A dictionary of values which will be persisted across all waterfall steps.
60
+ *
61
+ * @returns A dictionary of values which will be persisted across all waterfall steps.
62
+ */
63
+ get values(): object;
64
+ /**
65
+ * Skips to the next waterfall step.
66
+ *
67
+ * @param result (Optional) result to pass to the next step.
68
+ * @returns A promise with the DialogTurnResult.
69
+ */
70
+ next(result?: any): Promise<DialogTurnResult>;
71
+ }
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WaterfallStepContext = void 0;
4
+ /**
5
+ * Copyright (c) Microsoft Corporation. All rights reserved.
6
+ * Licensed under the MIT License.
7
+ */
8
+ const dialogContext_1 = require("./dialogContext");
9
+ /**
10
+ * Context object passed in to a `WaterfallStep`.
11
+ *
12
+ * @param O (Optional) type of options passed to the steps waterfall dialog in the call to `DialogContext.beginDialog()`.
13
+ */
14
+ class WaterfallStepContext extends dialogContext_1.DialogContext {
15
+ /**
16
+ * Creates a new WaterfallStepContext instance.
17
+ *
18
+ * @param dialogContext The dialog context for the current turn of conversation.
19
+ * @param stepInfo Values to initialize the step context with.
20
+ */
21
+ constructor(dialogContext, stepInfo) {
22
+ super(dialogContext.dialogs, dialogContext, { dialogStack: dialogContext.stack });
23
+ this._stepInfo = stepInfo;
24
+ this.parent = dialogContext.parent;
25
+ }
26
+ /**
27
+ * The index of the current waterfall step being executed.
28
+ *
29
+ * @returns The index of the current waterfall step being executed.
30
+ */
31
+ get index() {
32
+ return this._stepInfo.index;
33
+ }
34
+ /**
35
+ * Any options passed to the steps waterfall dialog when it was started with
36
+ * `DialogContext.beginDialog()`.
37
+ *
38
+ * @returns Any options the waterfall dialog was called with.
39
+ */
40
+ get options() {
41
+ return this._stepInfo.options;
42
+ }
43
+ /**
44
+ * The reason the waterfall step is being executed.
45
+ *
46
+ * @returns The reason the waterfall step is being executed.
47
+ */
48
+ get reason() {
49
+ return this._stepInfo.reason;
50
+ }
51
+ /**
52
+ * Results returned by a dialog or prompt that was called in the previous waterfall step.
53
+ *
54
+ * @returns The result from the previous waterfall step.
55
+ */
56
+ get result() {
57
+ return this._stepInfo.result;
58
+ }
59
+ /**
60
+ * A dictionary of values which will be persisted across all waterfall steps.
61
+ *
62
+ * @returns A dictionary of values which will be persisted across all waterfall steps.
63
+ */
64
+ get values() {
65
+ return this._stepInfo.values;
66
+ }
67
+ /**
68
+ * Skips to the next waterfall step.
69
+ *
70
+ * @param result (Optional) result to pass to the next step.
71
+ * @returns A promise with the DialogTurnResult.
72
+ */
73
+ async next(result) {
74
+ return await this._stepInfo.onNext(result);
75
+ }
76
+ }
77
+ exports.WaterfallStepContext = WaterfallStepContext;
78
+ //# sourceMappingURL=waterfallStepContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"waterfallStepContext.js","sourceRoot":"","sources":["../../src/waterfallStepContext.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,mDAA+C;AAgB/C;;;;GAIG;AACH,MAAa,oBAA4C,SAAQ,6BAAa;IAG5E;;;;;SAKK;IACL,YAAa,aAA4B,EAAE,QAA8B;QACvE,KAAK,CAAC,aAAa,CAAC,OAAO,EAAE,aAAa,EAAE,EAAE,WAAW,EAAE,aAAa,CAAC,KAAK,EAAE,CAAC,CAAA;QACjF,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAA;QACzB,IAAI,CAAC,MAAM,GAAG,aAAa,CAAC,MAAM,CAAA;IACpC,CAAC;IAED;;;;SAIK;IACL,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAA;IAC7B,CAAC;IAED;;;;;SAKK;IACL,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAA;IAC/B,CAAC;IAED;;;;SAIK;IACL,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAA;IAC9B,CAAC;IAED;;;;SAIK;IACL,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAA;IAC9B,CAAC;IAED;;;;SAIK;IACL,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAA;IAC9B,CAAC;IAED;;;;;SAKK;IACL,KAAK,CAAC,IAAI,CAAE,MAAY;QACtB,OAAO,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IAC5C,CAAC;CACF;AAtED,oDAsEC"}
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/package.json",
3
+ "name": "@microsoft/agents-hosting-dialogs",
4
+ "version": "0.1.49",
5
+ "homepage": "https://github.com/microsoft/Agents-for-js",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/microsoft/Agents-for-js.git"
9
+ },
10
+ "author": {
11
+ "name": "Microsoft",
12
+ "email": "agentssdk@microsoft.com",
13
+ "url": "https://aka.ms/Agents"
14
+ },
15
+ "description": "Microsoft 365 Agents SDK Dialogs support.",
16
+ "main": "dist/index.js",
17
+ "types": "dist/src/index.d.ts",
18
+ "dependencies": {
19
+ "@microsoft/agents-hosting": "0.1.49",
20
+ "@types/lodash": "^4.17.16",
21
+ "dependency-graph": "^1.0.0",
22
+ "@microsoft/recognizers-text-suite": "^1.3.1",
23
+ "@microsoft/recognizers-text-number": "^1.3.1",
24
+ "@microsoft/recognizers-text-date-time": "^1.3.2",
25
+ "@microsoft/recognizers-text-choice": "^1.3.1",
26
+ "globalize": "^1.7.0"
27
+ },
28
+ "devDependencies": {
29
+ "@types/express": "^5.0.1"
30
+ },
31
+ "license": "MIT",
32
+ "files": [
33
+ "README.md",
34
+ "dist/src",
35
+ "dist/vendor",
36
+ "src",
37
+ "vendor"
38
+ ],
39
+ "exports": {
40
+ ".": {
41
+ "import": "./dist/src/index.js",
42
+ "require": "./dist/src/index.js"
43
+ },
44
+ "./package.json": "./package.json"
45
+ },
46
+ "engines": {
47
+ "node": ">=18.0.0"
48
+ }
49
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import * as z from 'zod'
7
+ import { ServiceCollection } from './serviceCollection'
8
+ import { Configuration } from './configuration'
9
+
10
+ /**
11
+ * Definition of an AgentComponent that allows registration of services, custom actions, memory scopes and adapters.
12
+ *
13
+ * To make your components available to the system you derive from AgentComponent and register services to add functionality.
14
+ * These components then are consumed in appropriate places by the systems that need them. When using Composer, configureServices
15
+ * gets called automatically on the components by the agent runtime, as long as the components are registered in the configuration.
16
+ */
17
+ export abstract class AgentComponent {
18
+ static z = z.custom<AgentComponent>((val: any) => typeof val.configureServices === 'function', {
19
+ message: 'AgentComponent',
20
+ })
21
+
22
+ abstract configureServices (services: ServiceCollection, configuration: Configuration): void
23
+ }
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { AgentState, TurnContext } from '@microsoft/agents-hosting'
6
+
7
+ /**
8
+ * A collection of `AgentState` plugins that should be loaded or saved in parallel as a single unit.
9
+ * See `AutoSaveStateMiddleware` for an implementation of this class.
10
+ */
11
+ export class AgentStateSet {
12
+ /**
13
+ * Array of the sets `AgentState` plugins.
14
+ */
15
+ readonly agentStates: AgentState[] = []
16
+
17
+ /**
18
+ * Creates a new AgentStateSet instance.
19
+ *
20
+ * @param agentStates One or more AgentState plugins to register.
21
+ */
22
+ constructor (...agentStates: AgentState[]) {
23
+ AgentStateSet.prototype.add.apply(this, agentStates)
24
+ }
25
+
26
+ /**
27
+ * Registers one or more `AgentState` plugins with the set.
28
+ *
29
+ * @param agentStates One or more AgentState plugins to register.
30
+ * @returns The updated AgentStateSet.
31
+ */
32
+ add (...agentStates: AgentState[]): this {
33
+ agentStates.forEach((agentstate: AgentState) => {
34
+ if (typeof agentstate.load === 'function' && typeof agentstate.saveChanges === 'function') {
35
+ this.agentStates.push(agentstate)
36
+ } else {
37
+ throw new Error("AgentStateSet: a object was added that isn't an instance of AgentStateSet.")
38
+ }
39
+ })
40
+
41
+ return this
42
+ }
43
+
44
+ /**
45
+ * Calls `AgentState.load()` on all of the AgentState plugins in the set.
46
+ *
47
+ * @remarks
48
+ * This will trigger all of the plugins to read in their state in parallel.
49
+ *
50
+ * @param context Context for current turn of conversation with the user.
51
+ * @param force (Optional) If `true` the cache will be bypassed and the state will always be read in directly from storage. Defaults to `false`.
52
+ */
53
+ async loadAll (context: TurnContext, force = false): Promise<void> {
54
+ const promises: Promise<any>[] = this.agentStates.map((agentstate: AgentState) => agentstate.load(context, force))
55
+
56
+ await Promise.all(promises)
57
+ }
58
+
59
+ /**
60
+ * Calls `AgentState.saveChanges()` on all of the AgentState plugins in the set.
61
+ *
62
+ * @remarks
63
+ * This will trigger all of the plugins to write out their state in parallel.
64
+ *
65
+ * @param context Context for current turn of conversation with the user.
66
+ * @param force (Optional) if `true` the state will always be written out regardless of its change state. Defaults to `false`.
67
+ */
68
+ async saveAllChanges (context: TurnContext, force = false): Promise<void> {
69
+ const promises: Promise<void>[] = this.agentStates.map((agentstate: AgentState) =>
70
+ agentstate.saveChanges(context, force)
71
+ )
72
+
73
+ await Promise.all(promises)
74
+ }
75
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import { CardAction } from '@microsoft/agents-hosting'
7
+
8
+ /**
9
+ * An instance of a choice that can be used to render a choice to a user or recognize something a
10
+ * user picked.
11
+ */
12
+ export interface Choice {
13
+ value: string;
14
+ action?: CardAction;
15
+ synonyms?: string[];
16
+ }
@@ -0,0 +1,189 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import {
7
+ ActionTypes,
8
+ Activity,
9
+ InputHints,
10
+ MessageFactory,
11
+ TurnContext,
12
+ } from '@microsoft/agents-hosting'
13
+ import { Choice } from './choice'
14
+
15
+ /**
16
+ * Additional options used to tweak the formatting of choice lists.
17
+ */
18
+ export interface ChoiceFactoryOptions {
19
+ /**
20
+ * (Optional) character used to separate individual choices when there are more than 2 choices.
21
+ * The default value is `", "`.
22
+ */
23
+ inlineSeparator?: string;
24
+
25
+ /**
26
+ * (Optional) separator inserted between the choices when their are only 2 choices. The default
27
+ * value is `" or "`.
28
+ */
29
+ inlineOr?: string;
30
+
31
+ /**
32
+ * (Optional) separator inserted between the last 2 choices when their are more than 2 choices.
33
+ * The default value is `", or "`.
34
+ */
35
+ inlineOrMore?: string;
36
+
37
+ /**
38
+ * (Optional) if `true`, inline and list style choices will be prefixed with the index of the
39
+ * choice as in "1. choice". If `false`, the list style will use a bulleted list instead. The
40
+ * default value is `true`.
41
+ */
42
+ includeNumbers?: boolean;
43
+ }
44
+
45
+ /**
46
+ * A set of utility functions to assist with the formatting a 'message' activity containing a list
47
+ * of choices.
48
+ *
49
+ */
50
+ export class ChoiceFactory {
51
+ static readonly MAX_ACTION_TITLE_LENGTH = 20
52
+
53
+ /**
54
+ * Returns a 'message' activity containing a list of choices that has been automatically
55
+ * formatted based on the capabilities of a given channel.
56
+ *
57
+ * @param channelOrContext Channel ID or context object for the current turn of conversation.
58
+ * @param choices List of choices to render.
59
+ * @param text (Optional) text of the message.
60
+ * @param speak (Optional) SSML to speak for the message.
61
+ * @param options (Optional) formatting options to use when rendering as a list.
62
+ * @returns The created message activity.
63
+ */
64
+ static forChannel (
65
+ channelOrContext: string | TurnContext,
66
+ choices: (string | Choice)[],
67
+ text?: string,
68
+ speak?: string,
69
+ options?: ChoiceFactoryOptions
70
+ ): Activity {
71
+ const list: Choice[] = ChoiceFactory.toChoices(choices)
72
+
73
+ let maxTitleLength = 0
74
+ list.forEach((choice: Choice) => {
75
+ const l: number = choice.action && choice.action.title ? choice.action.title.length : choice.value.length
76
+ if (l > maxTitleLength) {
77
+ maxTitleLength = l
78
+ }
79
+ })
80
+
81
+ const longTitles: boolean = maxTitleLength > this.MAX_ACTION_TITLE_LENGTH
82
+ if (!longTitles && choices.length <= 3) {
83
+ // If the titles are short and there are 3 or less choices we'll use an inline list.
84
+ return ChoiceFactory.inline(list, text, speak, options)
85
+ } else {
86
+ return ChoiceFactory.list(list, text, speak, options)
87
+ }
88
+ }
89
+
90
+ /**
91
+ * Returns a 'message' activity containing a list of choices that has been formatted as an
92
+ * inline list.
93
+ *
94
+ * @param choices List of choices to render.
95
+ * @param text (Optional) text of the message.
96
+ * @param speak (Optional) SSML to speak for the message.
97
+ * @param options (Optional) formatting options to tweak rendering of list.
98
+ * @returns The created message activity.
99
+ */
100
+ static inline (
101
+ choices: (string | Choice)[],
102
+ text?: string,
103
+ speak?: string,
104
+ options?: ChoiceFactoryOptions
105
+ ): Activity {
106
+ const opt: ChoiceFactoryOptions = {
107
+ inlineSeparator: ', ',
108
+ inlineOr: ' or ',
109
+ inlineOrMore: ', or ',
110
+ includeNumbers: true,
111
+ ...options,
112
+ } as ChoiceFactoryOptions
113
+
114
+ let connector = ''
115
+ let txt: string = text || ''
116
+ txt += ' '
117
+ ChoiceFactory.toChoices(choices).forEach((choice: any, index: number) => {
118
+ const title: string = choice.action && choice.action.title ? choice.action.title : choice.value
119
+ txt += `${connector}${opt.includeNumbers ? '(' + (index + 1).toString() + ') ' : ''}${title}`
120
+ if (index === choices.length - 2) {
121
+ connector = (index === 0 ? opt.inlineOr : opt.inlineOrMore) || ''
122
+ } else {
123
+ connector = opt.inlineSeparator || ''
124
+ }
125
+ })
126
+ txt += ''
127
+
128
+ return MessageFactory.text(txt, speak, InputHints.ExpectingInput)
129
+ }
130
+
131
+ /**
132
+ * Returns a 'message' activity containing a list of choices that has been formatted as an
133
+ * numbered or bulleted list.
134
+ *
135
+ * @param choices List of choices to render.
136
+ * @param text (Optional) text of the message.
137
+ * @param speak (Optional) SSML to speak for the message.
138
+ * @param options (Optional) formatting options to tweak rendering of list.
139
+ * @returns The created message activity.
140
+ */
141
+ static list (
142
+ choices: (string | Choice)[],
143
+ text?: string,
144
+ speak?: string,
145
+ options?: ChoiceFactoryOptions
146
+ ): Activity {
147
+ const opt: ChoiceFactoryOptions = {
148
+ includeNumbers: true,
149
+ ...options,
150
+ } as ChoiceFactoryOptions
151
+
152
+ let connector = ''
153
+ let txt: string = text || ''
154
+ txt += '\n\n '
155
+ ChoiceFactory.toChoices(choices).forEach((choice: any, index: number) => {
156
+ const title: string = choice.action && choice.action.title ? choice.action.title : choice.value
157
+ txt += `${connector}${opt.includeNumbers ? (index + 1).toString() + '. ' : '- '}${title}`
158
+ connector = '\n '
159
+ })
160
+
161
+ return MessageFactory.text(txt, speak, InputHints.ExpectingInput)
162
+ }
163
+
164
+ /**
165
+ * Takes a mixed list of `string` and `Choice` based choices and returns them as a `Choice[]`.
166
+ *
167
+ * @param choices List of choices to add.
168
+ * @returns A list of choices.
169
+ */
170
+ static toChoices (choices: (string | Choice)[] | undefined): Choice[] {
171
+ return (choices || [])
172
+ .map((choice) => (typeof choice === 'string' ? { value: choice } : choice))
173
+ .map((choice: Choice) => {
174
+ const action = choice.action
175
+ if (action) {
176
+ action.type = action.type ? action.type : ActionTypes.ImBack
177
+ if (!action.value && action.title) {
178
+ action.value = action.title
179
+ } else if (!action.title && action.value) {
180
+ action.title = action.value
181
+ } else if (!action.title && !action.value) {
182
+ action.title = action.value = choice.value
183
+ }
184
+ }
185
+ return choice
186
+ })
187
+ .filter((choice: Choice) => choice)
188
+ }
189
+ }
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import { findValues, FindValuesOptions, FoundValue, SortedValue } from './findValues'
7
+ import { ModelResult } from './modelResult'
8
+ import { Choice } from './choice'
9
+
10
+ export interface FindChoicesOptions extends FindValuesOptions {
11
+ noValue?: boolean;
12
+ noAction?: boolean;
13
+ recognizeNumbers?: boolean;
14
+ recognizeOrdinals?: boolean;
15
+ }
16
+
17
+ export interface FoundChoice {
18
+ value: string;
19
+ index: number;
20
+ score: number;
21
+ synonym?: string;
22
+ }
23
+
24
+ /**
25
+ * Mid-level search function for recognizing a choice in an utterance.
26
+ *
27
+ * @param utterance The text or user utterance to search over. For an incoming 'message' activity you can simply use `context.activity.text`.
28
+ * @param choices List of choices to search over.
29
+ * @param options (Optional) options used to tweak the search that's performed.
30
+ * @returns A list of found choices, sorted by most relevant first.
31
+ */
32
+ export function findChoices (
33
+ utterance: string,
34
+ choices: (string | Choice)[],
35
+ options?: FindChoicesOptions
36
+ ): ModelResult<FoundChoice>[] {
37
+ const opt: FindChoicesOptions = options || {}
38
+
39
+ const list: Choice[] = (choices || []).map((choice) =>
40
+ typeof choice === 'string' ? { value: choice } : choice
41
+ )
42
+
43
+ const synonyms: SortedValue[] = []
44
+ list.forEach((choice: Choice, index: number) => {
45
+ if (!opt.noValue) {
46
+ synonyms.push({ value: choice.value, index })
47
+ }
48
+ if (choice.action && choice.action.title && !opt.noAction) {
49
+ synonyms.push({ value: choice.action.title, index })
50
+ }
51
+ (choice.synonyms || []).forEach((synonym: string) => synonyms.push({ value: synonym, index }))
52
+ })
53
+
54
+ return findValues(utterance, synonyms, options).map((v: ModelResult<FoundValue>) => {
55
+ const choice: Choice = list[v.resolution.index]
56
+
57
+ return {
58
+ start: v.start,
59
+ end: v.end,
60
+ typeName: 'choice',
61
+ text: v.text,
62
+ resolution: {
63
+ value: choice.value,
64
+ index: v.resolution.index,
65
+ score: v.resolution.score,
66
+ synonym: v.resolution.value,
67
+ },
68
+ } as ModelResult<FoundChoice>
69
+ })
70
+ }