/** * Hashing helpers. Conversation identity matches OpenRouter's own * fingerprinting (sha256 over system prompt + first non-system message), * so our `session_id` groups the same traffic their logs do. */ export function sha256Hex(input: string): string { return new Bun.CryptoHasher("sha256").update(input).digest("hex"); } /** First 32 hex chars of sha256(systemText NUL firstNonSystemText). */ export function conversationKeyOf(systemText: string, firstNonSystemText: string): string { return sha256Hex(systemText + "" + firstNonSystemText).slice(0, 32); }