@microsoft/agents-hosting-dialogs 1.0.0-ge4831811bf → 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
package/src/dialogContext.ts
CHANGED
|
@@ -80,8 +80,10 @@ export class DialogContext {
|
|
|
80
80
|
* @param dialogs The `DialogSet` for which to create the dialog context.
|
|
81
81
|
* @param contextOrDialogContext The `TurnContext` object for the current turn.
|
|
82
82
|
* @param state The state object to use to read and write `DialogState` to storage.
|
|
83
|
+
*
|
|
83
84
|
* @remarks
|
|
84
85
|
* Passing in a `DialogContext` instance will clone the dialog context.
|
|
86
|
+
*
|
|
85
87
|
*/
|
|
86
88
|
constructor (dialogs: DialogSet, contextOrDialogContext: TurnContext, state: DialogState)
|
|
87
89
|
|
|
@@ -91,8 +93,10 @@ export class DialogContext {
|
|
|
91
93
|
* @param dialogs The `DialogSet` for which to create the dialog context.
|
|
92
94
|
* @param contextOrDialogContext The `DialogContext` object for the current turn.
|
|
93
95
|
* @param state The state object to use to read and write `DialogState` to storage.
|
|
96
|
+
*
|
|
94
97
|
* @remarks
|
|
95
98
|
* Passing in a `DialogContext` instance will clone the dialog context.
|
|
99
|
+
*
|
|
96
100
|
*/
|
|
97
101
|
constructor (dialogs: DialogSet, contextOrDialogContext: DialogContext, state: DialogState)
|
|
98
102
|
|
|
@@ -102,7 +106,10 @@ export class DialogContext {
|
|
|
102
106
|
* @param dialogs The `DialogSet` for which to create the dialog context.
|
|
103
107
|
* @param contextOrDialogContext The `TurnContext` or `DialogContext` for the current turn.
|
|
104
108
|
* @param state The state object to use to read and write `DialogState` to storage.
|
|
105
|
-
*
|
|
109
|
+
*
|
|
110
|
+
* @remarks
|
|
111
|
+
* Passing in a `DialogContext` instance will clone the dialog context.
|
|
112
|
+
*
|
|
106
113
|
*/
|
|
107
114
|
constructor (dialogs: DialogSet, contextOrDialogContext: TurnContext | DialogContext, state: DialogState) {
|
|
108
115
|
this.dialogs = dialogs
|
|
@@ -147,12 +154,15 @@ export class DialogContext {
|
|
|
147
154
|
* When it attempts to start a dialog, the dialog context searches for the {@link Dialog.id}
|
|
148
155
|
* in its {@link DialogContext.dialogs}. If the dialog to start is not found
|
|
149
156
|
* in this dialog context, it searches in its parent dialog context, and so on.
|
|
157
|
+
*
|
|
150
158
|
*/
|
|
151
159
|
parent: DialogContext | undefined
|
|
152
160
|
|
|
153
161
|
/**
|
|
154
|
-
|
|
155
|
-
|
|
162
|
+
* Gets the dialog context for the child if the active dialog is a container.
|
|
163
|
+
*
|
|
164
|
+
* @returns Dialog context for child if the active dialog is a container.
|
|
165
|
+
*/
|
|
156
166
|
get child (): DialogContext | undefined {
|
|
157
167
|
const instance = this.activeDialog
|
|
158
168
|
if (instance !== undefined) {
|
|
@@ -167,9 +177,13 @@ export class DialogContext {
|
|
|
167
177
|
}
|
|
168
178
|
|
|
169
179
|
/**
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
180
|
+
* Gets the state information for the dialog on the top of the dialog stack, or `undefined` if
|
|
181
|
+
* the stack is empty.
|
|
182
|
+
*
|
|
183
|
+
* @returns The state information for the dialog on the top of the dialog stack, or `undefined` if
|
|
184
|
+
* the stack is empty.
|
|
185
|
+
*
|
|
186
|
+
*/
|
|
173
187
|
get activeDialog (): DialogInstance | undefined {
|
|
174
188
|
return this.stack.length > 0 ? this.stack[this.stack.length - 1] : undefined
|
|
175
189
|
}
|
|
@@ -185,8 +199,10 @@ export class DialogContext {
|
|
|
185
199
|
services: TurnContextStateCollection = new TurnContextStateCollection()
|
|
186
200
|
|
|
187
201
|
/**
|
|
188
|
-
|
|
189
|
-
|
|
202
|
+
* Gets the current dialog manager instance.
|
|
203
|
+
*
|
|
204
|
+
* @returns The current dialog manager instance.
|
|
205
|
+
*/
|
|
190
206
|
get dialogManager (): DialogManager {
|
|
191
207
|
return this.context.turnState.get(DialogTurnStateConstants.dialogManager)
|
|
192
208
|
}
|
|
@@ -219,6 +235,7 @@ export class DialogContext {
|
|
|
219
235
|
* @param dialogId ID of the dialog to start.
|
|
220
236
|
* @param options Optional. Arguments to pass into the dialog when it starts.
|
|
221
237
|
* @returns {Promise<DialogTurnResult>} a promise resolving to the dialog turn result.
|
|
238
|
+
*
|
|
222
239
|
* @remarks
|
|
223
240
|
* If there's already an active dialog on the stack, that dialog will be paused until
|
|
224
241
|
* it is again the top dialog on the stack.
|
|
@@ -258,6 +275,7 @@ export class DialogContext {
|
|
|
258
275
|
* @param eventName Optional. Name of a custom event to raise as dialogs are cancelled. This defaults to DialogEvents.cancelDialog.
|
|
259
276
|
* @param eventValue Optional. Value to pass along with custom cancellation event.
|
|
260
277
|
* @returns {Promise<DialogTurnResult>} a promise resolving to the dialog turn result.
|
|
278
|
+
*
|
|
261
279
|
* @remarks
|
|
262
280
|
* This calls each dialog's {@link Dialog.endDialog | endDialog method} before
|
|
263
281
|
* removing the dialog from the stack.
|
|
@@ -305,6 +323,7 @@ export class DialogContext {
|
|
|
305
323
|
*
|
|
306
324
|
* @param dialogId ID of the dialog to search for.
|
|
307
325
|
* @returns The dialog for the provided ID.
|
|
326
|
+
*
|
|
308
327
|
* @remarks
|
|
309
328
|
* If the dialog to start is not found in the {@link DialogSet} associated
|
|
310
329
|
* with this dialog context, it attempts to find the dialog in its parent dialog context.
|
|
@@ -345,6 +364,7 @@ export class DialogContext {
|
|
|
345
364
|
* the object with which to format the prompt dialog.
|
|
346
365
|
* @param choices Optional. Array of choices for the user to choose from,
|
|
347
366
|
* for use with a {@link ChoicePrompt}.
|
|
367
|
+
*
|
|
348
368
|
* @remarks
|
|
349
369
|
* This helper method formats the object to use as the `options` parameter, and then calls
|
|
350
370
|
* {@link DialogContext.beginDialog} to start the specified prompt dialog.
|
|
@@ -365,7 +385,9 @@ export class DialogContext {
|
|
|
365
385
|
* @param choices Optional. Array of choices for the user to choose from,
|
|
366
386
|
* for use with a {@link ChoicePrompt}.
|
|
367
387
|
* @returns {Promise<DialogTurnResult>} a promise resolving to the dialog turn result.
|
|
368
|
-
*
|
|
388
|
+
*
|
|
389
|
+
* @remarks
|
|
390
|
+
* This helper method formats the object to use as the `options` parameter, and then calls
|
|
369
391
|
* {@link DialogContext.beginDialog} to start the specified prompt dialog.
|
|
370
392
|
*
|
|
371
393
|
*/
|
|
@@ -396,6 +418,7 @@ export class DialogContext {
|
|
|
396
418
|
* {@link DialogContext.continueDialog} method.
|
|
397
419
|
*
|
|
398
420
|
* @returns {Promise<DialogTurnResult>} a promise resolving to the dialog turn result.
|
|
421
|
+
*
|
|
399
422
|
* @remarks
|
|
400
423
|
* After the call completes, you can check the turn context's {@link @microsoft/agents-hosting.TurnContext.responded | TurnContext.responded}
|
|
401
424
|
* property to determine if the dialog sent a reply to the user.
|
|
@@ -443,6 +466,7 @@ export class DialogContext {
|
|
|
443
466
|
* on the stack, or if this was the last dialog on the stack, a parent dialog context or
|
|
444
467
|
* the agent's turn handler.
|
|
445
468
|
* @returns {Promise<DialogTurnResult>} a promise resolving to the dialog turn result.
|
|
469
|
+
*
|
|
446
470
|
* @remarks
|
|
447
471
|
* The _parent_ dialog is the next dialog on the dialog stack, if there is one. This method
|
|
448
472
|
* calls the parent's {@link Dialog.resumeDialog} method,
|
|
@@ -488,6 +512,7 @@ export class DialogContext {
|
|
|
488
512
|
* @param dialogId ID of the dialog to start.
|
|
489
513
|
* @param options Optional. Arguments to pass into the new dialog when it starts.
|
|
490
514
|
* @returns {Promise<DialogTurnResult>} a promise resolving to the dialog turn result.
|
|
515
|
+
*
|
|
491
516
|
* @remarks
|
|
492
517
|
* This is particularly useful for creating a loop or redirecting to another dialog.
|
|
493
518
|
*
|
|
@@ -538,13 +563,14 @@ export class DialogContext {
|
|
|
538
563
|
/**
|
|
539
564
|
* Searches for a dialog with a given ID.
|
|
540
565
|
*
|
|
541
|
-
* @remarks
|
|
542
|
-
* Emits a named event for the current dialog, or someone who started it, to handle.
|
|
543
566
|
* @param name Name of the event to raise.
|
|
544
567
|
* @param value Optional. Value to send along with the event.
|
|
545
568
|
* @param bubble Optional. Flag to control whether the event should be bubbled to its parent if not handled locally. Defaults to a value of `true`.
|
|
546
569
|
* @param fromLeaf Optional. Whether the event is emitted from a leaf node.
|
|
547
570
|
* @returns `true` if the event was handled.
|
|
571
|
+
*
|
|
572
|
+
* @remarks
|
|
573
|
+
* Emits a named event for the current dialog, or someone who started it, to handle.
|
|
548
574
|
*/
|
|
549
575
|
async emitEvent (name: string, value?: any, bubble = true, fromLeaf = false): Promise<boolean> {
|
|
550
576
|
// Initialize event
|
package/src/dialogInstance.ts
CHANGED
|
@@ -11,22 +11,22 @@
|
|
|
11
11
|
*/
|
|
12
12
|
export interface DialogInstance<T = any> {
|
|
13
13
|
/**
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
* ID of this dialog
|
|
15
|
+
*
|
|
16
|
+
* @remarks
|
|
17
|
+
* Dialog state is associated with a specific dialog set.
|
|
18
|
+
* This ID is the the dialog's Dialog.id within that dialog set.
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
21
|
id: string;
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
* The state information for this instance of this dialog.
|
|
25
|
+
*/
|
|
26
26
|
state: T;
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
* Hash code used to detect that a dialog has changed since the current instance was started.
|
|
30
|
+
*/
|
|
31
31
|
version?: string;
|
|
32
32
|
}
|
package/src/dialogReason.ts
CHANGED
|
@@ -8,33 +8,33 @@
|
|
|
8
8
|
*/
|
|
9
9
|
export enum DialogReason {
|
|
10
10
|
/**
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
* The dialog is being started from DialogContext.beginDialog or DialogContext.replaceDialog.
|
|
12
|
+
*/
|
|
13
13
|
beginCalled = 'beginCalled',
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
* The dialog is being continued from DialogContext.continueDialog.
|
|
17
|
+
*/
|
|
18
18
|
continueCalled = 'continueCalled',
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
* The dialog is being ended from DialogContext.endDialog.
|
|
22
|
+
*/
|
|
23
23
|
endCalled = 'endCalled',
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
* The dialog is being ended from DialogContext.replaceDialog.
|
|
27
|
+
*/
|
|
28
28
|
replaceCalled = 'replaceCalled',
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
* The dialog is being cancelled from DialogContext.cancelAllDialogs.
|
|
32
|
+
*/
|
|
33
33
|
cancelCalled = 'cancelCalled',
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
* A step in a WaterfallDialog is being called
|
|
37
|
+
* because the previous step in the waterfall dialog called WaterfallStepContext.next.
|
|
38
|
+
*/
|
|
39
39
|
nextCalled = 'nextCalled',
|
|
40
40
|
}
|
package/src/dialogSet.ts
CHANGED
|
@@ -12,7 +12,7 @@ import { DialogContext, DialogState } from './dialogContext'
|
|
|
12
12
|
import { StringUtils } from './stringUtils'
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* Interface for dialogs that have child dialog dependencies.
|
|
16
16
|
*
|
|
17
17
|
* @remarks
|
|
18
18
|
* Implement this interface on dialog classes that need to register child dialogs
|
|
@@ -38,7 +38,7 @@ import { StringUtils } from './stringUtils'
|
|
|
38
38
|
*/
|
|
39
39
|
export interface DialogDependencies {
|
|
40
40
|
/**
|
|
41
|
-
*
|
|
41
|
+
* Returns an array of child dialogs that this dialog depends on.
|
|
42
42
|
*
|
|
43
43
|
*
|
|
44
44
|
* @remarks
|
|
@@ -76,12 +76,13 @@ export class DialogSet {
|
|
|
76
76
|
/**
|
|
77
77
|
* Creates a new DialogSet instance.
|
|
78
78
|
*
|
|
79
|
+
* @param dialogState (Optional) state property used to persist the sets dialog stack.
|
|
80
|
+
*
|
|
79
81
|
* @remarks
|
|
80
82
|
* If the `dialogState` parameter is not passed in, calls to `createContext`
|
|
81
83
|
* will return an error. You will need to create a {@link DialogContext} for the set manually and
|
|
82
84
|
* pass in your own state object for persisting the sets dialog stack:
|
|
83
85
|
*
|
|
84
|
-
* @param dialogState (Optional) state property used to persist the sets dialog stack.
|
|
85
86
|
*/
|
|
86
87
|
constructor (dialogState?: AgentStatePropertyAccessor<DialogState>) {
|
|
87
88
|
this.dialogState = dialogState
|
|
@@ -91,8 +92,10 @@ export class DialogSet {
|
|
|
91
92
|
* Returns a 32-bit hash of the all the `Dialog.version` values in the set.
|
|
92
93
|
*
|
|
93
94
|
* @returns A version that will change when any of the child dialogs version changes.
|
|
95
|
+
*
|
|
94
96
|
* @remarks
|
|
95
97
|
* This hash is persisted to state storage and used to detect changes to a dialog set.
|
|
98
|
+
*
|
|
96
99
|
*/
|
|
97
100
|
getVersion (): string {
|
|
98
101
|
if (!this._version) {
|
|
@@ -112,14 +115,15 @@ export class DialogSet {
|
|
|
112
115
|
/**
|
|
113
116
|
* Adds a new dialog or prompt to the set.
|
|
114
117
|
*
|
|
118
|
+
* @param dialog The dialog or prompt to add.
|
|
119
|
+
* If a telemetryClient is present on the dialog set, it will be added to each dialog.
|
|
120
|
+
* @returns The dialog set after the operation is complete.
|
|
121
|
+
*
|
|
115
122
|
* @remarks
|
|
116
123
|
* If the {@link Dialog.id} being added already exists in the set, the dialogs id will be updated to
|
|
117
124
|
* include a suffix which makes it unique. So adding 2 dialogs named "duplicate" to the set
|
|
118
125
|
* would result in the first one having an id of "duplicate" and the second one having an id
|
|
119
126
|
* of "duplicate2".
|
|
120
|
-
* @param dialog The dialog or prompt to add.
|
|
121
|
-
* If a telemetryClient is present on the dialog set, it will be added to each dialog.
|
|
122
|
-
* @returns The dialog set after the operation is complete.
|
|
123
127
|
*/
|
|
124
128
|
add<T extends Dialog>(dialog: T): this {
|
|
125
129
|
if (!(dialog instanceof Dialog)) {
|
|
@@ -184,6 +188,7 @@ export class DialogSet {
|
|
|
184
188
|
|
|
185
189
|
/**
|
|
186
190
|
* Finds a dialog that was previously added to the set using add.
|
|
191
|
+
*
|
|
187
192
|
* @param dialogId ID of the dialog or prompt to lookup.
|
|
188
193
|
* @returns The dialog if found; otherwise undefined.
|
|
189
194
|
*/
|
package/src/dialogTurnResult.ts
CHANGED
package/src/dialogTurnStatus.ts
CHANGED
|
@@ -129,12 +129,14 @@ export class DialogStateManager {
|
|
|
129
129
|
/**
|
|
130
130
|
* Get the value from memory using path expression.
|
|
131
131
|
*
|
|
132
|
-
* @remarks
|
|
133
|
-
* This always returns a CLONE of the memory, any modifications to the result will not affect memory.
|
|
134
132
|
* @typeParam T The value type to return.
|
|
135
133
|
* @param pathExpression Path expression to use.
|
|
136
134
|
* @param defaultValue (Optional) default value to use if the path isn't found. May be a function that returns the default value to use.
|
|
137
135
|
* @returns The found value or undefined if not found and no `defaultValue` specified.
|
|
136
|
+
*
|
|
137
|
+
* @remarks
|
|
138
|
+
* This always returns a CLONE of the memory, any modifications to the result will not affect memory.
|
|
139
|
+
*
|
|
138
140
|
*/
|
|
139
141
|
getValue<T = any>(pathExpression: string, defaultValue?: T | (() => T)): T {
|
|
140
142
|
function returnDefault (): T {
|
|
@@ -274,6 +276,7 @@ export class DialogStateManager {
|
|
|
274
276
|
*
|
|
275
277
|
* @remarks
|
|
276
278
|
* This should be called at the beginning of the turn.
|
|
279
|
+
*
|
|
277
280
|
*/
|
|
278
281
|
async loadAllScopes (): Promise<void> {
|
|
279
282
|
const scopes = this.configuration.memoryScopes
|
|
@@ -287,6 +290,7 @@ export class DialogStateManager {
|
|
|
287
290
|
*
|
|
288
291
|
* @remarks
|
|
289
292
|
* This should be called at the end of the turn.
|
|
293
|
+
*
|
|
290
294
|
*/
|
|
291
295
|
async saveAllChanges (): Promise<void> {
|
|
292
296
|
const scopes = this.configuration.memoryScopes
|
|
@@ -315,11 +319,12 @@ export class DialogStateManager {
|
|
|
315
319
|
/**
|
|
316
320
|
* Normalizes the path segments of a passed in path.
|
|
317
321
|
*
|
|
318
|
-
* @remarks
|
|
319
|
-
* A path of `profile.address[0]` will be normalized to `profile.address.0`.
|
|
320
322
|
* @param pathExpression The path to normalize.
|
|
321
323
|
* @param allowNestedPaths Optional. If `false` then detection of a nested path will cause an empty path to be returned. Defaults to 'true'.
|
|
322
324
|
* @returns The normalized path.
|
|
325
|
+
*
|
|
326
|
+
* @remarks
|
|
327
|
+
* A path of `profile.address[0]` will be normalized to `profile.address.0`.
|
|
323
328
|
*/
|
|
324
329
|
parsePath (pathExpression: string, allowNestedPaths = true): (string | number)[] {
|
|
325
330
|
// Expand path segments
|
|
@@ -41,9 +41,11 @@ export class ActivityPrompt extends Dialog {
|
|
|
41
41
|
* @param options PromptOptions, additional
|
|
42
42
|
* information to pass to the prompt being started.
|
|
43
43
|
* @returns A `Promise` representing the asynchronous operation.
|
|
44
|
+
*
|
|
44
45
|
* @remarks
|
|
45
46
|
* If the promise is successful, the result indicates whether the prompt is still
|
|
46
47
|
* active after the turn has been processed by the prompt.
|
|
48
|
+
*
|
|
47
49
|
*/
|
|
48
50
|
async beginDialog (dialogContext: DialogContext, options: PromptOptions): Promise<DialogTurnResult> {
|
|
49
51
|
// Ensure prompts have input hint set
|
|
@@ -72,11 +74,13 @@ export class ActivityPrompt extends Dialog {
|
|
|
72
74
|
* @param dialogContext The DialogContext for the current
|
|
73
75
|
* turn of conversation.
|
|
74
76
|
* @returns A `Promise` representing the asynchronous operation.
|
|
77
|
+
*
|
|
75
78
|
* @remarks
|
|
76
79
|
* If the promise is successful, the result indicates whether the dialog is still
|
|
77
80
|
* active after the turn has been processed by the dialog.
|
|
78
81
|
* The prompt generally continues to receive the user's replies until it accepts the
|
|
79
82
|
* user's reply as valid input for the prompt.
|
|
83
|
+
*
|
|
80
84
|
*/
|
|
81
85
|
async continueDialog (dialogContext: DialogContext): Promise<DialogTurnResult> {
|
|
82
86
|
// Perform base recognition
|
|
@@ -11,6 +11,7 @@ import { Attachment, InputHints } from '@microsoft/agents-activity'
|
|
|
11
11
|
*
|
|
12
12
|
* @remarks
|
|
13
13
|
* By default the prompt will return to the calling dialog an `Attachment[]`.
|
|
14
|
+
*
|
|
14
15
|
*/
|
|
15
16
|
export class AttachmentPrompt extends Prompt<Attachment[]> {
|
|
16
17
|
// eslint-disable-next-line @typescript-eslint/no-useless-constructor
|
|
@@ -16,6 +16,7 @@ import { Activity } from '@microsoft/agents-activity'
|
|
|
16
16
|
* @remarks
|
|
17
17
|
* This interface is used to define the default options for rendering choices in prompts,
|
|
18
18
|
* such as separators, inline options, and whether to include numbers.
|
|
19
|
+
*
|
|
19
20
|
*/
|
|
20
21
|
export interface ChoiceDefaultsChoicePrompt {
|
|
21
22
|
/**
|
|
@@ -24,6 +25,7 @@ export interface ChoiceDefaultsChoicePrompt {
|
|
|
24
25
|
* @remarks
|
|
25
26
|
* Each locale key maps to a `ChoiceFactoryOptions` object that defines the
|
|
26
27
|
* default behavior for rendering choices in that locale.
|
|
28
|
+
*
|
|
27
29
|
*/
|
|
28
30
|
[locale: string]: ChoiceFactoryOptions;
|
|
29
31
|
}
|
|
@@ -34,6 +36,7 @@ export interface ChoiceDefaultsChoicePrompt {
|
|
|
34
36
|
* @remarks
|
|
35
37
|
* By default the prompt will return to the calling dialog a {@link FoundChoice} object containing the
|
|
36
38
|
* choice that was selected.
|
|
39
|
+
*
|
|
37
40
|
*/
|
|
38
41
|
export class ChoicePrompt extends Prompt<FoundChoice> {
|
|
39
42
|
/**
|
|
@@ -52,6 +55,7 @@ export class ChoicePrompt extends Prompt<FoundChoice> {
|
|
|
52
55
|
*
|
|
53
56
|
* @remarks
|
|
54
57
|
* Defaults to `ListStyle.auto`.
|
|
58
|
+
*
|
|
55
59
|
*/
|
|
56
60
|
style: ListStyle
|
|
57
61
|
|
|
@@ -10,7 +10,7 @@ import { PromptCultureModels } from './promptCultureModels'
|
|
|
10
10
|
import { Activity } from '@microsoft/agents-activity'
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* Defines locale-specific choice defaults for confirmation prompts.
|
|
14
14
|
*
|
|
15
15
|
* @remarks
|
|
16
16
|
* This interface represents a dictionary that maps locale strings to their corresponding
|
|
@@ -50,6 +50,7 @@ export interface ChoiceDefaultsConfirmPrompt {
|
|
|
50
50
|
* @remarks
|
|
51
51
|
* The key is a locale string (e.g., 'en-us', 'fr-fr', 'de-de') and the value
|
|
52
52
|
* contains the localized choices and formatting options for that locale.
|
|
53
|
+
*
|
|
53
54
|
*/
|
|
54
55
|
[locale: string]: {
|
|
55
56
|
/**
|
|
@@ -71,6 +72,7 @@ export interface ChoiceDefaultsConfirmPrompt {
|
|
|
71
72
|
* @remarks
|
|
72
73
|
* By default the prompt will return to the calling dialog a `boolean` representing the users
|
|
73
74
|
* selection.
|
|
75
|
+
*
|
|
74
76
|
*/
|
|
75
77
|
export class ConfirmPrompt extends Prompt<boolean> {
|
|
76
78
|
/**
|
|
@@ -89,6 +91,7 @@ export class ConfirmPrompt extends Prompt<boolean> {
|
|
|
89
91
|
*
|
|
90
92
|
* @remarks
|
|
91
93
|
* Defaults to {@link ListStyle.auto}.
|
|
94
|
+
*
|
|
92
95
|
*/
|
|
93
96
|
style: ListStyle
|
|
94
97
|
|
package/src/prompts/prompt.ts
CHANGED
|
@@ -103,7 +103,10 @@ export interface PromptRecognizerResult<T> {
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
/**
|
|
106
|
-
*
|
|
106
|
+
* Function signature for providing a custom prompt validator.
|
|
107
|
+
*
|
|
108
|
+
* @param T Type of recognizer result being validated.
|
|
109
|
+
* @param prompt Contextual information containing the recognizer result and original options passed to the prompt.
|
|
107
110
|
*
|
|
108
111
|
* @remarks
|
|
109
112
|
* The validator should be an asynchronous function that returns `true` if
|
|
@@ -118,8 +121,7 @@ export interface PromptRecognizerResult<T> {
|
|
|
118
121
|
* ```typescript
|
|
119
122
|
* type PromptValidator<T> = (prompt: PromptValidatorContext<T>) => Promise<boolean>;
|
|
120
123
|
* ```
|
|
121
|
-
*
|
|
122
|
-
* @param prompt Contextual information containing the recognizer result and original options passed to the prompt.
|
|
124
|
+
*
|
|
123
125
|
*/
|
|
124
126
|
export type PromptValidator<T> = (prompt: PromptValidatorContext<T>) => Promise<boolean>
|
|
125
127
|
|
|
@@ -134,6 +136,7 @@ export interface PromptValidatorContext<T> {
|
|
|
134
136
|
*
|
|
135
137
|
* @remarks
|
|
136
138
|
* The validator can use this to re-prompt the user.
|
|
139
|
+
*
|
|
137
140
|
*/
|
|
138
141
|
readonly context: TurnContext;
|
|
139
142
|
|
|
@@ -143,6 +146,7 @@ export interface PromptValidatorContext<T> {
|
|
|
143
146
|
* @remarks
|
|
144
147
|
* The {@link @microsoft/agents-hosting-dialogs.PromptRecognizerResult.succeeded | recognized.succeeded} field can be checked to determine of the recognizer found
|
|
145
148
|
* anything and then the value can be retrieved from {@link @microsoft/agents-hosting-dialogs.PromptRecognizerResult.value | recognized.value}.
|
|
149
|
+
*
|
|
146
150
|
*/
|
|
147
151
|
readonly recognized: PromptRecognizerResult<T>;
|
|
148
152
|
|
|
@@ -151,6 +155,7 @@ export interface PromptValidatorContext<T> {
|
|
|
151
155
|
*
|
|
152
156
|
* @remarks
|
|
153
157
|
* The validator can use this to persist things like turn counts or other state information.
|
|
158
|
+
*
|
|
154
159
|
*/
|
|
155
160
|
readonly state: object;
|
|
156
161
|
|
|
@@ -159,6 +164,7 @@ export interface PromptValidatorContext<T> {
|
|
|
159
164
|
*
|
|
160
165
|
* @remarks
|
|
161
166
|
* The validator can extend this interface to support additional prompt options.
|
|
167
|
+
*
|
|
162
168
|
*/
|
|
163
169
|
readonly options: PromptOptions;
|
|
164
170
|
|
|
@@ -166,6 +172,7 @@ export interface PromptValidatorContext<T> {
|
|
|
166
172
|
* A count of the number of times the prompt has been executed.
|
|
167
173
|
*
|
|
168
174
|
* A number indicating how many times the prompt was invoked (starting at 1 for the first time it was invoked).
|
|
175
|
+
*
|
|
169
176
|
*/
|
|
170
177
|
readonly attemptCount: number;
|
|
171
178
|
}
|
|
@@ -197,9 +204,11 @@ export abstract class Prompt<T> extends Dialog {
|
|
|
197
204
|
* @param options Optional. PromptOptions,
|
|
198
205
|
* additional information to pass to the prompt being started.
|
|
199
206
|
* @returns A `Promise` representing the asynchronous operation.
|
|
207
|
+
*
|
|
200
208
|
* @remarks
|
|
201
209
|
* If the task is successful, the result indicates whether the prompt is still
|
|
202
210
|
* active after the turn has been processed by the prompt.
|
|
211
|
+
*
|
|
203
212
|
*/
|
|
204
213
|
async beginDialog (dialogContext: DialogContext, options: PromptOptions): Promise<DialogTurnResult> {
|
|
205
214
|
// Ensure prompts have input hint set
|
|
@@ -227,11 +236,13 @@ export abstract class Prompt<T> extends Dialog {
|
|
|
227
236
|
*
|
|
228
237
|
* @param dialogContext The DialogContext for the current turn of conversation.
|
|
229
238
|
* @returns A `Promise` representing the asynchronous operation.
|
|
239
|
+
*
|
|
230
240
|
* @remarks
|
|
231
241
|
* If the task is successful, the result indicates whether the dialog is still
|
|
232
242
|
* active after the turn has been processed by the dialog.
|
|
233
243
|
* The prompt generally continues to receive the user's replies until it accepts the
|
|
234
244
|
* user's reply as valid input for the prompt.
|
|
245
|
+
*
|
|
235
246
|
*/
|
|
236
247
|
async continueDialog (dialogContext: DialogContext): Promise<DialogTurnResult> {
|
|
237
248
|
// Don't do anything for non-message activities
|
|
@@ -288,10 +299,12 @@ export abstract class Prompt<T> extends Dialog {
|
|
|
288
299
|
* @param dialogContext The DialogContext for the current turn of conversation.
|
|
289
300
|
* @param event DialogEvent, the event being raised.
|
|
290
301
|
* @returns Whether the event is handled by the current dialog and further processing should stop.
|
|
302
|
+
*
|
|
291
303
|
* @remarks
|
|
292
304
|
* This is a good place to perform interception of an event as returning `true` will prevent
|
|
293
305
|
* any further bubbling of the event to the dialogs parents and will also prevent any child
|
|
294
306
|
* dialogs from performing their default processing.
|
|
307
|
+
*
|
|
295
308
|
*/
|
|
296
309
|
protected async onPreBubbleEvent (dialogContext: DialogContext, event: DialogEvent): Promise<boolean> {
|
|
297
310
|
if (event.name === 'activityReceived' && dialogContext.context.activity.type === ActivityTypes.Message) {
|
|
@@ -317,9 +330,11 @@ export abstract class Prompt<T> extends Dialog {
|
|
|
317
330
|
* @param _result Optional, value returned from the previous dialog on the stack.
|
|
318
331
|
* The type of the value returned is dependent on the previous dialog.
|
|
319
332
|
* @returns A Promise representing the asynchronous operation.
|
|
333
|
+
*
|
|
320
334
|
* @remarks
|
|
321
335
|
* If the task is successful, the result indicates whether the dialog is still
|
|
322
336
|
* active after the turn has been processed by the dialog.
|
|
337
|
+
*
|
|
323
338
|
*/
|
|
324
339
|
async resumeDialog (dialogContext: DialogContext, _reason: DialogReason, _result?: any): Promise<DialogTurnResult> {
|
|
325
340
|
// Prompts are typically leaf nodes on the stack but the dev is free to push other dialogs
|
|
@@ -364,12 +379,13 @@ export abstract class Prompt<T> extends Dialog {
|
|
|
364
379
|
/**
|
|
365
380
|
* Called to recognize an utterance received from the user.
|
|
366
381
|
*
|
|
367
|
-
* @remarks
|
|
368
|
-
* The Prompt class filters out non-message activities so its safe to assume that the users
|
|
369
|
-
* utterance can be retrieved from `context.activity.text`.
|
|
370
382
|
* @param context Context for the current turn of conversation with the user.
|
|
371
383
|
* @param state Additional state being persisted for the prompt.
|
|
372
384
|
* @param options Options that the prompt was started with in the call to `DialogContext.prompt()`.
|
|
385
|
+
*
|
|
386
|
+
* @remarks
|
|
387
|
+
* The Prompt class filters out non-message activities so its safe to assume that the users
|
|
388
|
+
* utterance can be retrieved from `context.activity.text`.
|
|
373
389
|
*/
|
|
374
390
|
protected abstract onRecognize (
|
|
375
391
|
context: TurnContext,
|