@hashbrownai/core
Version:
Runtime helpers for Hashbrown AI
59 lines • 1.63 kB
TypeScript
import { RuntimeFunctionRef } from './create-runtime-function-impl';
/**
* A reference to a JavaScript runtime.
*/
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.
*
* @param options - The options for creating the runtime.
* @param options.timeout - The timeout for the runtime.
* @param options.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.
*
* @default 10000
*/
timeout?: number;
/**
* The functions that are available in the runtime.
*/
functions: [...RuntimeFunctionRef<any, any>[]];
}): RuntimeRef;
//# sourceMappingURL=create-runtime-impl.d.ts.map