| 10 | const VERBOSE_FLAGS = new Set(['--verbose', '-v']) |
| 11 | |
| 12 | const call = async args => { |
| 13 | const tokens = args.trim().split(/\s+/).filter(Boolean) |
| 14 | const verbose = tokens.some(token => VERBOSE_FLAGS.has(token)) |
| 15 | |
| 16 | const beforeScenario = getCurrentMockScenario() |
| 17 | const beforeStatus = getMockStatus() |
| 18 | const hadHeaderlessOverride = Boolean(process.env.CLAUDE_MOCK_HEADERLESS_429) |
| 19 | |
| 20 | clearMockHeaders() |
| 21 | |
| 22 | // This env var only affects the current process. Clearing it here makes |
| 23 | // /reset-limits fully reset in-session rate-limit mock behavior. |
| 24 | if (hadHeaderlessOverride) { |
| 25 | delete process.env.CLAUDE_MOCK_HEADERLESS_429 |
| 26 | } |
| 27 | |
| 28 | const afterStatus = getMockStatus() |
| 29 | const stillMocking = shouldProcessMockLimits() |
| 30 | |
| 31 | const lines = ['Reset mock rate-limit state.'] |
| 32 | |
| 33 | if (beforeScenario) { |
| 34 | lines.push( |
| 35 | `Previous scenario: ${beforeScenario} (${getScenarioDescription(beforeScenario)})`, |
| 36 | ) |
| 37 | } |
| 38 | |
| 39 | if (hadHeaderlessOverride) { |
| 40 | lines.push('Cleared CLAUDE_MOCK_HEADERLESS_429 for this process.') |
| 41 | } |
| 42 | |
| 43 | lines.push(afterStatus) |
| 44 | |
| 45 | if (verbose) { |
| 46 | lines.push('') |
| 47 | lines.push('Previous state:') |
| 48 | lines.push(beforeStatus) |
| 49 | } |
| 50 | |
| 51 | if (stillMocking) { |
| 52 | lines.push('') |
| 53 | lines.push( |
| 54 | 'Warning: rate-limit mocking still appears active. Check process env and mock settings.', |
| 55 | ) |
| 56 | } |
| 57 | |
| 58 | return { |
| 59 | type: 'text', |
| 60 | value: lines.join('\n'), |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | export const resetLimits = { |
| 65 | type: 'local', |
nothing calls this directly
no test coverage detected