/** * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ import { TurnContext, AgentState, ConversationState, UserState, TurnContextStateCollection } from '@microsoft/agents-hosting'; import { Configurable } from './configurable'; import { DialogSet } from './dialogSet'; import { Dialog } from './dialog'; import { DialogStateManagerConfiguration } from './memory'; import { DialogTurnResult } from './dialogTurnResult'; /** * Result returned by the DialogManager after processing a conversation turn. * Contains the outcome of dialog execution and any state changes that occurred during the turn. */ export interface DialogManagerResult { /** * The result of executing the dialog during this conversation turn. * Contains information about the dialog's completion state, any returned values, * and whether the dialog is waiting for additional input from the user. */ turnResult: DialogTurnResult; } /** * Configuration interface for DialogManager instances. * Defines the required and optional settings needed to initialize and configure a dialog manager. */ export interface DialogManagerConfiguration { /** * The conversation state storage for maintaining dialog state across turns. * This is required and manages the dialog stack and conversation-scoped data. */ conversationState: AgentState; /** * The root dialog that will be started when the dialog manager begins execution. * This dialog serves as the entry point for the conversation flow. */ rootDialog: Dialog; /** * Optional user state storage for maintaining user-scoped data across conversations. * When provided, enables persistence of user-specific information beyond individual conversations. */ userState?: UserState; /** * Optional timeout duration in milliseconds after which inactive conversations expire. * When set, conversations that haven't been accessed within this timeframe will have their state cleared. * If not specified, conversations will not automatically expire. */ expireAfter?: number; /** * Optional configuration for the dialog state manager. * Provides advanced settings for how dialog state is managed and persisted. */ stateConfiguration?: DialogStateManagerConfiguration; } /** * Class which runs the dialog system. * */ export declare class DialogManager extends Configurable { private _rootDialogId; private readonly _dialogStateProperty; private readonly _initialTurnState; /** * Creates an instance of the DialogManager class. * * @param rootDialog Optional, root Dialog to use. * @param dialogStateProperty Optional, alternate name for the dialogState property. (Default is "DialogStateProperty") */ constructor(rootDialog?: Dialog, dialogStateProperty?: string); conversationState: ConversationState; userState?: UserState; /** * Values that will be copied to the `TurnContext.turnState` at the beginning of each turn. * * @returns The turn state collection. */ get initialTurnState(): TurnContextStateCollection; /** * Root dialog to start from [onTurn()](#onturn) method. */ set rootDialog(value: Dialog); /** * Gets the root Dialog ID. * * @returns The root Dialog ID. */ get rootDialog(): Dialog; dialogs: DialogSet; stateConfiguration?: DialogStateManagerConfiguration; expireAfter?: number; /** * Set configuration settings. * * @param config Configuration settings to apply. * @returns The cofigured DialogManager context. */ configure(config: Partial): this; /** * Runs dialog system in the context of a TurnContext. * * @param context TurnContext for the current turn of conversation with the user. * @returns Result of running the logic against the activity. */ onTurn(context: TurnContext): Promise; private registerContainerDialogs; }