UNPKG

@traceprompt/node

Version:

Client-side encrypted, audit-ready logging for LLM applications

47 lines (40 loc) 1.53 kB
import { Registry } from 'prom-client'; interface TracePromptInit { dataDir?: string; apiKey: string; cmkArn?: string; ingestUrl: string; batchSize?: number; flushIntervalMs?: number; staticMeta?: Record<string, unknown>; logLevel?: "error" | "warn" | "info" | "verbose" | "debug" | "silly"; } interface WrapOpts { modelVendor: "openai" | "anthropic" | "grok" | "local"; modelName: string; userId?: string; } interface EncryptedBundle { ciphertext: string; encryptedDataKey: string; suiteId?: number; } interface QueueItem { payload: Record<string, unknown> & { enc: EncryptedBundle; }; leafHash: string; } declare function initTracePrompt(cfg?: Partial<TracePromptInit>): Promise<void>; declare function wrapLLM<P extends Record<string, any>, R>(originalFn: (prompt: string, params?: P) => Promise<R>, meta: WrapOpts): (prompt: string, params?: P) => Promise<R>; declare function decryptBundle(bundle: EncryptedBundle): Promise<Buffer>; declare const registry: Registry<"text/plain; version=0.0.4; charset=utf-8">; declare function append(item: QueueItem): Promise<void>; declare function flushOnce(): Promise<any>; declare function gracefulShutdown(): Promise<void>; declare const PersistentBatcher: { enqueue: typeof append; flush: typeof flushOnce; gracefulShutdown: typeof gracefulShutdown; }; export { type EncryptedBundle, PersistentBatcher, type TracePromptInit, type WrapOpts, decryptBundle, initTracePrompt, registry, wrapLLM };