@ai2070/l0
Version:
L0: The Missing Reliability Substrate for AI
52 lines • 2.28 kB
TypeScript
import type { L0Telemetry } from "../types/l0";
import type { GuardrailViolation } from "../types/guardrails";
import type { L0Monitor } from "./monitoring";
import type * as Sentry from "@sentry/node";
import type { SeverityLevel, Breadcrumb, Scope } from "@sentry/types";
import type { EventHandler } from "./event-handlers";
export interface SentryClient {
captureException: typeof Sentry.captureException;
captureMessage: typeof Sentry.captureMessage;
addBreadcrumb: typeof Sentry.addBreadcrumb;
setTag: typeof Sentry.setTag;
setExtra: typeof Sentry.setExtra;
setContext: typeof Sentry.setContext;
startSpan?: typeof Sentry.startSpan;
withScope?: typeof Sentry.withScope;
}
export interface SentryConfig {
sentry: SentryClient;
captureNetworkErrors?: boolean;
captureGuardrailViolations?: boolean;
minGuardrailSeverity?: "warning" | "error" | "fatal";
breadcrumbsForTokens?: boolean;
enableTracing?: boolean;
tags?: Record<string, string>;
environment?: string;
}
export declare class L0Sentry {
private sentry;
private config;
constructor(config: SentryConfig);
startExecution(name?: string, metadata?: Record<string, any>): (() => void) | undefined;
startStream(): void;
recordToken(token?: string): void;
recordFirstToken(ttft: number): void;
recordNetworkError(error: Error, errorType: string, retried: boolean): void;
recordRetry(attempt: number, reason: string, isNetworkError: boolean): void;
recordGuardrailViolations(violations: GuardrailViolation[]): void;
recordDrift(detected: boolean, types: string[]): void;
completeStream(tokenCount: number): void;
completeExecution(telemetry: L0Telemetry): void;
recordFailure(error: Error, telemetry?: L0Telemetry): void;
recordFromMonitor(monitor: L0Monitor): void;
private mapSeverity;
private shouldCapture;
}
export declare function createSentryIntegration(config: SentryConfig): L0Sentry;
export declare function createSentryHandler(config: SentryConfig): EventHandler;
export declare function withSentry<T>(config: SentryConfig, fn: () => Promise<T & {
telemetry?: L0Telemetry;
}>): Promise<T>;
export type { SeverityLevel, Breadcrumb, Scope };
//# sourceMappingURL=sentry.d.ts.map