UNPKG

@hashbrownai/core

Version:

Runtime helpers for Hashbrown AI

62 lines 1.65 kB
import { RuntimeFunctionRef } from './create-runtime-function-impl'; /** * A reference to a JavaScript runtime. * * @public */ export interface RuntimeRef { /** * The functions that are available in the runtime. */ readonly functions: [...RuntimeFunctionRef<any, any>[]]; /** * The timeout for the runtime. */ readonly timeout: number; /** * Describes the runtime to the LLM. * * Example: * * ```js * const description = runtime.describe(); * ``` */ readonly describe: () => string; /** * Run JavaScript code in the runtime. * * Example: * * ```js * const result = await runtime.run('return 1 + 1;', AbortSignal.timeout(1000)); * ``` * * @param code - The JavaScript code to run. * @param abortSignal - An optional abort signal to cancel the operation. * @returns The result of the code execution. */ readonly run: (code: string, abortSignal: AbortSignal) => Promise<any>; } /** * Creates a new runtime. * * @public * @param options - The options for creating the runtime containing: * - `timeout`: The timeout for the runtime * - `functions`: The functions that are available in the runtime * @returns A reference to the runtime. */ export declare function createRuntimeImpl(options: { /** * The timeout for the runtime. * * @defaultValue 10000 */ timeout?: number; /** * The functions that are available in the runtime. */ functions: [...RuntimeFunctionRef<any, any>[]]; }): RuntimeRef; //# sourceMappingURL=create-runtime-impl.d.ts.map