import * as ThingTalk from 'thingtalk'; import { Ast, Type } from 'thingtalk'; import * as SentenceGeneratorRuntime from '../sentence-generator/runtime'; import * as SentenceGeneratorTypes from '../sentence-generator/types'; export declare type AgentReplyRecord = SentenceGeneratorTypes.AgentReplyRecord; import { SlotBag } from './slot_bag'; import ThingpediaLoader from './load-thingpedia'; export declare const POLICY_NAME = "org.thingpedia.dialogue.transaction"; export declare class ResultInfo { hasStream: boolean; isTable: boolean; isQuestion: boolean; isAggregation: boolean; isList: boolean; argMinMaxField: [string, string] | null; projection: string[] | null; hasError: boolean; hasEmptyResult: boolean; hasSingleResult: boolean; hasLargeResult: boolean; idType: Type | null; constructor(state: Ast.DialogueState, item: Ast.DialogueHistoryItem); } export declare class NextStatementInfo { isAction: boolean; chainParameter: string | null; chainParameterFilled: boolean; isComplete: boolean; missingSlots: Ast.AbstractSlot[]; constructor(currentItem: Ast.DialogueHistoryItem | null, resultInfo: ResultInfo | null, nextItem: Ast.DialogueHistoryItem); } export declare class ContextInfo { loader: ThingpediaLoader; contextTable: SentenceGeneratorTypes.ContextTable; state: Ast.DialogueState; currentFunction: Ast.FunctionDef | null; currentTableFunction: Ast.FunctionDef | null; resultInfo: ResultInfo | null; isMultiDomain: boolean; previousDomainIdx: number | null; currentIdx: number | null; nextFunction: Ast.FunctionDef | null; nextIdx: number | null; nextInfo: NextStatementInfo | null; aux: any; key: { currentFunction: string | null; nextFunction: string | null; currentTableFunction: string | null; idType: Type | null; id0: string | number | null; id1: string | number | null; id2: string | number | null; resultLength: number; aggregationCount: number | null; is_monitorable: boolean; }; constructor(loader: ThingpediaLoader, contextTable: SentenceGeneratorTypes.ContextTable, state: Ast.DialogueState, currentTableSchema: Ast.FunctionDef | null, currentFunctionSchema: Ast.FunctionDef | null, resultInfo: ResultInfo | null, previousDomainIdx: number | null, currentIdx: number | null, nextIdx: number | null, nextFunctionSchema: Ast.FunctionDef | null, nextInfo: NextStatementInfo | null, aux?: any); toString(): string; get results(): ThingTalk.Ast.DialogueHistoryResultItem[] | null; get error(): ThingTalk.Ast.Value | null; get previousDomain(): ThingTalk.Ast.DialogueHistoryItem | null; get current(): ThingTalk.Ast.DialogueHistoryItem | null; get next(): ThingTalk.Ast.DialogueHistoryItem | null; clone(): ContextInfo; } export declare function contextKeyFn(ctx: ContextInfo): { currentFunction: string | null; nextFunction: string | null; currentTableFunction: string | null; idType: ThingTalk.Type | null; id0: string | number | null; id1: string | number | null; id2: string | number | null; resultLength: number; aggregationCount: number | null; is_monitorable: boolean; }; export declare function initialContextInfo(loader: ThingpediaLoader, contextTable: SentenceGeneratorTypes.ContextTable): ContextInfo; export declare function getContextInfo(loader: ThingpediaLoader, state: Ast.DialogueState, contextTable: SentenceGeneratorTypes.ContextTable): ContextInfo; export declare function isUserAskingResultQuestion(ctx: ContextInfo): boolean; declare function addNewItem(ctx: ContextInfo, dialogueAct: string, dialogueActParam: string | null, confirm: 'accepted-query' | 'accepted' | 'proposed' | 'proposed-query' | 'confirmed', ...newHistoryItem: Ast.DialogueHistoryItem[]): Ast.DialogueState; export declare function addNewStatement(ctx: ContextInfo, dialogueAct: string, dialogueActParam: string | null, confirm: 'accepted' | 'proposed' | 'confirmed', ...newExpression: Ast.Expression[]): ThingTalk.Ast.DialogueState; export declare function acceptAllProposedStatements(ctx: ContextInfo): ThingTalk.Ast.DialogueState | null; declare function makeSimpleState(ctx: ContextInfo, dialogueAct: string, dialogueActParam: string[] | null): Ast.DialogueState; declare function sortByName(p1: Ast.InputParam, p2: Ast.InputParam): -1 | 0 | 1; declare function setOrAddInvocationParam(newInvocation: Ast.Invocation, pname: string, value: Ast.Value): void; declare function mergeParameters(toInvocation: Ast.Invocation, fromInvocation: Ast.Invocation): Ast.Invocation; declare function addActionParam(ctx: ContextInfo, dialogueAct: string, action: Ast.Invocation, pname: string, value: Ast.Value, confirm: 'accepted' | 'proposed'): Ast.DialogueState; declare function addAction(ctx: ContextInfo, dialogueAct: string, action: Ast.Invocation, confirm: 'accepted' | 'proposed'): Ast.DialogueState; declare function addQuery(ctx: ContextInfo, dialogueAct: string, newTable: Ast.Expression, confirm: 'accepted' | 'proposed'): Ast.DialogueState; declare function addQueryAndAction(ctx: ContextInfo, dialogueAct: string, newTable: Ast.Expression, newAction: Ast.Invocation, confirm: 'accepted' | 'proposed'): Ast.DialogueState; export declare function makeContextPhrase(symbol: number, value: ContextInfo, utterance?: SentenceGeneratorRuntime.ReplacedResult, priority?: number): SentenceGeneratorTypes.ContextPhrase; export declare function makeExpressionContextPhrase(context: ContextInfo, symbol: number, value: Ast.Expression, utterance?: SentenceGeneratorRuntime.ReplacedResult, priority?: number): SentenceGeneratorTypes.ContextPhrase; export declare function makeValueContextPhrase(context: ContextInfo, symbol: number, value: Ast.Value, utterance?: SentenceGeneratorRuntime.ReplacedResult, priority?: number): SentenceGeneratorTypes.ContextPhrase; export interface AgentReplyOptions { end?: boolean; raw?: boolean; numResults?: number; } /** * Construct a full formal reply from the agent. * * The reply contains: * - the agent state (a ThingTalk dialogue state passed to the NLU and NLG networks) * - the agent reply tags (a list of strings that define the context tags on the user side) * - the interaction state (the expected type of the reply, if any, and a boolean indicating raw mode) * - extra information for the new context */ declare function makeAgentReply(ctx: ContextInfo, state: Ast.DialogueState, aux?: unknown, expectedType?: ThingTalk.Type | null, options?: AgentReplyOptions): AgentReplyRecord; declare function setEndBit(reply: AgentReplyRecord, value: boolean): AgentReplyRecord; export declare function tagContextForAgent(ctx: ContextInfo): number[]; export declare function makeResultContextPhrase(ctx: ContextInfo, topResult: Ast.DialogueHistoryResultItem, allResults: Ast.DialogueHistoryResultItem[]): ({ symbol: number; utterance: SentenceGeneratorRuntime.ReplacedResult; value: (SlotBag | ContextInfo)[]; priority: number; context: ContextInfo; key: { functionName: string | null; idType: ThingTalk.Type | null; }; } | { symbol: number; utterance: SentenceGeneratorRuntime.ReplacedResult; value: SlotBag; priority: number; context: ContextInfo; key: { functionName: string | null; idType: ThingTalk.Type | null; }; })[]; export declare function makeEmptyResultContextPhrase(ctx: ContextInfo): { symbol: number; utterance: SentenceGeneratorRuntime.ReplacedResult; value: SlotBag; priority: number; context: ContextInfo; key: { functionName: string | null; idType: ThingTalk.Type | null; }; }[]; export interface NameList { ctx: ContextInfo; results: Ast.DialogueHistoryResultItem[]; } export declare function nameListKeyFn(list: NameList): { functionName: string; idType: ThingTalk.Type; length: number; id0: string | number | null; id1: string | number | null; id2: string | number | null; }; export interface ContextName { ctx: ContextInfo; name: Ast.Value; } export declare function contextNameKeyFn(name: ContextName): { currentFunction: string | null; }; export declare function makeNameListContextPhrases(ctx: ContextInfo): SentenceGeneratorTypes.ContextPhrase[]; export declare function getUserContextPhrases(ctx: ContextInfo): SentenceGeneratorTypes.ContextPhrase[]; export declare function getAgentContextPhrases(ctx: ContextInfo): SentenceGeneratorTypes.ContextPhrase[]; export { makeAgentReply, setEndBit, sortByName, makeSimpleState, addNewItem, addActionParam, addAction, addQuery, addQueryAndAction, mergeParameters, setOrAddInvocationParam, };