(fingerprint: string)
| 71 | * replacement avoids Content-Length changes and buffer reallocation. |
| 72 | */ |
| 73 | export function getAttributionHeader(fingerprint: string): string { |
| 74 | if (!isAttributionHeaderEnabled()) { |
| 75 | return '' |
| 76 | } |
| 77 | |
| 78 | const version = `${MACRO.VERSION}.${fingerprint}` |
| 79 | const entrypoint = process.env.CLAUDE_CODE_ENTRYPOINT ?? 'unknown' |
| 80 | |
| 81 | // cch=00000 placeholder is overwritten by Bun's HTTP stack with attestation token |
| 82 | const cch = feature('NATIVE_CLIENT_ATTESTATION') ? ' cch=00000;' : '' |
| 83 | // cc_workload: turn-scoped hint so the API can route e.g. cron-initiated |
| 84 | // requests to a lower QoS pool. Absent = interactive default. Safe re: |
| 85 | // fingerprint (computed from msg chars + version only, line 78 above) and |
| 86 | // cch attestation (placeholder overwritten in serialized body bytes after |
| 87 | // this string is built). Server _parse_cc_header tolerates unknown extra |
| 88 | // fields so old API deploys silently ignore this. |
| 89 | const workload = getWorkload() |
| 90 | const workloadPair = workload ? ` cc_workload=${workload};` : '' |
| 91 | const header = `x-anthropic-billing-header: cc_version=${version}; cc_entrypoint=${entrypoint};${cch}${workloadPair}` |
| 92 | |
| 93 | logForDebugging(`attribution header ${header}`) |
| 94 | return header |
| 95 | } |
| 96 |
no test coverage detected