@microsoft/agents-hosting-dialogs 0.5.19-gc1e2ea1096 → 0.6.11

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 (44) hide show
  1. package/dist/src/choices/findChoices.d.ts +25 -0
  2. package/dist/src/choices/findChoices.js.map +1 -1
  3. package/dist/src/choices/findValues.d.ts +61 -6
  4. package/dist/src/choices/findValues.js +2 -1
  5. package/dist/src/choices/findValues.js.map +1 -1
  6. package/dist/src/choices/recognizeChoices.js +2 -2
  7. package/dist/src/choices/recognizeChoices.js.map +1 -1
  8. package/dist/src/dialogEvent.d.ts +14 -8
  9. package/dist/src/dialogManager.d.ts +34 -0
  10. package/dist/src/dialogManager.js.map +1 -1
  11. package/dist/src/dialogSet.d.ts +39 -2
  12. package/dist/src/dialogSet.js.map +1 -1
  13. package/dist/src/dialogTurnStateConstants.d.ts +1 -0
  14. package/dist/src/dialogTurnStateConstants.js +1 -0
  15. package/dist/src/dialogTurnStateConstants.js.map +1 -1
  16. package/dist/src/memory/dialogStateManager.d.ts +40 -5
  17. package/dist/src/memory/dialogStateManager.js +1 -1
  18. package/dist/src/memory/dialogStateManager.js.map +1 -1
  19. package/dist/src/prompts/confirmPrompt.d.ts +49 -0
  20. package/dist/src/prompts/confirmPrompt.js.map +1 -1
  21. package/dist/src/prompts/prompt.d.ts +2 -1
  22. package/dist/src/prompts/prompt.js.map +1 -1
  23. package/dist/src/prompts/promptCultureModels.d.ts +64 -30
  24. package/dist/src/prompts/promptCultureModels.js.map +1 -1
  25. package/dist/src/recognizer.d.ts +17 -0
  26. package/dist/src/recognizer.js +1 -0
  27. package/dist/src/recognizer.js.map +1 -1
  28. package/dist/src/recognizerResult.d.ts +26 -0
  29. package/dist/src/recognizerResult.js +26 -0
  30. package/dist/src/recognizerResult.js.map +1 -1
  31. package/package.json +2 -2
  32. package/src/choices/findChoices.ts +28 -0
  33. package/src/choices/findValues.ts +61 -6
  34. package/src/choices/recognizeChoices.ts +1 -1
  35. package/src/dialogEvent.ts +14 -8
  36. package/src/dialogManager.ts +38 -0
  37. package/src/dialogSet.ts +39 -2
  38. package/src/dialogTurnStateConstants.ts +1 -0
  39. package/src/memory/dialogStateManager.ts +40 -5
  40. package/src/prompts/confirmPrompt.ts +53 -2
  41. package/src/prompts/prompt.ts +2 -1
  42. package/src/prompts/promptCultureModels.ts +69 -30
  43. package/src/recognizer.ts +17 -0
  44. package/src/recognizerResult.ts +26 -0
@@ -12,15 +12,50 @@ import { DialogsComponentRegistration } from '../dialogsComponentRegistration'
12
12
  import { MemoryScope } from './scopes'
13
13
  import { PathResolver } from './pathResolvers'
14
14
 
15
+ /**
16
+ * Configuration options for the DialogStateManager.
17
+ *
18
+ * @remarks
19
+ * This interface defines the configuration settings that control how the DialogStateManager
20
+ * resolves memory paths and manages different memory scopes within a dialog context.
21
+ * The configuration is shared across all DialogStateManager instances within a dialog chain
22
+ * and is cached in turn state for performance optimization.
23
+ */
15
24
  export interface DialogStateManagerConfiguration {
16
25
  /**
17
- * List of path resolvers used to evaluate memory paths.
18
- */
26
+ * List of path resolvers used to evaluate and transform memory path expressions.
27
+ *
28
+ * @remarks
29
+ * Path resolvers provide shortcut behavior for mapping path expressions to their
30
+ * actual memory locations. For example, a resolver might transform '$foo' to 'dialog.foo'
31
+ * or 'user.name' to 'user.profile.name'. Resolvers are applied in order during path
32
+ * transformation, allowing for complex path mapping scenarios.
33
+ *
34
+ * Common path resolver types include:
35
+ * - Dollar sign resolvers (e.g., $variable -> dialog.variable)
36
+ * - Scope alias resolvers (e.g., this -> dialog)
37
+ * - Custom application-specific resolvers
38
+ */
19
39
  readonly pathResolvers: PathResolver[];
20
40
 
21
41
  /**
22
- * List of the supported memory scopes.
23
- */
42
+ * List of the supported memory scopes available to the dialog state manager.
43
+ *
44
+ * @remarks
45
+ * Memory scopes are named root-level objects that provide access to different
46
+ * types of persistent and transient data within the dialog system. Each scope
47
+ * manages its own data lifecycle including loading, saving, and deletion operations.
48
+ *
49
+ * Common memory scope types include:
50
+ * - dialog: Dialog-specific data that persists across turns
51
+ * - user: User-specific data that persists across conversations
52
+ * - conversation: Conversation-specific data
53
+ * - turn: Turn-specific data (transient)
54
+ * - settings: Application configuration data
55
+ *
56
+ * Scopes can exist either in the dialog context or in turn state, and each
57
+ * scope determines whether it should be included in memory snapshots for debugging.
58
+ */
24
59
  readonly memoryScopes: MemoryScope[];
25
60
  }
26
61
 
@@ -29,7 +64,7 @@ const PATH_TRACKER = 'dialog._tracker.paths'
29
64
  const DIALOG_STATE_MANAGER_CONFIGURATION = 'DialogStateManagerConfiguration'
30
65
 
31
66
  /**
32
- * The DialogStateManager manages memory scopes and path resolvers.
67
+ * Manages memory scopes and path resolvers.
33
68
  *
34
69
  * @remarks
35
70
  * MemoryScopes are named root level objects, which can exist either in the dialog context or off
@@ -9,9 +9,60 @@ import { ListStyle, Prompt, PromptOptions, PromptRecognizerResult, PromptValidat
9
9
  import { PromptCultureModels } from './promptCultureModels'
10
10
  import { Activity } from '@microsoft/agents-activity'
11
11
 
12
- // Need ChoiceDefaultsProperty so we can set choiceDefaults dynamically with lambda
12
+ /**
13
+ * Defines locale-specific choice defaults for confirmation prompts.
14
+ *
15
+ * @remarks
16
+ * This interface represents a dictionary that maps locale strings to their corresponding
17
+ * choice configurations for confirmation prompts. Each locale entry contains the localized
18
+ * "yes" and "no" choices along with formatting options for how those choices should be
19
+ * presented to the user.
20
+ *
21
+ * The interface is designed to support dynamic configuration of choice defaults using
22
+ * lambda expressions or other dynamic assignment patterns.
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * const customChoiceDefaults: ChoiceDefaultsConfirmPrompt = {
27
+ * 'en-us': {
28
+ * choices: ['Yes', 'No'],
29
+ * options: {
30
+ * inlineSeparator: ', ',
31
+ * inlineOr: ' or ',
32
+ * includeNumbers: true
33
+ * }
34
+ * },
35
+ * 'es-es': {
36
+ * choices: ['Sí', 'No'],
37
+ * options: {
38
+ * inlineSeparator: ', ',
39
+ * inlineOr: ' o ',
40
+ * includeNumbers: true
41
+ * }
42
+ * }
43
+ * };
44
+ * ```
45
+ */
13
46
  export interface ChoiceDefaultsConfirmPrompt {
14
- [locale: string]: { choices: (string | Choice)[]; options: ChoiceFactoryOptions };
47
+ /**
48
+ * Locale-specific choice configuration.
49
+ *
50
+ * @remarks
51
+ * The key is a locale string (e.g., 'en-us', 'fr-fr', 'de-de') and the value
52
+ * contains the localized choices and formatting options for that locale.
53
+ */
54
+ [locale: string]: {
55
+ /**
56
+ * Array of localized choice options, typically ["Yes", "No"] equivalents.
57
+ * Can be either string values or Choice objects for more complex configurations.
58
+ */
59
+ choices: (string | Choice)[];
60
+ /**
61
+ * Formatting options that control how the choices are presented to the user,
62
+ * including separators, conjunctions, and whether to include numbers.
63
+ */
64
+ options: ChoiceFactoryOptions
65
+ };
15
66
  }
16
67
 
17
68
  /**
@@ -105,7 +105,8 @@ export interface PromptRecognizerResult<T> {
105
105
  /**
106
106
  * Function signature for providing a custom prompt validator.
107
107
  *
108
- * ```TypeScript
108
+ * @example
109
+ * ```typescript
109
110
  * type PromptValidator<T> = (prompt: PromptValidatorContext<T>) => Promise<boolean>;
110
111
  * ```
111
112
  *
@@ -1,47 +1,86 @@
1
1
  import { Culture } from '@microsoft/recognizers-text-suite'
2
2
 
3
+ /**
4
+ * Represents a culture-specific model that defines localization settings for prompts.
5
+ * This interface provides language-specific formatting rules and translations for
6
+ * interactive prompts such as choice lists and confirmation dialogs.
7
+ */
3
8
  export interface PromptCultureModel {
4
9
  /**
5
- * Culture Model's Locale.
6
- *
7
- * @example
8
- * "en-US"
9
- */
10
+ * The locale identifier for this culture model.
11
+ * This follows the standard IETF language tag format (e.g., "en-US", "fr-FR", "ja-JP").
12
+ * Used to identify the target language and region for localization.
13
+ *
14
+ * @example
15
+ * "en-US" // English (United States)
16
+ * @example
17
+ * "fr-FR" // French (France)
18
+ * @example
19
+ * "ja-JP" // Japanese (Japan)
20
+ */
10
21
  locale: string;
22
+
11
23
  /**
12
- * Culture Model's InlineSeparator.
13
- *
14
- * @example
15
- * ", "
16
- */
24
+ * The separator string used to delimit items in a list when presenting choices.
25
+ * This is typically used between items in the middle of a list, not before the final item.
26
+ *
27
+ * @example
28
+ * ", " // English: "apple, banana, orange"
29
+ * @example
30
+ * "、 " // Japanese: "りんご、 バナナ、 オレンジ"
31
+ */
17
32
  separator: string;
33
+
18
34
  /**
19
- * Culture Model's InlineOr.
20
- *
21
- * @example
22
- * " or "
23
- */
35
+ * The conjunction string used before the final item in a two-item list.
36
+ * This is used when presenting exactly two choices to the user.
37
+ *
38
+ * @example
39
+ * " or " // English: "apple or banana"
40
+ * @example
41
+ * " ou " // French: "pomme ou banane"
42
+ * @example
43
+ * " または " // Japanese: "りんご または バナナ"
44
+ */
24
45
  inlineOr: string;
46
+
25
47
  /**
26
- * Culture Model's InlineOrMore.
27
- *
28
- * @example
29
- * ", or "
30
- */
48
+ * The conjunction string used before the final item in a list of three or more items.
49
+ * This combines with the separator to create properly formatted choice lists.
50
+ *
51
+ * @example
52
+ * ", or " // English: "apple, banana, or orange"
53
+ * @example
54
+ * ", ou " // French: "pomme, banane, ou orange"
55
+ * @example
56
+ * "、 または " // Japanese: "りんご、 バナナ、 または オレンジ"
57
+ */
31
58
  inlineOrMore: string;
59
+
32
60
  /**
33
- * Equivalent of "Yes" in Culture Model's Language.
34
- *
35
- * @example
36
- * "Yes"
37
- */
61
+ * The affirmative response word in the target language.
62
+ * Used in confirmation prompts and boolean choice scenarios.
63
+ *
64
+ * @example
65
+ * "Yes" // English
66
+ * @example
67
+ * "Oui" // French
68
+ * @example
69
+ * "はい" // Japanese
70
+ */
38
71
  yesInLanguage: string;
72
+
39
73
  /**
40
- * Equivalent of "No" in Culture Model's Language.
41
- *
42
- * @example
43
- * "No"
44
- */
74
+ * The negative response word in the target language.
75
+ * Used in confirmation prompts and boolean choice scenarios.
76
+ *
77
+ * @example
78
+ * "No" // English
79
+ * @example
80
+ * "Non" // French
81
+ * @example
82
+ * "いいえ" // Japanese
83
+ */
45
84
  noInLanguage: string;
46
85
  }
47
86
 
package/src/recognizer.ts CHANGED
@@ -8,13 +8,30 @@ import { DialogContext } from './dialogContext'
8
8
  import omit from 'lodash/omit'
9
9
  import { RecognizerResult, getTopScoringIntent } from './recognizerResult'
10
10
 
11
+ /**
12
+ * Configuration options for a recognizer instance.
13
+ *
14
+ * @remarks
15
+ * This interface defines the configuration properties that can be used to customize
16
+ * the behavior and identification of a recognizer. Recognizers use this configuration
17
+ * to set up their basic properties and operational parameters.
18
+ */
11
19
  export interface RecognizerConfiguration {
20
+ /**
21
+ * Optional unique identifier for the recognizer instance.
22
+ *
23
+ * @remarks
24
+ * The id property allows you to distinguish between multiple recognizer instances
25
+ * and can be useful for logging, debugging, and telemetry purposes. If not provided,
26
+ * the recognizer will operate without a specific identifier.
27
+ */
12
28
  id?: string;
13
29
  }
14
30
 
15
31
  /**
16
32
  * Base class for implementing custom recognizers to identify intents and entities from user input.
17
33
  *
34
+ * @remarks
18
35
  * Recognizers process user input, such as text or speech, and return structured data representing
19
36
  * the recognized intents, entities, and other relevant information. This class provides a foundation
20
37
  * for creating custom recognizers by defining common methods and properties.
@@ -34,6 +34,32 @@ export interface RecognizerResult {
34
34
  [propName: string]: any
35
35
  }
36
36
 
37
+ /**
38
+ * Finds the intent with the highest confidence score from a recognizer result.
39
+ *
40
+ * This function iterates through all intents in the recognizer result and returns
41
+ * the intent name and score for the intent with the highest confidence score.
42
+ * If multiple intents have the same highest score, the last one encountered is returned.
43
+ *
44
+ * @param result - The recognizer result containing intents and their scores
45
+ * @returns An object containing the top-scoring intent name and its confidence score
46
+ * @throws {Error} Throws an error if the result is empty or doesn't contain intents
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * const result: RecognizerResult = {
51
+ * text: "Book a flight to Seattle",
52
+ * intents: {
53
+ * "BookFlight": { score: 0.95 },
54
+ * "Cancel": { score: 0.02 },
55
+ * "Help": { score: 0.03 }
56
+ * }
57
+ * };
58
+ *
59
+ * const topIntent = getTopScoringIntent(result);
60
+ * // Returns: { intent: "BookFlight", score: 0.95 }
61
+ * ```
62
+ */
37
63
  export const getTopScoringIntent = (result: RecognizerResult): { intent: string; score: number } => {
38
64
  if (!result || !result.intents) {
39
65
  throw new Error('result is empty')