agsamantha/node_modules/langsmith/dist/singletons/traceable.d.ts

23 lines
1 KiB
TypeScript
Raw Normal View History

2024-10-02 15:15:21 -05:00
import { RunTree } from "../run_trees.js";
import { TraceableFunction } from "./types.js";
interface AsyncLocalStorageInterface {
getStore: () => RunTree | undefined;
run: (context: RunTree | undefined, fn: () => void) => void;
}
declare class AsyncLocalStorageProvider {
getInstance(): AsyncLocalStorageInterface;
initializeGlobalInstance(instance: AsyncLocalStorageInterface): void;
}
export declare const AsyncLocalStorageProviderSingleton: AsyncLocalStorageProvider;
/**
* Return the current run tree from within a traceable-wrapped function.
* Will throw an error if called outside of a traceable function.
*
* @returns The run tree for the given context.
*/
export declare const getCurrentRunTree: () => RunTree;
export declare function withRunTree<Fn extends (...args: any[]) => any>(runTree: RunTree, fn: Fn): Promise<Awaited<ReturnType<Fn>>>;
export declare const ROOT: unique symbol;
export declare function isTraceableFunction(x: unknown): x is TraceableFunction<any>;
export type { TraceableFunction } from "./types.js";