@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
package/dist/index.js ADDED
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ // Copyright (c) Microsoft Corporation. All rights reserved.
3
+ // Licensed under the MIT License.
4
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5
+ if (k2 === undefined) k2 = k;
6
+ var desc = Object.getOwnPropertyDescriptor(m, k);
7
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
8
+ desc = { enumerable: true, get: function() { return m[k]; } };
9
+ }
10
+ Object.defineProperty(o, k2, desc);
11
+ }) : (function(o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ o[k2] = m[k];
14
+ }));
15
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
17
+ };
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ __exportStar(require("./src"), exports);
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import * as z from 'zod';
6
+ import { ServiceCollection } from './serviceCollection';
7
+ import { Configuration } from './configuration';
8
+ /**
9
+ * Definition of an AgentComponent that allows registration of services, custom actions, memory scopes and adapters.
10
+ *
11
+ * To make your components available to the system you derive from AgentComponent and register services to add functionality.
12
+ * These components then are consumed in appropriate places by the systems that need them. When using Composer, configureServices
13
+ * gets called automatically on the components by the agent runtime, as long as the components are registered in the configuration.
14
+ */
15
+ export declare abstract class AgentComponent {
16
+ static z: z.ZodType<AgentComponent, z.ZodTypeDef, AgentComponent>;
17
+ abstract configureServices(services: ServiceCollection, configuration: Configuration): void;
18
+ }
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Microsoft Corporation. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
6
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
+ if (k2 === undefined) k2 = k;
8
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
+ desc = { enumerable: true, get: function() { return m[k]; } };
11
+ }
12
+ Object.defineProperty(o, k2, desc);
13
+ }) : (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ o[k2] = m[k];
16
+ }));
17
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
18
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
19
+ }) : function(o, v) {
20
+ o["default"] = v;
21
+ });
22
+ var __importStar = (this && this.__importStar) || (function () {
23
+ var ownKeys = function(o) {
24
+ ownKeys = Object.getOwnPropertyNames || function (o) {
25
+ var ar = [];
26
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
27
+ return ar;
28
+ };
29
+ return ownKeys(o);
30
+ };
31
+ return function (mod) {
32
+ if (mod && mod.__esModule) return mod;
33
+ var result = {};
34
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
35
+ __setModuleDefault(result, mod);
36
+ return result;
37
+ };
38
+ })();
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.AgentComponent = void 0;
41
+ const z = __importStar(require("zod"));
42
+ /**
43
+ * Definition of an AgentComponent that allows registration of services, custom actions, memory scopes and adapters.
44
+ *
45
+ * To make your components available to the system you derive from AgentComponent and register services to add functionality.
46
+ * These components then are consumed in appropriate places by the systems that need them. When using Composer, configureServices
47
+ * gets called automatically on the components by the agent runtime, as long as the components are registered in the configuration.
48
+ */
49
+ class AgentComponent {
50
+ }
51
+ exports.AgentComponent = AgentComponent;
52
+ AgentComponent.z = z.custom((val) => typeof val.configureServices === 'function', {
53
+ message: 'AgentComponent',
54
+ });
55
+ //# sourceMappingURL=agentComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agentComponent.js","sourceRoot":"","sources":["../../src/agentComponent.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAwB;AAIxB;;;;;;GAMG;AACH,MAAsB,cAAc;;AAApC,wCAMC;AALQ,gBAAC,GAAG,CAAC,CAAC,MAAM,CAAiB,CAAC,GAAQ,EAAE,EAAE,CAAC,OAAO,GAAG,CAAC,iBAAiB,KAAK,UAAU,EAAE;IAC7F,OAAO,EAAE,gBAAgB;CAC1B,CAAC,CAAA"}
@@ -0,0 +1,48 @@
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
+ * A collection of `AgentState` plugins that should be loaded or saved in parallel as a single unit.
8
+ * See `AutoSaveStateMiddleware` for an implementation of this class.
9
+ */
10
+ export declare class AgentStateSet {
11
+ /**
12
+ * Array of the sets `AgentState` plugins.
13
+ */
14
+ readonly agentStates: AgentState[];
15
+ /**
16
+ * Creates a new AgentStateSet instance.
17
+ *
18
+ * @param agentStates One or more AgentState plugins to register.
19
+ */
20
+ constructor(...agentStates: AgentState[]);
21
+ /**
22
+ * Registers one or more `AgentState` plugins with the set.
23
+ *
24
+ * @param agentStates One or more AgentState plugins to register.
25
+ * @returns The updated AgentStateSet.
26
+ */
27
+ add(...agentStates: AgentState[]): this;
28
+ /**
29
+ * Calls `AgentState.load()` on all of the AgentState plugins in the set.
30
+ *
31
+ * @remarks
32
+ * This will trigger all of the plugins to read in their state in parallel.
33
+ *
34
+ * @param context Context for current turn of conversation with the user.
35
+ * @param force (Optional) If `true` the cache will be bypassed and the state will always be read in directly from storage. Defaults to `false`.
36
+ */
37
+ loadAll(context: TurnContext, force?: boolean): Promise<void>;
38
+ /**
39
+ * Calls `AgentState.saveChanges()` on all of the AgentState plugins in the set.
40
+ *
41
+ * @remarks
42
+ * This will trigger all of the plugins to write out their state in parallel.
43
+ *
44
+ * @param context Context for current turn of conversation with the user.
45
+ * @param force (Optional) if `true` the state will always be written out regardless of its change state. Defaults to `false`.
46
+ */
47
+ saveAllChanges(context: TurnContext, force?: boolean): Promise<void>;
48
+ }
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AgentStateSet = void 0;
4
+ /**
5
+ * A collection of `AgentState` plugins that should be loaded or saved in parallel as a single unit.
6
+ * See `AutoSaveStateMiddleware` for an implementation of this class.
7
+ */
8
+ class AgentStateSet {
9
+ /**
10
+ * Creates a new AgentStateSet instance.
11
+ *
12
+ * @param agentStates One or more AgentState plugins to register.
13
+ */
14
+ constructor(...agentStates) {
15
+ /**
16
+ * Array of the sets `AgentState` plugins.
17
+ */
18
+ this.agentStates = [];
19
+ AgentStateSet.prototype.add.apply(this, agentStates);
20
+ }
21
+ /**
22
+ * Registers one or more `AgentState` plugins with the set.
23
+ *
24
+ * @param agentStates One or more AgentState plugins to register.
25
+ * @returns The updated AgentStateSet.
26
+ */
27
+ add(...agentStates) {
28
+ agentStates.forEach((agentstate) => {
29
+ if (typeof agentstate.load === 'function' && typeof agentstate.saveChanges === 'function') {
30
+ this.agentStates.push(agentstate);
31
+ }
32
+ else {
33
+ throw new Error("AgentStateSet: a object was added that isn't an instance of AgentStateSet.");
34
+ }
35
+ });
36
+ return this;
37
+ }
38
+ /**
39
+ * Calls `AgentState.load()` on all of the AgentState plugins in the set.
40
+ *
41
+ * @remarks
42
+ * This will trigger all of the plugins to read in their state in parallel.
43
+ *
44
+ * @param context Context for current turn of conversation with the user.
45
+ * @param force (Optional) If `true` the cache will be bypassed and the state will always be read in directly from storage. Defaults to `false`.
46
+ */
47
+ async loadAll(context, force = false) {
48
+ const promises = this.agentStates.map((agentstate) => agentstate.load(context, force));
49
+ await Promise.all(promises);
50
+ }
51
+ /**
52
+ * Calls `AgentState.saveChanges()` on all of the AgentState plugins in the set.
53
+ *
54
+ * @remarks
55
+ * This will trigger all of the plugins to write out their state in parallel.
56
+ *
57
+ * @param context Context for current turn of conversation with the user.
58
+ * @param force (Optional) if `true` the state will always be written out regardless of its change state. Defaults to `false`.
59
+ */
60
+ async saveAllChanges(context, force = false) {
61
+ const promises = this.agentStates.map((agentstate) => agentstate.saveChanges(context, force));
62
+ await Promise.all(promises);
63
+ }
64
+ }
65
+ exports.AgentStateSet = AgentStateSet;
66
+ //# sourceMappingURL=agentStateSet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agentStateSet.js","sourceRoot":"","sources":["../../src/agentStateSet.ts"],"names":[],"mappings":";;;AAMA;;;GAGG;AACH,MAAa,aAAa;IAMxB;;;;SAIK;IACL,YAAa,GAAG,WAAyB;QAVzC;;aAEK;QACI,gBAAW,GAAiB,EAAE,CAAA;QAQrC,aAAa,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,WAAW,CAAC,CAAA;IACtD,CAAC;IAED;;;;;SAKK;IACL,GAAG,CAAE,GAAG,WAAyB;QAC/B,WAAW,CAAC,OAAO,CAAC,CAAC,UAAsB,EAAE,EAAE;YAC7C,IAAI,OAAO,UAAU,CAAC,IAAI,KAAK,UAAU,IAAI,OAAO,UAAU,CAAC,WAAW,KAAK,UAAU,EAAE,CAAC;gBAC1F,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;YACnC,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,KAAK,CAAC,4EAA4E,CAAC,CAAA;YAC/F,CAAC;QACH,CAAC,CAAC,CAAA;QAEF,OAAO,IAAI,CAAA;IACb,CAAC;IAED;;;;;;;;SAQK;IACL,KAAK,CAAC,OAAO,CAAE,OAAoB,EAAE,KAAK,GAAG,KAAK;QAChD,MAAM,QAAQ,GAAmB,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,UAAsB,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAA;QAElH,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;IAC7B,CAAC;IAED;;;;;;;;SAQK;IACL,KAAK,CAAC,cAAc,CAAE,OAAoB,EAAE,KAAK,GAAG,KAAK;QACvD,MAAM,QAAQ,GAAoB,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,UAAsB,EAAE,EAAE,CAChF,UAAU,CAAC,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,CACvC,CAAA;QAED,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;IAC7B,CAAC;CACF;AAhED,sCAgEC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { CardAction } from '@microsoft/agents-hosting';
6
+ /**
7
+ * An instance of a choice that can be used to render a choice to a user or recognize something a
8
+ * user picked.
9
+ */
10
+ export interface Choice {
11
+ value: string;
12
+ action?: CardAction;
13
+ synonyms?: string[];
14
+ }
@@ -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=choice.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"choice.js","sourceRoot":"","sources":["../../../src/choices/choice.ts"],"names":[],"mappings":";AAAA;;;GAGG"}
@@ -0,0 +1,81 @@
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 } from './choice';
7
+ /**
8
+ * Additional options used to tweak the formatting of choice lists.
9
+ */
10
+ export interface ChoiceFactoryOptions {
11
+ /**
12
+ * (Optional) character used to separate individual choices when there are more than 2 choices.
13
+ * The default value is `", "`.
14
+ */
15
+ inlineSeparator?: string;
16
+ /**
17
+ * (Optional) separator inserted between the choices when their are only 2 choices. The default
18
+ * value is `" or "`.
19
+ */
20
+ inlineOr?: string;
21
+ /**
22
+ * (Optional) separator inserted between the last 2 choices when their are more than 2 choices.
23
+ * The default value is `", or "`.
24
+ */
25
+ inlineOrMore?: string;
26
+ /**
27
+ * (Optional) if `true`, inline and list style choices will be prefixed with the index of the
28
+ * choice as in "1. choice". If `false`, the list style will use a bulleted list instead. The
29
+ * default value is `true`.
30
+ */
31
+ includeNumbers?: boolean;
32
+ }
33
+ /**
34
+ * A set of utility functions to assist with the formatting a 'message' activity containing a list
35
+ * of choices.
36
+ *
37
+ */
38
+ export declare class ChoiceFactory {
39
+ static readonly MAX_ACTION_TITLE_LENGTH = 20;
40
+ /**
41
+ * Returns a 'message' activity containing a list of choices that has been automatically
42
+ * formatted based on the capabilities of a given channel.
43
+ *
44
+ * @param channelOrContext Channel ID or context object for the current turn of conversation.
45
+ * @param choices List of choices to render.
46
+ * @param text (Optional) text of the message.
47
+ * @param speak (Optional) SSML to speak for the message.
48
+ * @param options (Optional) formatting options to use when rendering as a list.
49
+ * @returns The created message activity.
50
+ */
51
+ static forChannel(channelOrContext: string | TurnContext, choices: (string | Choice)[], text?: string, speak?: string, options?: ChoiceFactoryOptions): Activity;
52
+ /**
53
+ * Returns a 'message' activity containing a list of choices that has been formatted as an
54
+ * inline list.
55
+ *
56
+ * @param choices List of choices to render.
57
+ * @param text (Optional) text of the message.
58
+ * @param speak (Optional) SSML to speak for the message.
59
+ * @param options (Optional) formatting options to tweak rendering of list.
60
+ * @returns The created message activity.
61
+ */
62
+ static inline(choices: (string | Choice)[], text?: string, speak?: string, options?: ChoiceFactoryOptions): Activity;
63
+ /**
64
+ * Returns a 'message' activity containing a list of choices that has been formatted as an
65
+ * numbered or bulleted list.
66
+ *
67
+ * @param choices List of choices to render.
68
+ * @param text (Optional) text of the message.
69
+ * @param speak (Optional) SSML to speak for the message.
70
+ * @param options (Optional) formatting options to tweak rendering of list.
71
+ * @returns The created message activity.
72
+ */
73
+ static list(choices: (string | Choice)[], text?: string, speak?: string, options?: ChoiceFactoryOptions): Activity;
74
+ /**
75
+ * Takes a mixed list of `string` and `Choice` based choices and returns them as a `Choice[]`.
76
+ *
77
+ * @param choices List of choices to add.
78
+ * @returns A list of choices.
79
+ */
80
+ static toChoices(choices: (string | Choice)[] | undefined): Choice[];
81
+ }
@@ -0,0 +1,133 @@
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.ChoiceFactory = void 0;
8
+ const agents_hosting_1 = require("@microsoft/agents-hosting");
9
+ /**
10
+ * A set of utility functions to assist with the formatting a 'message' activity containing a list
11
+ * of choices.
12
+ *
13
+ */
14
+ class ChoiceFactory {
15
+ /**
16
+ * Returns a 'message' activity containing a list of choices that has been automatically
17
+ * formatted based on the capabilities of a given channel.
18
+ *
19
+ * @param channelOrContext Channel ID or context object for the current turn of conversation.
20
+ * @param choices List of choices to render.
21
+ * @param text (Optional) text of the message.
22
+ * @param speak (Optional) SSML to speak for the message.
23
+ * @param options (Optional) formatting options to use when rendering as a list.
24
+ * @returns The created message activity.
25
+ */
26
+ static forChannel(channelOrContext, choices, text, speak, options) {
27
+ const list = ChoiceFactory.toChoices(choices);
28
+ let maxTitleLength = 0;
29
+ list.forEach((choice) => {
30
+ const l = choice.action && choice.action.title ? choice.action.title.length : choice.value.length;
31
+ if (l > maxTitleLength) {
32
+ maxTitleLength = l;
33
+ }
34
+ });
35
+ const longTitles = maxTitleLength > this.MAX_ACTION_TITLE_LENGTH;
36
+ if (!longTitles && choices.length <= 3) {
37
+ // If the titles are short and there are 3 or less choices we'll use an inline list.
38
+ return ChoiceFactory.inline(list, text, speak, options);
39
+ }
40
+ else {
41
+ return ChoiceFactory.list(list, text, speak, options);
42
+ }
43
+ }
44
+ /**
45
+ * Returns a 'message' activity containing a list of choices that has been formatted as an
46
+ * inline list.
47
+ *
48
+ * @param choices List of choices to render.
49
+ * @param text (Optional) text of the message.
50
+ * @param speak (Optional) SSML to speak for the message.
51
+ * @param options (Optional) formatting options to tweak rendering of list.
52
+ * @returns The created message activity.
53
+ */
54
+ static inline(choices, text, speak, options) {
55
+ const opt = {
56
+ inlineSeparator: ', ',
57
+ inlineOr: ' or ',
58
+ inlineOrMore: ', or ',
59
+ includeNumbers: true,
60
+ ...options,
61
+ };
62
+ let connector = '';
63
+ let txt = text || '';
64
+ txt += ' ';
65
+ ChoiceFactory.toChoices(choices).forEach((choice, index) => {
66
+ const title = choice.action && choice.action.title ? choice.action.title : choice.value;
67
+ txt += `${connector}${opt.includeNumbers ? '(' + (index + 1).toString() + ') ' : ''}${title}`;
68
+ if (index === choices.length - 2) {
69
+ connector = (index === 0 ? opt.inlineOr : opt.inlineOrMore) || '';
70
+ }
71
+ else {
72
+ connector = opt.inlineSeparator || '';
73
+ }
74
+ });
75
+ txt += '';
76
+ return agents_hosting_1.MessageFactory.text(txt, speak, agents_hosting_1.InputHints.ExpectingInput);
77
+ }
78
+ /**
79
+ * Returns a 'message' activity containing a list of choices that has been formatted as an
80
+ * numbered or bulleted list.
81
+ *
82
+ * @param choices List of choices to render.
83
+ * @param text (Optional) text of the message.
84
+ * @param speak (Optional) SSML to speak for the message.
85
+ * @param options (Optional) formatting options to tweak rendering of list.
86
+ * @returns The created message activity.
87
+ */
88
+ static list(choices, text, speak, options) {
89
+ const opt = {
90
+ includeNumbers: true,
91
+ ...options,
92
+ };
93
+ let connector = '';
94
+ let txt = text || '';
95
+ txt += '\n\n ';
96
+ ChoiceFactory.toChoices(choices).forEach((choice, index) => {
97
+ const title = choice.action && choice.action.title ? choice.action.title : choice.value;
98
+ txt += `${connector}${opt.includeNumbers ? (index + 1).toString() + '. ' : '- '}${title}`;
99
+ connector = '\n ';
100
+ });
101
+ return agents_hosting_1.MessageFactory.text(txt, speak, agents_hosting_1.InputHints.ExpectingInput);
102
+ }
103
+ /**
104
+ * Takes a mixed list of `string` and `Choice` based choices and returns them as a `Choice[]`.
105
+ *
106
+ * @param choices List of choices to add.
107
+ * @returns A list of choices.
108
+ */
109
+ static toChoices(choices) {
110
+ return (choices || [])
111
+ .map((choice) => (typeof choice === 'string' ? { value: choice } : choice))
112
+ .map((choice) => {
113
+ const action = choice.action;
114
+ if (action) {
115
+ action.type = action.type ? action.type : agents_hosting_1.ActionTypes.ImBack;
116
+ if (!action.value && action.title) {
117
+ action.value = action.title;
118
+ }
119
+ else if (!action.title && action.value) {
120
+ action.title = action.value;
121
+ }
122
+ else if (!action.title && !action.value) {
123
+ action.title = action.value = choice.value;
124
+ }
125
+ }
126
+ return choice;
127
+ })
128
+ .filter((choice) => choice);
129
+ }
130
+ }
131
+ exports.ChoiceFactory = ChoiceFactory;
132
+ ChoiceFactory.MAX_ACTION_TITLE_LENGTH = 20;
133
+ //# sourceMappingURL=choiceFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"choiceFactory.js","sourceRoot":"","sources":["../../../src/choices/choiceFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,8DAMkC;AAiClC;;;;GAIG;AACH,MAAa,aAAa;IAGxB;;;;;;;;;;SAUK;IACL,MAAM,CAAC,UAAU,CACf,gBAAsC,EACtC,OAA4B,EAC5B,IAAa,EACb,KAAc,EACd,OAA8B;QAE9B,MAAM,IAAI,GAAa,aAAa,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;QAEvD,IAAI,cAAc,GAAG,CAAC,CAAA;QACtB,IAAI,CAAC,OAAO,CAAC,CAAC,MAAc,EAAE,EAAE;YAC9B,MAAM,CAAC,GAAW,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAA;YACzG,IAAI,CAAC,GAAG,cAAc,EAAE,CAAC;gBACvB,cAAc,GAAG,CAAC,CAAA;YACpB,CAAC;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AAG,EAAE,CAAA"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { FindValuesOptions } from './findValues';
6
+ import { ModelResult } from './modelResult';
7
+ import { Choice } from './choice';
8
+ export interface FindChoicesOptions extends FindValuesOptions {
9
+ noValue?: boolean;
10
+ noAction?: boolean;
11
+ recognizeNumbers?: boolean;
12
+ recognizeOrdinals?: boolean;
13
+ }
14
+ export interface FoundChoice {
15
+ value: string;
16
+ index: number;
17
+ score: number;
18
+ synonym?: string;
19
+ }
20
+ /**
21
+ * Mid-level search function for recognizing a choice in an utterance.
22
+ *
23
+ * @param utterance The text or user utterance to search over. For an incoming 'message' activity you can simply use `context.activity.text`.
24
+ * @param choices List of choices to search over.
25
+ * @param options (Optional) options used to tweak the search that's performed.
26
+ * @returns A list of found choices, sorted by most relevant first.
27
+ */
28
+ export declare function findChoices(utterance: string, choices: (string | Choice)[], options?: FindChoicesOptions): ModelResult<FoundChoice>[];
@@ -0,0 +1,46 @@
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.findChoices = findChoices;
8
+ const findValues_1 = require("./findValues");
9
+ /**
10
+ * Mid-level search function for recognizing a choice in an utterance.
11
+ *
12
+ * @param utterance The text or user utterance to search over. For an incoming 'message' activity you can simply use `context.activity.text`.
13
+ * @param choices List of choices to search over.
14
+ * @param options (Optional) options used to tweak the search that's performed.
15
+ * @returns A list of found choices, sorted by most relevant first.
16
+ */
17
+ function findChoices(utterance, choices, options) {
18
+ const opt = options || {};
19
+ const list = (choices || []).map((choice) => typeof choice === 'string' ? { value: choice } : choice);
20
+ const synonyms = [];
21
+ list.forEach((choice, index) => {
22
+ if (!opt.noValue) {
23
+ synonyms.push({ value: choice.value, index });
24
+ }
25
+ if (choice.action && choice.action.title && !opt.noAction) {
26
+ synonyms.push({ value: choice.action.title, index });
27
+ }
28
+ (choice.synonyms || []).forEach((synonym) => synonyms.push({ value: synonym, index }));
29
+ });
30
+ return (0, findValues_1.findValues)(utterance, synonyms, options).map((v) => {
31
+ const choice = list[v.resolution.index];
32
+ return {
33
+ start: v.start,
34
+ end: v.end,
35
+ typeName: 'choice',
36
+ text: v.text,
37
+ resolution: {
38
+ value: choice.value,
39
+ index: v.resolution.index,
40
+ score: v.resolution.score,
41
+ synonym: v.resolution.value,
42
+ },
43
+ };
44
+ });
45
+ }
46
+ //# sourceMappingURL=findChoices.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"findChoices.js","sourceRoot":"","sources":["../../../src/choices/findChoices.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AA4BH,kCAsCC;AAhED,6CAAqF;AAkBrF;;;;;;;GAOG;AACH,SAAgB,WAAW,CACzB,SAAiB,EACjB,OAA4B,EAC5B,OAA4B;IAE5B,MAAM,GAAG,GAAuB,OAAO,IAAI,EAAE,CAAA;IAE7C,MAAM,IAAI,GAAa,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CACpD,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,MAAM,CACxD,CAAA;IAED,MAAM,QAAQ,GAAkB,EAAE,CAAA;IAClC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAc,EAAE,KAAa,EAAE,EAAE;QAC7C,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;YACjB,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,CAAC,CAAA;QAC/C,CAAC;QACD,IAAI,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;YAC1D,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,CAAC,CAAA;QACtD,CAAC;QACD,CAAC,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,OAAe,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,CAAA;IAChG,CAAC,CAAC,CAAA;IAEF,OAAO,IAAA,uBAAU,EAAC,SAAS,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAA0B,EAAE,EAAE;QACjF,MAAM,MAAM,GAAW,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;QAE/C,OAAO;YACL,KAAK,EAAE,CAAC,CAAC,KAAK;YACd,GAAG,EAAE,CAAC,CAAC,GAAG;YACV,QAAQ,EAAE,QAAQ;YAClB,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,UAAU,EAAE;gBACV,KAAK,EAAE,MAAM,CAAC,KAAK;gBACnB,KAAK,EAAE,CAAC,CAAC,UAAU,CAAC,KAAK;gBACzB,KAAK,EAAE,CAAC,CAAC,UAAU,CAAC,KAAK;gBACzB,OAAO,EAAE,CAAC,CAAC,UAAU,CAAC,KAAK;aAC5B;SAC0B,CAAA;IAC/B,CAAC,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { ModelResult } from './modelResult';
6
+ import { TokenizerFunction } from './tokenizer';
7
+ /**
8
+ * Basic search options used to control how choices are recognized in a users utterance.
9
+ */
10
+ export interface FindValuesOptions {
11
+ allowPartialMatches?: boolean;
12
+ locale?: string;
13
+ maxTokenDistance?: number;
14
+ tokenizer?: TokenizerFunction;
15
+ }
16
+ export interface FoundValue {
17
+ value: string;
18
+ index: number;
19
+ score: number;
20
+ }
21
+ export interface SortedValue {
22
+ value: string;
23
+ index: number;
24
+ }
25
+ /**
26
+ * INTERNAL: Low-level function that searches for a set of values within an utterance. Higher level
27
+ * functions like `findChoices()` and `recognizeChoices()` are layered above this function. In most
28
+ * cases its easier to just call one of the higher level functions instead but this function contains
29
+ * the fuzzy search algorithm that drives choice recognition.
30
+ *
31
+ * @param utterance The text or user utterance to search over.
32
+ * @param values List of values to search over.
33
+ * @param options (Optional) options used to tweak the search that's performed.
34
+ * @returns A list of found values.
35
+ */
36
+ export declare function findValues(utterance: string, values: SortedValue[], options?: FindValuesOptions): ModelResult<FoundValue>[];