type cJSON = string | number | boolean | null | undefined | { [x: string]: cJSON; } | Array; interface LLMonitorOptions { appId?: string; apiUrl?: string; verbose?: boolean; } type RunType = "log" | "tool" | "agent" | "llm" | "chain" | "retriever" | "embed" | "thread" | "chat"; type EventName = "start" | "end" | "error" | "info" | "warn" | "feedback"; interface Event { type: RunType; event: EventName; app: string; timestamp: number; userId?: string; userProps?: cJSON; parentRunId?: string; extra?: cJSON; tags?: string[]; runtime?: string; error?: { message: string; stack?: string; }; } type TokenUsage = { completion: number; prompt: number; }; interface RunEvent extends Event { runId: string; input?: cJSON; output?: cJSON; tokensUsage?: TokenUsage; [key: string]: unknown; } interface LogEvent extends Event { message: string; } interface ChatMessage { role: "user" | "assistant" | "system" | "function" | "tool"; text: string; [key: string]: cJSON; } type WrapExtras = { name?: string; extra?: cJSON; tags?: string[]; userId?: string; userProps?: cJSON; }; type WrapParams = { inputParser?: (...args: Parameters) => cJSON; extraParser?: (...args: Parameters) => cJSON; nameParser?: (...args: Parameters) => string; outputParser?: (result: Awaited>) => cJSON; tagsParser?: (...args: Parameters) => string[]; userIdParser?: (...args: Parameters) => string; userPropsParser?: (...args: Parameters) => cJSON; tokensUsageParser?: (result: Awaited>) => Promise; enableWaitUntil?: (...args: Parameters) => boolean; forceFlush?: (...args: Parameters) => boolean; waitUntil?: (result: Awaited>, onComplete: (any: any) => any, onError: (any: any) => any) => ReturnType; } & WrapExtras; type WrappableFn = (...args: any[]) => any; type Identify = (userId: string, userProps?: cJSON) => WrappedReturn; type SetParent = (runId: string) => WrappedReturn; type WrappedReturn = ReturnType & { identify: Identify; setParent: SetParent; }; type WrappedFn = (...args: Parameters) => WrappedReturn; export { ChatMessage, Event, EventName, Identify, LLMonitorOptions, LogEvent, RunEvent, RunType, SetParent, TokenUsage, WrapExtras, WrapParams, WrappableFn, WrappedFn, WrappedReturn, cJSON };