mirror of
https://github.com/NanmiCoder/claude-code-haha.git
synced 2026-10-10 11:53:10 +08:00
ccc48df0e0
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.
23 lines
745 B
TypeScript
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
|
|
}
|