Files
claude-code-haha/src/services/api/requestBodyAudit.ts
T
程序员阿江(Relakkes) ccc48df0e0 feat(api): align Codex request routing and tool payloads
Preserve optional function arguments with explicit non-strict schemas.
Send stable session and thread identities, retain routing state through
one user turn and dispose it on completion or cancellation.

Compress Codex OAuth request bodies with zstd when supported, retaining
readable request audit data and a local compatibility opt-out without
replaying submitted requests.

Validation: 352 focused offline API/provider tests passed. The real query
loop regression covers tool continuation, next-turn reset and cleanup.
Selected repository verification passed with mocked transports.
2026-09-10 20:58:55 +08:00

23 lines
745 B
TypeScript

/** Only locally encoded bodies are associated with plaintext; never decompress caller input. */
export type RequestBodyAudit = Readonly<{
plainBody: string
requestEncoding: 'zstd'
requestPlainBytes: number
requestWireBytes: number
}>
const encodedBodies = new WeakMap<Uint8Array, RequestBodyAudit>()
export function registerEncodedRequestBody(body: Uint8Array, plainBody: string): void {
encodedBodies.set(body, Object.freeze({
plainBody,
requestEncoding: 'zstd',
requestPlainBytes: Buffer.byteLength(plainBody),
requestWireBytes: body.byteLength,
}))
}
export function getRequestBodyAudit(body: unknown): RequestBodyAudit | undefined {
return body instanceof Uint8Array ? encodedBodies.get(body) : undefined
}