UNPKG

@hashbrownai/core

Version:

Runtime helpers for Hashbrown AI

53 lines 1.89 kB
import { s } from '../schema'; import type { QuickJSAsyncContext, QuickJSHandle } from 'quickjs-emscripten-core'; import { RuntimeTransport } from './transport'; /** * A reference to a function in the runtime. * * @public * @param Args - The args of the function. * @param Result - The result of the function. * @returns The function reference. */ export type RuntimeFunctionRef<Args, Result> = { name: string; description: string; args?: s.HashbrownType; result?: s.HashbrownType; handler: (args: Args, abortSignal: AbortSignal) => Result | Promise<Result>; }; /** * Creates a function with an input schema. * * @public * @param cfg - The configuration for the function containing: * - `name`: The name of the function * - `description`: The description of the function * - `args`: The args schema of the function * - `result`: The result schema of the function * - `handler`: The handler of the function * @returns The function reference. */ export declare function createRuntimeFunctionImpl(cfg: { name: string; description: string; args: s.HashbrownType; result: s.HashbrownType; handler: (args: unknown, abort?: AbortSignal) => unknown; } | { name: string; description: string; result: s.HashbrownType; handler: (abort?: AbortSignal) => unknown; } | { name: string; description: string; args: s.HashbrownType; handler: (args: unknown, abort?: AbortSignal) => unknown; } | { name: string; description: string; handler: (abortSignal?: AbortSignal) => unknown; }): RuntimeFunctionRef<any, any>; export declare function attachFunctionToContext(context: QuickJSAsyncContext, transport: RuntimeTransport, definition: RuntimeFunctionRef<any, Promise<any>>, attachTo: QuickJSHandle, abortSignal: AbortSignal): QuickJSHandle; //# sourceMappingURL=create-runtime-function-impl.d.ts.map