import * as Tp from 'thingpedia'; import * as ThingTalk from 'thingtalk'; import type Engine from '../engine'; import ValueCategory from './value-category'; import QueueItem from './dialogue_queue'; import { UserInput } from './user-input'; import { PlatformData } from './protocol'; import type Conversation from './conversation'; import { ConversationState } from './conversation'; import AppExecutor from '../engine/apps/app_executor'; export declare enum CommandAnalysisType { STOP = 0, NEVERMIND = 1, WAKEUP = 2, DEBUG = 3, EXACT_IN_DOMAIN_COMMAND = 4, STRONGLY_CONFIDENT_IN_DOMAIN_COMMAND = 5, CONFIDENT_IN_DOMAIN_COMMAND = 6, NONCONFIDENT_IN_DOMAIN_COMMAND = 7, EXACT_IN_DOMAIN_FOLLOWUP = 8, STRONGLY_CONFIDENT_IN_DOMAIN_FOLLOWUP = 9, CONFIDENT_IN_DOMAIN_FOLLOWUP = 10, NONCONFIDENT_IN_DOMAIN_FOLLOWUP = 11, OUT_OF_DOMAIN_COMMAND = 12 } export declare const enum Confidence { NO = 0, LOW = 1, NORMAL = 2, HIGH = 3, ABSOLUTE = 4 } export interface CommandAnalysisResult { type: CommandAnalysisType; utterance: string; user_target: string; } export interface ReplyResult { messages: Array; expecting: ValueCategory | null; context: string; agent_target: string; } export interface DialogueHandler { priority: Tp.DialogueHandler.Priority; uniqueId: string; icon: string | null; initialize(initialState: StateType | undefined, showWelcome: boolean): Promise; getState(): StateType; reset(): void; analyzeCommand(command: UserInput): Promise; getReply(command: AnalysisType): Promise; getFollowUp(): Promise; } export declare class DialogueLoop { conversation: Conversation; engine: Engine; private _langPack; private _userInputQueue; private _notifyQueue; private _debug; private _agent; private _nlu; private _nlg; private _thingtalkHandler; private _faqHandlers; private _dynamicHandlers; private _currentHandler; private icon; expecting: ValueCategory | null; platformData: PlatformData; choices: string[]; raw: boolean; private _stopped; private _mgrResolve; private _mgrPromise; constructor(conversation: Conversation, engine: Engine, options: { nluServerUrl: string | undefined; nlgServerUrl: string | undefined; useConfidence: boolean; debug: boolean; rng: () => number; faqModels: Record; }); get _(): (x: string) => string; get isAnonymous(): boolean; get hasDebug(): boolean; getState(): Record; debug(...args: unknown[]): void; interpolate(msg: string, args: Record): string; private _formatError; nextCommand(): Promise; private _iterateDialogueHandlers; private _analyzeCommand; private _handleUICommand; private _handleAPICall; private _sendAgentReply; private _handleUserInput; private _initialize; private _loop; nextQueueItem(): Promise; lookingFor(): Promise; fail(msg?: string): Promise; setExpected(expected: ValueCategory | null, raw?: boolean): void; /** * Ask a question to the user. * * This is a legacy method used for certain scripted interactions. */ ask(expected: ValueCategory.YesNo | ValueCategory.PhoneNumber | ValueCategory.EmailAddress | ValueCategory.Location | ValueCategory.Time, question: string, args?: Record): Promise; askChoices(question: string, choices: string[]): Promise; private _resendChoices; replyInterp(msg: string, args?: Record, icon?: string | null): Promise; reply(msg: string, icon?: string | null): Promise; replyGeneric(message: string | Tp.FormatObjects.FormattedObject, icon?: string | null): Promise; replyButton(text: string, json: string): Promise; replyLink(title: string, url: string, state?: ConversationState): Promise; private _isInDefaultState; dispatchNotify(app: AppExecutor, outputType: string, outputValue: Record): void; dispatchNotifyError(app: AppExecutor, error: Error): void; _tryLoop(showWelcome: boolean, initialState: Record | null): Promise; start(showWelcome: boolean, initialState: Record | null): Promise; stop(): Promise; reset(): Promise; private _pushQueueItem; /** * Returns a promise that will resolve when the dialogue loop is * ready to accept the next command from the user. */ private _waitNextCommand; pushCommand(command: UserInput): void; handleCommand(command: UserInput): Promise; } export declare function pickHandler(currentHandler: DialogueHandler | null, expecting: ValueCategory | null, handlerCandidates: Array<{ handler: DialogueHandler; analysis: CommandAnalysisResult; }>, command: UserInput, debug?: boolean): [DialogueHandler | undefined, CommandAnalysisResult];