UNPKG

@convo-lang/convo-lang

Version:
90 lines (89 loc) 5.09 kB
import { ZodObject, ZodType } from 'zod'; import { Conversation } from './Conversation.js'; import { ConvoCompletionMessage, ConvoExecuteFunctionOptions, ConvoExecuteResult, ConvoFunction, ConvoGlobal, ConvoMessage, ConvoPrintFunction, ConvoScope, ConvoScopeFunction, ConvoStatement, ConvoTag, FlatConvoConversation } from "./convo-types.js"; export declare const executeConvoFunction: (fn: ConvoFunction, args?: Record<string, any>, message?: ConvoMessage) => 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, message?: ConvoMessage): ConvoExecuteResult; executeFunction(fn: ConvoFunction, args?: Record<string, any>, message?: ConvoMessage, options?: ConvoExecuteFunctionOptions): ConvoExecuteResult; executeFunctionAsync(fn: ConvoFunction, args?: Record<string, any>, message?: ConvoMessage): Promise<any>; executeFunctionResultAsync(fn: ConvoFunction, args?: Record<string, any>, message?: ConvoMessage): Promise<ConvoExecuteResult>; getConvoFunctionArgsValue(fn: ConvoFunction, message?: ConvoMessage): 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[], message?: ConvoMessage): ConvoExecuteResult; paramsToObjAsync(params: ConvoStatement[], message?: ConvoMessage): 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, message?: ConvoMessage): any[]; enableRag(paramValues?: any[]): any[]; clearRag(): void; /** * Returns the full path of the give path if the path is relative. The __cwd variable is used to * determine the current working directory. */ getFullPath(path: string | undefined | null, scope?: ConvoScope): string; /** * Gets the current working directory based on scope */ getCwd(scope?: ConvoScope): string; /** * Gets the current working directory based on scope or undefined if the current working directory * equals '.' */ getCwdOrUndefined(scope?: ConvoScope): string | undefined; /** * 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, scope?: ConvoScope): any; }