* Dump the auto mode classifier request and response bodies to the per-user * claude temp directory when CLAUDE_CODE_DUMP_AUTO_MODE is set. Files are * named by unix timestamp: {timestamp}[.{suffix}].req.json and .res.json
( request: unknown, response: unknown, timestamp: number, suffix?: string, )
| 151 | * named by unix timestamp: {timestamp}[.{suffix}].req.json and .res.json |
| 152 | */ |
| 153 | async function maybeDumpAutoMode( |
| 154 | request: unknown, |
| 155 | response: unknown, |
| 156 | timestamp: number, |
| 157 | suffix?: string, |
| 158 | ): Promise<void> { |
| 159 | if (process.env.USER_TYPE !== 'ant') return |
| 160 | if (!isEnvTruthy(process.env.CLAUDE_CODE_DUMP_AUTO_MODE)) return |
| 161 | const base = suffix ? `${timestamp}.${suffix}` : `${timestamp}` |
| 162 | try { |
| 163 | await mkdir(getAutoModeDumpDir(), { recursive: true }) |
| 164 | await writeFile( |
| 165 | join(getAutoModeDumpDir(), `${base}.req.json`), |
| 166 | jsonStringify(request, null, 2), |
| 167 | 'utf-8', |
| 168 | ) |
| 169 | await writeFile( |
| 170 | join(getAutoModeDumpDir(), `${base}.res.json`), |
| 171 | jsonStringify(response, null, 2), |
| 172 | 'utf-8', |
| 173 | ) |
| 174 | logForDebugging( |
| 175 | `Dumped auto mode req/res to ${getAutoModeDumpDir()}/${base}.{req,res}.json`, |
| 176 | ) |
| 177 | } catch { |
| 178 | // Ignore errors |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | /** |
| 183 | * Session-scoped dump file for auto mode classifier error prompts. Written on API |
no test coverage detected