@microsoft/agents-hosting-dialogs 1.0.0 → 1.0.3-g444d99f704
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.
- package/dist/src/agentStateSet.d.ts +30 -27
- package/dist/src/agentStateSet.js +30 -27
- package/dist/src/agentStateSet.js.map +1 -1
- package/dist/src/choices/findValues.d.ts +21 -12
- package/dist/src/choices/findValues.js +8 -5
- package/dist/src/choices/findValues.js.map +1 -1
- package/dist/src/componentDialog.d.ts +117 -95
- package/dist/src/componentDialog.js +106 -84
- package/dist/src/componentDialog.js.map +1 -1
- package/dist/src/dialog.d.ts +15 -10
- package/dist/src/dialog.js +15 -10
- package/dist/src/dialog.js.map +1 -1
- package/dist/src/dialogContainer.d.ts +5 -2
- package/dist/src/dialogContainer.js +5 -2
- package/dist/src/dialogContainer.js.map +1 -1
- package/dist/src/dialogContext.d.ts +30 -9
- package/dist/src/dialogContext.js +31 -11
- package/dist/src/dialogContext.js.map +1 -1
- package/dist/src/dialogInstance.d.ts +11 -11
- package/dist/src/dialogReason.d.ts +13 -13
- package/dist/src/dialogReason.js +13 -13
- package/dist/src/dialogReason.js.map +1 -1
- package/dist/src/dialogSet.d.ts +11 -6
- package/dist/src/dialogSet.js +9 -4
- package/dist/src/dialogSet.js.map +1 -1
- package/dist/src/dialogTurnResult.d.ts +1 -0
- package/dist/src/dialogTurnStateConstants.d.ts +1 -0
- package/dist/src/dialogTurnStateConstants.js +1 -0
- package/dist/src/dialogTurnStateConstants.js.map +1 -1
- package/dist/src/dialogTurnStatus.d.ts +1 -0
- package/dist/src/dialogTurnStatus.js +1 -0
- package/dist/src/dialogTurnStatus.js.map +1 -1
- package/dist/src/memory/dialogStateManager.d.ts +9 -4
- package/dist/src/memory/dialogStateManager.js +9 -4
- package/dist/src/memory/dialogStateManager.js.map +1 -1
- package/dist/src/prompts/activityPrompt.d.ts +4 -0
- package/dist/src/prompts/activityPrompt.js +4 -0
- package/dist/src/prompts/activityPrompt.js.map +1 -1
- package/dist/src/prompts/attachmentPrompt.d.ts +1 -0
- package/dist/src/prompts/attachmentPrompt.js +1 -0
- package/dist/src/prompts/attachmentPrompt.js.map +1 -1
- package/dist/src/prompts/choicePrompt.d.ts +4 -0
- package/dist/src/prompts/choicePrompt.js +1 -0
- package/dist/src/prompts/choicePrompt.js.map +1 -1
- package/dist/src/prompts/confirmPrompt.d.ts +4 -1
- package/dist/src/prompts/confirmPrompt.js +1 -0
- package/dist/src/prompts/confirmPrompt.js.map +1 -1
- package/dist/src/prompts/datetimePrompt.d.ts +1 -0
- package/dist/src/prompts/datetimePrompt.js +1 -0
- package/dist/src/prompts/datetimePrompt.js.map +1 -1
- package/dist/src/prompts/numberPrompt.d.ts +1 -0
- package/dist/src/prompts/numberPrompt.js +1 -0
- package/dist/src/prompts/numberPrompt.js.map +1 -1
- package/dist/src/prompts/prompt.d.ts +22 -6
- package/dist/src/prompts/prompt.js +8 -0
- package/dist/src/prompts/prompt.js.map +1 -1
- package/dist/src/prompts/promptCultureModels.d.ts +16 -1
- package/dist/src/prompts/promptCultureModels.js +4 -1
- package/dist/src/prompts/promptCultureModels.js.map +1 -1
- package/dist/src/prompts/textPrompt.d.ts +3 -0
- package/dist/src/prompts/textPrompt.js +3 -0
- package/dist/src/prompts/textPrompt.js.map +1 -1
- package/dist/src/recognizer.d.ts +3 -0
- package/dist/src/recognizer.js +1 -0
- package/dist/src/recognizer.js.map +1 -1
- package/dist/src/recognizerResult.d.ts +5 -4
- package/dist/src/recognizerResult.js +5 -4
- package/dist/src/recognizerResult.js.map +1 -1
- package/dist/src/stringUtils.d.ts +4 -3
- package/dist/src/stringUtils.js +4 -3
- package/dist/src/stringUtils.js.map +1 -1
- package/dist/src/waterfallDialog.d.ts +11 -4
- package/dist/src/waterfallDialog.js +11 -4
- package/dist/src/waterfallDialog.js.map +1 -1
- package/package.json +2 -2
- package/src/agentStateSet.ts +30 -27
- package/src/choices/findValues.ts +21 -12
- package/src/componentDialog.ts +127 -97
- package/src/dialog.ts +15 -10
- package/src/dialogContainer.ts +5 -2
- package/src/dialogContext.ts +37 -11
- package/src/dialogInstance.ts +11 -11
- package/src/dialogReason.ts +13 -13
- package/src/dialogSet.ts +11 -6
- package/src/dialogTurnResult.ts +1 -0
- package/src/dialogTurnStateConstants.ts +1 -0
- package/src/dialogTurnStatus.ts +1 -0
- package/src/memory/dialogStateManager.ts +9 -4
- package/src/prompts/activityPrompt.ts +4 -0
- package/src/prompts/attachmentPrompt.ts +1 -0
- package/src/prompts/choicePrompt.ts +4 -0
- package/src/prompts/confirmPrompt.ts +4 -1
- package/src/prompts/datetimePrompt.ts +1 -0
- package/src/prompts/numberPrompt.ts +1 -0
- package/src/prompts/prompt.ts +22 -6
- package/src/prompts/promptCultureModels.ts +16 -1
- package/src/prompts/textPrompt.ts +3 -0
- package/src/recognizer.ts +3 -0
- package/src/recognizerResult.ts +5 -4
- package/src/stringUtils.ts +4 -3
- package/src/waterfallDialog.ts +11 -4
|
@@ -8,6 +8,8 @@ import { Culture } from '@microsoft/recognizers-text-suite'
|
|
|
8
8
|
export interface PromptCultureModel {
|
|
9
9
|
/**
|
|
10
10
|
* The locale identifier for this culture model.
|
|
11
|
+
*
|
|
12
|
+
* @remarks
|
|
11
13
|
* This follows the standard IETF language tag format (e.g., "en-US", "fr-FR", "ja-JP").
|
|
12
14
|
* Used to identify the target language and region for localization.
|
|
13
15
|
*
|
|
@@ -22,6 +24,8 @@ export interface PromptCultureModel {
|
|
|
22
24
|
|
|
23
25
|
/**
|
|
24
26
|
* The separator string used to delimit items in a list when presenting choices.
|
|
27
|
+
*
|
|
28
|
+
* @remarks
|
|
25
29
|
* This is typically used between items in the middle of a list, not before the final item.
|
|
26
30
|
*
|
|
27
31
|
* @example
|
|
@@ -33,6 +37,8 @@ export interface PromptCultureModel {
|
|
|
33
37
|
|
|
34
38
|
/**
|
|
35
39
|
* The conjunction string used before the final item in a two-item list.
|
|
40
|
+
*
|
|
41
|
+
* @remarks
|
|
36
42
|
* This is used when presenting exactly two choices to the user.
|
|
37
43
|
*
|
|
38
44
|
* @example
|
|
@@ -46,6 +52,8 @@ export interface PromptCultureModel {
|
|
|
46
52
|
|
|
47
53
|
/**
|
|
48
54
|
* The conjunction string used before the final item in a list of three or more items.
|
|
55
|
+
*
|
|
56
|
+
* @remarks
|
|
49
57
|
* This combines with the separator to create properly formatted choice lists.
|
|
50
58
|
*
|
|
51
59
|
* @example
|
|
@@ -59,6 +67,8 @@ export interface PromptCultureModel {
|
|
|
59
67
|
|
|
60
68
|
/**
|
|
61
69
|
* The affirmative response word in the target language.
|
|
70
|
+
*
|
|
71
|
+
* @remarks
|
|
62
72
|
* Used in confirmation prompts and boolean choice scenarios.
|
|
63
73
|
*
|
|
64
74
|
* @example
|
|
@@ -72,6 +82,8 @@ export interface PromptCultureModel {
|
|
|
72
82
|
|
|
73
83
|
/**
|
|
74
84
|
* The negative response word in the target language.
|
|
85
|
+
*
|
|
86
|
+
* @remarks
|
|
75
87
|
* Used in confirmation prompts and boolean choice scenarios.
|
|
76
88
|
*
|
|
77
89
|
* @example
|
|
@@ -211,8 +223,11 @@ export class PromptCultureModels {
|
|
|
211
223
|
*
|
|
212
224
|
* @param cultureCode The locale string to normalize (e.g., "en-US").
|
|
213
225
|
* @returns The normalized locale string.
|
|
214
|
-
*
|
|
226
|
+
*
|
|
227
|
+
* @remarks
|
|
228
|
+
* This is mostly a copy/paste from https://github.com/microsoft/Recognizers-Text/blob/master/JavaScript/packages/recognizers-text/src/culture.ts#L39
|
|
215
229
|
* This doesn't directly use Recognizers-Text's MapToNearestLanguage because if they add language support before we do, it will break our prompts.
|
|
230
|
+
*
|
|
216
231
|
*/
|
|
217
232
|
static mapToNearestLanguage (cultureCode: string): string {
|
|
218
233
|
if (cultureCode) {
|
|
@@ -13,6 +13,7 @@ import { InputHints } from '@microsoft/agents-activity'
|
|
|
13
13
|
*
|
|
14
14
|
* @remarks
|
|
15
15
|
* By default the prompt will return to the calling dialog a `string` representing the users reply.
|
|
16
|
+
*
|
|
16
17
|
*/
|
|
17
18
|
export class TextPrompt extends Prompt<string> {
|
|
18
19
|
// eslint-disable-next-line @typescript-eslint/no-useless-constructor
|
|
@@ -72,10 +73,12 @@ export class TextPrompt extends Prompt<string> {
|
|
|
72
73
|
* turn of conversation.
|
|
73
74
|
* @param _event DialogEvent, the event being raised.
|
|
74
75
|
* @returns Whether the event is handled by the current dialog and further processing should stop.
|
|
76
|
+
*
|
|
75
77
|
* @remarks
|
|
76
78
|
* This is a good place to perform interception of an event as returning `true` will prevent
|
|
77
79
|
* any further bubbling of the event to the dialogs parents and will also prevent any child
|
|
78
80
|
* dialogs from performing their default processing.
|
|
81
|
+
*
|
|
79
82
|
*/
|
|
80
83
|
protected async onPreBubbleEvent (_dc: DialogContext, _event: DialogEvent): Promise<boolean> {
|
|
81
84
|
return false
|
package/src/recognizer.ts
CHANGED
|
@@ -15,6 +15,7 @@ import { RecognizerResult, getTopScoringIntent } from './recognizerResult'
|
|
|
15
15
|
* This interface defines the configuration properties that can be used to customize
|
|
16
16
|
* the behavior and identification of a recognizer. Recognizers use this configuration
|
|
17
17
|
* to set up their basic properties and operational parameters.
|
|
18
|
+
*
|
|
18
19
|
*/
|
|
19
20
|
export interface RecognizerConfiguration {
|
|
20
21
|
/**
|
|
@@ -24,6 +25,7 @@ export interface RecognizerConfiguration {
|
|
|
24
25
|
* The id property allows you to distinguish between multiple recognizer instances
|
|
25
26
|
* and can be useful for logging, debugging, and telemetry purposes. If not provided,
|
|
26
27
|
* the recognizer will operate without a specific identifier.
|
|
28
|
+
*
|
|
27
29
|
*/
|
|
28
30
|
id?: string;
|
|
29
31
|
}
|
|
@@ -35,6 +37,7 @@ export interface RecognizerConfiguration {
|
|
|
35
37
|
* Recognizers process user input, such as text or speech, and return structured data representing
|
|
36
38
|
* the recognized intents, entities, and other relevant information. This class provides a foundation
|
|
37
39
|
* for creating custom recognizers by defining common methods and properties.
|
|
40
|
+
*
|
|
38
41
|
*/
|
|
39
42
|
export class Recognizer extends Configurable implements RecognizerConfiguration {
|
|
40
43
|
/**
|
package/src/recognizerResult.ts
CHANGED
|
@@ -35,7 +35,11 @@ export interface RecognizerResult {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
|
-
*
|
|
38
|
+
* Finds the intent with the highest confidence score from a recognizer result.
|
|
39
|
+
*
|
|
40
|
+
* @param result - The recognizer result containing intents and their scores
|
|
41
|
+
* @returns An object containing the top-scoring intent name and its confidence score
|
|
42
|
+
* @throws {Error} Throws an error if the result is empty or doesn't contain intents
|
|
39
43
|
*
|
|
40
44
|
* @remarks
|
|
41
45
|
* This function iterates through all intents in the recognizer result and returns
|
|
@@ -57,9 +61,6 @@ export interface RecognizerResult {
|
|
|
57
61
|
* // Returns: { intent: "BookFlight", score: 0.95 }
|
|
58
62
|
* ```
|
|
59
63
|
*
|
|
60
|
-
* @param result - The recognizer result containing intents and their scores
|
|
61
|
-
* @returns An object containing the top-scoring intent name and its confidence score
|
|
62
|
-
* @throws {Error} Throws an error if the result is empty or doesn't contain intents
|
|
63
64
|
*/
|
|
64
65
|
export const getTopScoringIntent = (result: RecognizerResult): { intent: string; score: number } => {
|
|
65
66
|
if (!result || !result.intents) {
|
package/src/stringUtils.ts
CHANGED
|
@@ -26,12 +26,13 @@ export class StringUtils {
|
|
|
26
26
|
/**
|
|
27
27
|
* UniqueHash - create a unique hash from a string.
|
|
28
28
|
*
|
|
29
|
+
* @param text Text to hash.
|
|
30
|
+
* @returns A string which is an unique hash.
|
|
31
|
+
*
|
|
29
32
|
* @remarks
|
|
30
33
|
* The source for this function was derived from the following article:
|
|
31
|
-
*
|
|
32
34
|
* https://werxltd.com/wp/2010/05/13/javascript-implementation-of-javas-string-hashcode-method/
|
|
33
|
-
*
|
|
34
|
-
* @returns A string which is an unique hash.
|
|
35
|
+
*
|
|
35
36
|
*/
|
|
36
37
|
static hash (text: string): string {
|
|
37
38
|
const length = text.length
|
package/src/waterfallDialog.ts
CHANGED
|
@@ -28,10 +28,12 @@ export class WaterfallDialog<O extends object = {}> extends Dialog<O> {
|
|
|
28
28
|
/**
|
|
29
29
|
* Creates a new waterfall dialog containing the given array of steps.
|
|
30
30
|
*
|
|
31
|
-
* @remarks
|
|
32
|
-
* See the {@link WaterfallDialog.addStep | addStep function} for details on creating a valid step function.
|
|
33
31
|
* @param dialogId Unique ID of the dialog within the component or set its being added to.
|
|
34
32
|
* @param steps (Optional) array of asynchronous waterfall step functions.
|
|
33
|
+
*
|
|
34
|
+
* @remarks
|
|
35
|
+
* See the {@link WaterfallDialog.addStep | addStep function} for details on creating a valid step function.
|
|
36
|
+
|
|
35
37
|
*/
|
|
36
38
|
constructor (dialogId: string, steps?: WaterfallStep<O>[]) {
|
|
37
39
|
super(dialogId)
|
|
@@ -70,9 +72,11 @@ export class WaterfallDialog<O extends object = {}> extends Dialog<O> {
|
|
|
70
72
|
* @param dialogContext The {@link DialogContext} for the current turn of conversation.
|
|
71
73
|
* @param options Optional, initial information to pass to the Dialog.
|
|
72
74
|
* @returns A Promise representing the asynchronous operation.
|
|
75
|
+
*
|
|
73
76
|
* @remarks
|
|
74
77
|
* If the task is successful, the result indicates whether the Dialog is still
|
|
75
78
|
* active after the turn has been processed by the dialog.
|
|
79
|
+
*
|
|
76
80
|
*/
|
|
77
81
|
async beginDialog (dialogContext: DialogContext, options?: O): Promise<DialogTurnResult> {
|
|
78
82
|
const state: WaterfallDialogState = dialogContext.activeDialog.state as WaterfallDialogState
|
|
@@ -91,10 +95,12 @@ export class WaterfallDialog<O extends object = {}> extends Dialog<O> {
|
|
|
91
95
|
*
|
|
92
96
|
* @param dialogContext The {@link DialogContext} for the current turn of conversation.
|
|
93
97
|
* @returns A Promise representing the asynchronous operation.
|
|
98
|
+
*
|
|
94
99
|
* @remarks
|
|
95
100
|
* If the task is successful, the result indicates whether the dialog is still
|
|
96
101
|
* active after the turn has been processed by the dialog. The result may also contain a
|
|
97
102
|
* return value.
|
|
103
|
+
*
|
|
98
104
|
*/
|
|
99
105
|
async continueDialog (dialogContext: DialogContext): Promise<DialogTurnResult> {
|
|
100
106
|
// Don't do anything for non-message activities
|
|
@@ -125,11 +131,12 @@ export class WaterfallDialog<O extends object = {}> extends Dialog<O> {
|
|
|
125
131
|
/**
|
|
126
132
|
* Called when an individual waterfall step is being executed.
|
|
127
133
|
*
|
|
134
|
+
* @param step Context object for the waterfall step to execute.
|
|
135
|
+
* @returns A promise with the DialogTurnResult.
|
|
136
|
+
*
|
|
128
137
|
* @remarks
|
|
129
138
|
* SHOULD be overridden by derived class that want to add custom logging semantics.
|
|
130
139
|
*
|
|
131
|
-
* @param step Context object for the waterfall step to execute.
|
|
132
|
-
* @returns A promise with the DialogTurnResult.
|
|
133
140
|
*/
|
|
134
141
|
protected async onStep (step: WaterfallStepContext<O>): Promise<DialogTurnResult> {
|
|
135
142
|
return await this.steps[step.index](step)
|