@ai2070/l0
Version:
L0: The Missing Reliability Substrate for AI
107 lines • 2.91 kB
TypeScript
export interface GuardrailRule {
name: string;
description?: string;
check: (context: GuardrailContext) => GuardrailViolation[];
streaming?: boolean;
severity?: "warning" | "error" | "fatal";
recoverable?: boolean;
}
export interface GuardrailContext {
content: string;
checkpoint?: string;
delta?: string;
tokenCount: number;
completed: boolean;
metadata?: Record<string, any>;
previousViolations?: GuardrailViolation[];
}
export interface GuardrailViolation {
rule: string;
message: string;
severity: "warning" | "error" | "fatal";
position?: number;
recoverable: boolean;
timestamp?: number;
context?: Record<string, any>;
suggestion?: string;
}
export interface GuardrailState {
violations: GuardrailViolation[];
violationsByRule: Map<string, GuardrailViolation[]>;
hasFatalViolations: boolean;
hasErrorViolations: boolean;
violationCount: number;
lastCheckTime?: number;
}
export interface GuardrailConfig {
rules: GuardrailRule[];
stopOnFatal?: boolean;
enableStreaming?: boolean;
checkInterval?: number;
onViolation?: (violation: GuardrailViolation) => void;
onPhaseStart?: (contextSize: number, ruleCount: number) => void;
onPhaseEnd?: (ruleCount: number, violationCount: number) => void;
onRuleStart?: (index: number, ruleId: string) => void;
onRuleEnd?: (index: number, ruleId: string) => void;
}
export interface GuardrailResult {
passed: boolean;
violations: GuardrailViolation[];
shouldRetry: boolean;
shouldHalt: boolean;
summary: {
total: number;
fatal: number;
errors: number;
warnings: number;
};
}
export interface JsonStructure {
openBraces: number;
closeBraces: number;
openBrackets: number;
closeBrackets: number;
inString: boolean;
isBalanced: boolean;
issues: string[];
}
export interface MarkdownStructure {
openFences: number;
fenceLanguages: string[];
inFence: boolean;
headers: number[];
listDepth: number;
issues: string[];
}
export interface LatexStructure {
openEnvironments: string[];
isBalanced: boolean;
issues: string[];
}
export interface PatternConfig {
patterns: Array<string | RegExp>;
isBadPattern: boolean;
message?: string;
fatal?: boolean;
}
export interface DriftConfig {
detectToneShift?: boolean;
detectMetaCommentary?: boolean;
detectRepetition?: boolean;
detectEntropySpike?: boolean;
entropyThreshold?: number;
repetitionThreshold?: number;
}
export interface FunctionCallStructure {
name?: string;
arguments?: string;
parsedArguments?: Record<string, any>;
isValid: boolean;
errors: string[];
}
export interface SchemaValidation {
valid: boolean;
errors: string[];
parsed?: any;
}
//# sourceMappingURL=guardrails.d.ts.map