import * as Tp from 'thingpedia'; import { Type, SchemaRetriever, Syntax, Ast } from 'thingtalk'; import * as I18n from '../i18n'; import { Hashable } from '../utils/hashmap'; import { ReplacedResult } from '../utils/template-string'; import type SentenceGenerator from './generator'; import type { SentenceGeneratorOptions } from './generator'; import type ThingpediaLoader from '../templates/load-thingpedia'; export interface RuleAttributes { weight?: number; priority?: number; repeat?: boolean; forConstant?: boolean; temporary?: boolean; identity?: boolean; expandchoice?: boolean; } export declare type DerivationKeyValue = string | number | boolean | null | Hashable; /** * A compound key used to efficiently index compatible keys. * * This is a record of index names and hashable keys. * The generation algorithm keeps track of an index (hash table) for * every known index name. */ export declare type DerivationKey = Record; export declare type SemanticAction = (...args: ArgType) => ReturnType | null; export declare type KeyFunction = (value: ValueType) => DerivationKey; export interface ContextPhrase { symbol: number; utterance: ReplacedResult; value: unknown; context: unknown; priority?: number; key: DerivationKey; } export declare type ContextTable = Record; export interface AgentReplyRecord { state: Ast.DialogueState; contextPhrases: ContextPhrase[]; expect: Type | null; end: boolean; raw: boolean; numResults: number; } export interface GrammarOptions { thingpediaClient: Tp.BaseClient; schemaRetriever?: SchemaRetriever; entityAllocator: Syntax.SequentialEntityAllocator; forSide: 'user' | 'agent'; contextual: boolean; flags: { [key: string]: boolean; }; onlyDevices?: string[]; whiteList?: string; debug: number; timezone: string | undefined; } /** * A statically-defined non-terminal in a Genie template file. * * This type exists only for documentation. */ export declare type NonTerminal = ValueType extends unknown ? string : never; /** * The abstract interface of a dialogue policy module. * * This interface defines the functions that a policy module should export. */ export interface PolicyModule { /** * The policy manifest. * * This is used to check the generated dialogue states for correctness. */ MANIFEST: { name: string; terminalAct: string; dialogueActs: { user: readonly string[]; agent: readonly string[]; withParam: readonly string[]; }; }; initializeTemplates(agentOptions: SentenceGeneratorOptions, langPack: I18n.LanguagePack, grammar: SentenceGenerator, tpLoader: ThingpediaLoader): Promise; getContextPhrasesForState(state: Ast.DialogueState | null, tpLoader: ThingpediaLoader, contextTable: ContextTable): ContextPhrase[] | null; interpretAnswer?(state: Ast.DialogueState, value: Ast.Value, tpLoader: ThingpediaLoader, contextTable: ContextTable): Ast.DialogueState | null; initialState?(tpLoader: ThingpediaLoader): Ast.DialogueState | null; notification?(appName: string | null, program: Ast.Program, result: Ast.DialogueHistoryResultItem): Ast.DialogueState | null; notifyError?(appName: string | null, program: Ast.Program, error: Ast.Value): Ast.DialogueState | null; getFollowUp?(state: Ast.DialogueState, tpLoader: ThingpediaLoader, contextTable: ContextTable): Ast.DialogueState | null; }