@convo-lang/convo-lang
Version:
The language of AI
76 lines (75 loc) • 4.23 kB
TypeScript
import { ZodObject, ZodType } from 'zod';
import { Conversation } from './Conversation';
import { ConvoCompletionMessage, ConvoExecuteResult, ConvoFunction, ConvoGlobal, ConvoMessage, ConvoPrintFunction, ConvoScope, ConvoScopeFunction, ConvoStatement, ConvoTag, FlatConvoConversation } 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;
private readonly parentConvo?;
print: ConvoPrintFunction;
dynamicFunctionCallback: ConvoScopeFunction | undefined;
defaultThrowOnUndefined: boolean;
disableInlinePrompts: boolean;
maxInlinePromptDepth: number;
isReadonly: number;
flat?: FlatConvoConversation;
varPrefix?: string;
constructor(convo?: Partial<ConvoGlobal>, parentConvo?: Conversation);
getUserSharedVars(): {
[x: string]: any;
};
getUserSharedVarsExcludeTypes(): {
[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 lastInlineConversation?;
private executeStaticPrompt;
private createInlineConversation;
private applyInlinePrompt;
private executePromptAsync;
private beforeHandlePromptResult;
private handlePromptResult;
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;
getStringVar(nameOrPath: string, scope?: ConvoScope | null, defaultValue?: string): string | undefined;
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;
setVarUsingCompletionMessage(shared: boolean | undefined, msg: ConvoCompletionMessage, name: string, path?: string[], scope?: ConvoScope): void;
consumeVars(otherExec: ConvoExecutionContext | null | undefined): void;
getTagValueByName(msg: ConvoMessage | null | undefined, tagName: string, defaultValue?: any): any;
getTagValue(tag: ConvoTag, defaultValue?: any): any;
isTagConditionTrueByName(msg: ConvoMessage | null | undefined, tagName: string, defaultValue?: boolean): boolean;
isTagConditionTrue(tag: ConvoTag, defaultValue?: boolean): boolean;
getTagStatementValue(tag: ConvoTag): any[];
enableRag(paramValues?: any[]): any[];
clearRag(): void;
/**
* Gets built-in type aliases by name. Used to provide predefined types
* that are commonly used in Convo-Lang but not explicitly defined in user code.
*
* @param name - The name of the type alias to retrieve
* @returns The type definition, or undefined if the alias doesn't exist
*/
getVarAlias(name: string): any;
}