/** A single message in OpenAI/Anthropic format */ export interface LLMMessage { role: 'system' | 'user' | 'assistant' | 'tool'; content: string; name?: string; tool_call_id?: string; } /** Classification of the LLM operation */ export type OperationType = 'chat' | 'completion' | 'tool_call' | 'embedding' | 'moderation' | 'custom'; /** Provider identifier */ export type Provider = 'anthropic' | 'openai' | 'generic'; /** A single ledger entry — one LLM call recorded */ export interface LedgerEntry { /** Unique entry ID (uuid v4) */ id: string; /** ISO 8601 timestamp */ timestamp: string; /** SHA-256 hash of this entry's content */ hash: string; /** Hash of the previous entry (genesis = '0'.repeat(64)) */ previousHash: string; /** Sequence number in the chain (0-indexed) */ sequence: number; /** LLM provider */ provider: Provider; /** Model used */ model: string; /** Operation type */ operation: OperationType; /** Input messages / prompt */ input: LLMMessage[]; /** Output / response */ output: LLMMessage[]; /** Token counts */ tokens: { input: number; output: number; total: number; }; /** Latency in milliseconds */ latencyMs: number; /** Optional: agent or service name */ agent?: string; /** Optional: session/conversation ID */ sessionId?: string; /** Optional: user-provided tags */ tags?: string[]; /** Optional: custom metadata */ metadata?: Record; } /** Result of chain verification */ export interface VerificationResult { /** Is the chain intact? */ valid: boolean; /** Total entries checked */ entriesChecked: number; /** First broken link (null if valid) */ brokenAt: number | null; /** Details of the break */ brokenReason: string | null; /** Hash of the chain head */ headHash: string; /** Verification timestamp */ verifiedAt: string; /** Time taken to verify (ms) */ verificationMs: number; } /** Chain statistics */ export interface ChainStats { /** Total entries */ totalEntries: number; /** Chain start timestamp */ firstEntry: string | null; /** Chain end timestamp */ lastEntry: string | null; /** Unique models used */ models: string[]; /** Unique providers */ providers: Provider[]; /** Total tokens consumed */ totalTokens: { input: number; output: number; total: number; }; /** Average latency */ avgLatencyMs: number; /** Entries by operation type */ byOperation: Record; /** Entries by agent */ byAgent: Record; } /** Export format for compliance */ export interface LedgerExport { /** Export version */ version: '1.0'; /** Export timestamp */ exportedAt: string; /** Chain verification at export time */ verification: VerificationResult; /** Statistics */ stats: ChainStats; /** The entries */ entries: LedgerEntry[]; } /** Options for creating a ledger */ export interface LedgerOptions { /** Storage path (default: ~/.promptledger/ledger.db) */ storagePath?: string; /** Agent name to tag entries with */ agent?: string; /** Session ID */ sessionId?: string; /** Auto-verify chain on startup */ verifyOnStart?: boolean; } /** Options for recording an LLM call */ export interface RecordOptions { provider: Provider; model: string; operation?: OperationType; input: LLMMessage[]; output: LLMMessage[]; tokens?: { input: number; output: number; }; latencyMs?: number; agent?: string; sessionId?: string; tags?: string[]; metadata?: Record; } //# sourceMappingURL=types.d.ts.map