@iyio/convo-lang
Version:
A conversational language.
40 lines (39 loc) • 2.41 kB
TypeScript
import { ZodObject, ZodType } from 'zod';
import { ConvoExecuteResult, ConvoFunction, ConvoGlobal, ConvoMessage, ConvoPrintFunction, ConvoScope, ConvoScopeFunction, ConvoStatement } from "./convo-types";
export declare const executeConvoFunction: (fn: ConvoFunction, args?: Record<string, any>) => Promise<any> | any;
export declare class ConvoExecutionContext {
readonly sharedVars: Record<string, any>;
private nextSuspendId;
private readonly suspendedScopes;
readonly sharedSetters: string[];
readonly convo: ConvoGlobal;
print: ConvoPrintFunction;
dynamicFunctionCallback: ConvoScopeFunction | undefined;
constructor(convo?: Partial<ConvoGlobal>);
getUserSharedVars(): {
[x: string]: any;
};
loadFunctions(messages: ConvoMessage[], externFunctions?: Record<string, ConvoScopeFunction>): void;
clearSharedSetters(): void;
executeStatement(statement: ConvoStatement): ConvoExecuteResult;
executeFunction(fn: ConvoFunction, args?: Record<string, any>): ConvoExecuteResult;
executeFunctionAsync(fn: ConvoFunction, args?: Record<string, any>): Promise<any>;
executeFunctionResultAsync(fn: ConvoFunction, args?: Record<string, any>): Promise<ConvoExecuteResult>;
getConvoFunctionArgsValue(fn: ConvoFunction): any;
getConvoFunctionArgsScheme(fn: ConvoFunction, cache?: boolean): ZodObject<any>;
getConvoFunctionReturnScheme(fn: ConvoFunction, cache?: boolean): ZodType<any> | undefined;
getVarAsType(name: string): ZodType<any> | undefined;
paramsToObj(params: ConvoStatement[]): ConvoExecuteResult;
paramsToObjAsync(params: ConvoStatement[]): Promise<Record<string, any>>;
paramsToScheme(params: ConvoStatement[]): ZodObject<any>;
private execute;
private executeScope;
private suspendScope;
private completeScope;
getRefValue(statement: ConvoStatement | null | undefined, scope?: ConvoScope, throwUndefined?: boolean): any;
getVarEx(name: string, path?: string[], scope?: ConvoScope, throwUndefined?: boolean): any;
getVar(nameOrPath: string, scope?: ConvoScope | null, defaultValue?: any): any;
setRefValue(statement: ConvoStatement | null | undefined, value: any, scope?: ConvoScope): any;
setDefaultVarValue(value: any, name: string, path?: string[]): any;
setVar(shared: boolean | undefined, value: any, name: string, path?: string[], scope?: ConvoScope): any;
}