()
| 28 | // WARNING: We rely on `claude-cli` in the user agent for log filtering. |
| 29 | // Please do NOT change this without making sure that logging also gets updated! |
| 30 | export function getUserAgent(): string { |
| 31 | const agentSdkVersion = process.env.CLAUDE_AGENT_SDK_VERSION |
| 32 | ? `, agent-sdk/${process.env.CLAUDE_AGENT_SDK_VERSION}` |
| 33 | : '' |
| 34 | // SDK consumers can identify their app/library via CLAUDE_AGENT_SDK_CLIENT_APP |
| 35 | // e.g., "my-app/1.0.0" or "my-library/2.1" |
| 36 | const clientApp = process.env.CLAUDE_AGENT_SDK_CLIENT_APP |
| 37 | ? `, client-app/${process.env.CLAUDE_AGENT_SDK_CLIENT_APP}` |
| 38 | : '' |
| 39 | // Turn-/process-scoped workload tag for cron-initiated requests. 1P-only |
| 40 | // observability — proxies strip HTTP headers; QoS routing uses cc_workload |
| 41 | // in the billing-header attribution block instead (see constants/system.ts). |
| 42 | // getAnthropicClient (client.ts:98) calls this per-request inside withRetry, |
| 43 | // so the read picks up the same setWorkload() value as getAttributionHeader. |
| 44 | const workload = getWorkload() |
| 45 | const workloadSuffix = workload ? `, workload/${workload}` : '' |
| 46 | return `claude-cli/${MACRO.VERSION} (${process.env.USER_TYPE}, ${process.env.CLAUDE_CODE_ENTRYPOINT ?? 'cli'}${agentSdkVersion}${clientApp}${workloadSuffix})` |
| 47 | } |
| 48 | |
| 49 | export function getMCPUserAgent(): string { |
| 50 | const parts: string[] = [] |
no test coverage detected