import type { UpstreamInterceptor } from './types.js'; /** * 匹配 Claude Code 注入的 x-anthropic-billing-header 前缀的正则。 * * 格式:x-anthropic-billing-header: cc_version=xxx; cc_entrypoint=xxx; cch=xxx;正文 * 或: x-anthropic-billing-header: cc_version=xxx; cc_entrypoint=xxx; cch=xxx正文 * 或: x-anthropic-billing-header: cc_version=xxx; cc_entrypoint=xxx;正文 * 或: x-anthropic-billing-header: cc_version=xxx; cc_entrypoint=xxx正文 * * - i 标志:大小写不敏感 * - cch= 部分可选(某些客户端如 Claude Desktop 不发送) * - cch 值允许包含空格(如 "e0 bf8") */ export declare const BILLING_HEADER_RE: RegExp; /** * 清理字符串中的 billing header 前缀。 * * - 如果字符串以 "x-anthropic-billing-header" 开头但正则无法完整匹配,抛出错误。 * - 如果字符串以 billing header 开头且匹配成功,去除前缀后返回剩余部分。 * - 如果不以 billing header 开头,返回 undefined。 */ export declare function cleanBillingHeader(text: string): string | undefined; /** * Compute 3-char hex fingerprint SHA256(SALT + chars + version)[:3]. */ export declare function computeFingerprint(messageText: string, version: string): string; /** * Extract the text of the first real user message, skipping blocks. */ export declare function extractRealUserMessageText(messages: any[]): string; /** * Extract text from the first user message (for legacy round-trip verification). */ export declare function extractFirstMessageText(messages: any[]): string; /** * Stabilize the cc_version fingerprint in the x-anthropic-billing-header block. */ export declare function stabilizeFingerprint(system: any[], messages: any[]): { attrIdx: number; newText: string; oldFingerprint: string; stableFingerprint: string; } | null; /** * Anthropic Billing Header 清理 & Fingerprint 稳定化拦截器。 * * 1. 遍历 messages 中所有 role=system 的消息,去除 billing header 前缀。 * 2. 处理 body.system(顶层 system 数组)中的 billing header。 * 3. 在 billing header 清理后,对 body.system 中的 cc_version fingerprint 进行稳定化。 * * 必须注册为第一个拦截器,优先执行。 */ export declare const anthropicBillingCleaner: UpstreamInterceptor; //# sourceMappingURL=anthropic-billing-cleaner.d.ts.map